miniCompEval

所属分类:工具库
开发工具:C++
文件大小:0KB
下载次数:0
上传日期:2024-01-27 17:45:54
上 传 者sh-1993
说明:  玩具编译器和解释器
(Toy Compiler and Interpreter)

文件列表:
doc/
include/
source/
test/
CMakeLists.txt
Makefile

# A compiler and interpreter for the MiniJava syntax: Syntax dervied from: https://www.cs.tufts.edu/~sguyer/classes/comp181-2006/minijava.html ## Build (MacOs) ### Dependencies: * clang++ * flex * bison ### CMake: In the root directory ``` cmake -B build cmake --build build ``` Corresponding executables will be placed in `build` ``` cmake -DPNG=ON -B build cmake --build build ``` Generates a PNG of the tree during the build process as well. The tree can be found in `build/parse/tree.png`. ### Makefile: In the root directory ``` make ``` Create Tree PNG: ``` make png ``` ## Grammar ``` Program ::= MainClass ( ClassDeclaration )* MainClass ::= "class" Identifier "{" "public" "static" "void" "main" "(" "String" "[" "]" Identifier ")" "{" Statement "}" "}" ClassDeclaration ::= "class" Identifier ( "extends" Identifier )? "{" ( VarDeclaration )* ( MethodDeclaration )* "}" VarDeclaration ::= Type Identifier ";" MethodDeclaration ::= "public" Type Identifier "(" ( Type Identifier ( "," Type Identifier )* )? ")" "{" ( VarDeclaration )* ( Statement )* "return" Expression ";" "}" Type ::= "boolean" ( "[" "]" )* | "int" ( "[" "]" )* | Identifier ( "[" "]" )* | "boolean" | "int" | Identifier Statement ::= "{" ( Statement )* "}" | "if" "(" Expression ")" Statement "else" Statement | "while" "(" Expression ")" Statement | "System.out.println" "(" Expression ")" ";" | Identifier "=" Expression ";" | Identifier "[" Expression "]" "=" Expression ";" Expression ::= Expression ( "&&" | "<" | "+" | "-" | "*" ) Expression | Expression "[" Expression "]" | Expression "." "length" | Expression "." Identifier "(" ( Expression ( "," Expression )* )? ")" | | "true" | "false" | Identifier | "this" | "new" "int" "[" Expression "]" | "new" Identifier "(" ")" | "!" Expression | "(" Expression ")" Identifier ::= ``` ## The Makefile produces: ### [MiniJava_syntax.output](https://github.com/schriner/miniCompEval/blob/master/doc/MiniJava_syntax.output) Grammar specification from bison statefully ### MiniJava_syntax.dot Used to create a tree representation of the grammar specification ([tree.png](https://github.com/schriner/miniCompEval/blob/master/doc/tree.png)). ### mjavac: Compiler to ARM 32 bit assembly ``` mjavac [-o | --stdout ] .java ``` ### meval: Interpreter ``` meval [-o ] .java ``` ## TODO: Test Functionality

近期下载者

相关文件


收藏者