summaryrefslogtreecommitdiffstats
path: root/code/simpleSableCCCalulator/README.md
blob: 4c754219761c14f555ad0ae19f203b00080dd110 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# simpleSableCCCalculator

sableCC is a too used to parse .grammar files (containing a BNF, and lexer information)
into a lexer and parser. We can do a depth first traversal of the produced abstract syntax tree
to parse in the correct order. This is in the file `Translation.java`.

You produce a lexer and parser by running the sablecc .jar file you can download [here](http://downloads.sourceforge.net/sablecc/sablecc-3.7.zip). Then run it with the first argument as the grammar file:

`java -jar sablecc-3.7/lib/sablecc.jar sableCCCalculator.grammar`

(changing the paths as appropriate). The produced java files are not included in git since they're unnessicary. We compile the compiler, program stack and translator:

`javac sableCCCalculator/*.java`

Then we can run the program. For now it only works by reading files. There are some example maths questions in the examples folder:

`java sableCCCalculator.Compiler examples/maths.txt`