- python >= 3.8
- Install jdk
sudo apt-get install default-jdk
- Install antrl
cd /usr/local/lib
sudo curl -O https://www.antlr.org/download/antlr-4.9.2-complete.jar
export CLASSPATH=".:/usr/local/lib/antlr-4.9.2-complete.jar:$CLASSPATH"
- Create virtual environment & install packages
cd ${project folder}
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
- Add to your .bashrc:
alias grun='java org.antlr.v4.gui.TestRig'
alias antlr4='java -jar /usr/local/lib/antlr-4.9.2-complete.jar'
- Source bashrc:
source ~/.bashrc
- Genrate grammar:
antlr4 -Dlanguage=Python3 ./antlr/PP.g4 -visitor -o dist
- command prompt will appear and user can enter commands
- after command submission by
ENTER
command will be interpreted
- Go into project folder
- Activate virtual env:
- linux:
source venv/bin/activate
- windows:
.\venv\Scripts\activate
- linux:
- Run programm:
- with realtime interpreter -
python runInterpreter.py
- with realtime interpreter -
- Go into project folder
- Activate virtual env:
- linux:
source venv/bin/activate
- windows:
.\venv\Scripts\activate
- linux:
- Run programm:
- with realtime interpreter -
python runGP.py
- with realtime interpreter -
Go to src/antlr4/tree/Tree.py and change:
def aggregateResult(self, aggregate, nextResult):
return nextResult
to
def aggregateResult(self, aggregate, nextResult):
if aggregate is None:
return nextResult
elif nextResult is None:
return aggregate
return aggregate + nextResult