lablanguagestools
AntlrCalculator
Parser-generator calculator lab.- Java
- ANTLR
- Maven
- Docker
Simple CLI calculator app for me to get used to ANTLR parser generator.
Operations
The calculator supports the following operations:
- Addition (
+) - Subtraction (
-) - Multiplication (
*) - Division (
/) - Modulo (
%) - Unary plus (
+) - Unary minus (
-) - Parentheses for grouping (
())
Up and running
NB: For some of the scripts below you may need to run it with sudo, even though I discourage it.
Locally
To build locally you need maven, to run you need java. I use openjdk18.
- To build:
./scripts/build.sh
- To run as CLI:
./scripts/run.sh "(1.0 + -2)*-2.5e+1" # wait for some time
- To run as interactive REPL:
./scripts/run.sh # wait for some time
- To run tests:
./scripts/test.sh
Docker
- To build:
./scripts/docker/build.sh
- To run as CLI:
./scripts/docker/run.sh "(1.0 + -2)*-2.5e+1" # wait for some time
- To run as interactive REPL:
./scripts/docker/run.sh # wait for some time
- To run tests:
./scripts/docker/test.sh
TODO
- Cache some
mavendependencies duringdockerbuild so that it doesn’t take lifetime to run. - Mount src to docker so that you could edit it on the fly.