- 14
- 0
- 约6.65万字
- 约 39页
- 2018-04-08 发布于四川
- 举报
A COMPACT GUIDE TO
LEX YACC
by Thomas Niemann
Contents
Contents 2
Preface 3
Introduction 4
Lex 6
Theory 6
Practice 7
Yacc 11
Theory 11
Practice, Part I 12
Practice, Part II 15
Calculator 18
Description 18
Include File 21
Lex Input 22
Yacc Input 23
Interpreter 26
Compiler 27
Graph 29
More Lex 33
Strings 33
Reserved Words 34
Debugging Lex 34
More Yacc 35
Recursion 35
If-Else Ambiguity 35
Error Messages 36
Inherited Attributes 37
Embedded Actions 37
Debugging Yacc 38
Bibliography 39
2
Preface
This document explains how to construct a compiler using lex and yacc. Lex and yacc are tools
used to generate lexical analyzers and parsers. I assume you can program in C, and understand
data structures such as linked-lists and trees.
The introduction describes the basic building blocks of a compiler and explains the interaction
between lex and yacc. The next two sections describe lex and yacc in more detail. With this
background, we construct a sophisticated calculator. Conventional arithmetic operations and
control statements, such as if-else and while, are implemented. With minor changes, we convert
the calculator into a compiler for a stack-based machine. The remaining sections discuss issues
that commonly arise in compiler writing. Source code for examples may be downloaded from the
web site listed below.
Permission to reproduce portions of this document is given provided the web site listed below is
referenced, and no additional restrictions apply. Source code, when part of a software project,
may be used freely without reference to the author.
THOMAS NIEMANN
Portland, Oregon
web site:
您可能关注的文档
- Regulated Power Supply High Current稳压电源高电流.pdf
- Transcending Genetic Limits超越遗传限制.pdf
- An advanced deburring and a=chamfering system先进的去毛刺和倒角系统.pdf
- A Perspective on ISO C的透视.pdf
- ecp Interfacing the Extended Capabilities Port连接扩展功能端口.pdf
- Genetics and Reductionism Unveiling Mechanisms Without Metaphysics遗传学与还原论揭开机制而没有形而上学.pdf
- Cissp Risk Management风险管理.pdf
- A Love Of The King By Oscar Wilde奥斯卡王尔德的国王之爱.pdf
- Agile Methodologies and Extreme Programming in Context敏捷方法论与上下文极限编程.pdf
- CHRISTOPHER GAYNER Curriculum Vitae履历表.pdf
- 广东省广州省实验中学教育集团2025-2026学年八年级上学期期中考试物理试题(解析版).docx
- 广东省广州大学附属中学2025-2026学年八年级上学期奥班期中物理试题(解析版).docx
- 广东省广州市第八十六中学2025-2026学年八年级上学期期中物理试题(含答案).docx
- 广东省广州市第八十九中学2025-2026学年八年级上学期期中考试物理试题(解析版).docx
- 广东省广州市第二中学2025-2026学年八年级上学期期中考试物理试题(含答案).docx
- 广东省广州市第八十六中学2025-2026学年八年级上学期期中物理试题(解析版).docx
- 广东省广州市第八十九中学2025-2026学年八年级上学期期中考试物理试题(含答案).docx
- 广东省广州市第二中学2025-2026学年八年级上学期期中考试物理试题(解析版).docx
- 2026《中国人寿上海分公司营销员培训体系优化研究》18000字.docx
- 《生物探究性实验教学》中小学教师资格模拟试题.docx
原创力文档

文档评论(0)