Customize Compiler implements a statically strong typed language which compiles to Java. Its semantics is a subset of C but allows user-defined lexical and grammatical form by simply changing lexer.json
and production.json
.
- an optional interpreter as an back-end
- jsonify/serialize abstract syntax tree
- print generated automata using Latex
- generate Sublime syntax highlight configuration for user-defined lexical form
- interpret source code and show code coverage
There are three steps:
- edit
lexer.json
to define lexical form (regular expression is supported) - edit
production.json
to define grammatical form (with a little limitation) - run
Grammar Factory
main method and it will dynamically generate the parser
There are three examples in Syntax folder to show how to do this:
- C++
- Visual Basic
- Frog 🐸 (this is chinese programming language, mod is represented as '膜')
Different arguments could be used to trigger different functionality:
>java Compiler -help
Usage: compiler [option]
Default:
FILE_NAME : compile FILE_NAME to AST
Option:
-exec AST_NAME : execute AST_NAME
-json JSON_FILE_NAME AST_NAME : generate JSON format AST to JSON_FILE_NAME from AST_NAME
-showcoverage SOURCE_NAME : show SOURCE_NAME code coverage
-tojava JAVA_NAME AST_NAME : show java code to JAVA_NAME from AST_NAME
-repl : running REPL
-help : show this
...
see documentation.pdf for more information.