https://github.com/donydchen/dragon-front
The comment for A Complete Front End of the dragon book.
https://github.com/donydchen/dragon-front
compiler dragon-book java
Last synced: 5 months ago
JSON representation
The comment for A Complete Front End of the dragon book.
- Host: GitHub
- URL: https://github.com/donydchen/dragon-front
- Owner: donydchen
- Created: 2016-01-29T17:39:17.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-03-02T08:52:51.000Z (over 9 years ago)
- Last Synced: 2025-04-10T01:14:04.483Z (over 1 year ago)
- Topics: compiler, dragon-book, java
- Language: Java
- Homepage:
- Size: 1.84 MB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Dragon-Front
THE COMMENT FOR *A COMPLETE FRONT END* OF THE DRAGON BOOK
2015 SYSU COMPILER PROJECT 4
##文件结构简介
* **bin:** 由eclipse自动生成的可执行文件
* **doc:** javadoc生成的注解文档,使用命令:`javadoc inter/*.java lexer/*.java main/*.java parser/*.java symbols/*.java -d ../doc -encoding UTF-8 -charset UTF-8`
* **ref:** 其中*CompilerAppendixA.pdf*是龙书附录A,而*documents.pdf*则是编译器源码的分析与注解
* **src:** 完整编译器前端的源码,含注释
* **uml:** 编译器前端类的类图,包含jpg档和uxf档,其中uxf档请使用[UMLet](http://www.umlet.com/)打开
##编译器识别语言的文法
```
program -> block
block -> { decls stmts }
decls -> decl decls | epsilon
decl -> type id
type -> basic dims
dims -> [ num ] dims | epsilon
stmts -> stmt stmts | epsilon
stmt -> ;
| if ( bool ) stmt
| if ( bool ) stmt else stmt
| while ( bool ) stmt
| do stmt while ( bool ) ;
| break ;
| block
| assign
assign -> id offset = bool ;
offset -> [ bool ] offset | epsilon
bool -> join | join || bool
join -> equality | equality && join
equality -> rel | rel == equality | rel != equality
rel -> expr
| expr < expr | expr <= expr
| expr >= expr | expr > expr
expr -> term | term + expr | term - expr
term -> unary | unary * term | unary / term
unary -> - unary | ! unary | factor
factor -> ( bool ) | num | real | true | false | id offset
```