Lexical analyzer (scanner) for J-- using ANTLR4.
file: 30205038-cpsc411-milestone1.tex
usage:
- SSH into a CPSC Linux machine:
ssh <ucid>@cslinux.cpsc.ucalgary.ca - Clone your repo and cd into it.
- Run
make cleanto remove generated files. - Run
python3 ~aycock/411/TEST/ms1/runto execute all tests. - Check
run.outputfor results. - Compare with reference:
~aycock/411/j--scan <testfile>
build: make (generates Lexer.py from Lexer.g4)
limitations: ASCII only, no Unicode escapes, decimal integers only.
Parser and AST builder for J-- using the ANTLR4-generated parser plus ASTShaper.
file: 30205038-cpsc411-milestone2.tex
usage:
- Run
make cleanfollowed bymaketo regenerateLexer.pyandParser.pyfrom their grammars. - Execute
python3 ~aycock/411/TEST/ms2/runto rebuild and run the parser tests. - Inspect
run.outputfor the AST listings and success banner. - Compare the AST output with the reference:
~aycock/411/TEST/reference/j--parse <testfile>
build: make
limitations: no semantic analysis; only syntactic validation and AST emission.
Semantic checker based on cpsc411.ASTTraversal and a stack-of-scopes symbol table. Detects all 17 semantic errors in the specification, annotates AST nodes with sem_type, and reports errors to stderr with line-number context.
file: 30205038-cpsc411-milestone3.tex
usage:
- Run
make cleanfollowed bymaketo regenerateLexer.pyandParser.py. - Execute
~aycock/411/TEST/ms3/runto run all semantic tests. - Check
run.outputfor pass/fail detail and error message listings. - Compare with the reference:
~aycock/411/TEST/reference/j--sem <testfile>
build: make
limitations: treats all integer literals as 32-bit signed; does not perform constant folding for chained unary negation (consistent with reference compiler behaviour).
MIPS assembly backend: translates the semantically checked AST into MIPS
that runs under spim. python3 main.py implements the full pipeline
(see main.py and codegen.py).
file: 30205038-cpsc411-finalproject.tex
usage:
- Run
make cleanfollowed bymake. - Compile:
python3 main.py <source.j--> > out.s - Run:
~aycock/411/bin/spim -file out.s - Full suite:
python3 ~aycock/411/TEST/final/run(from repo root)
build: make
limitations: J-- subset only (see milestones above for lexer/parser/semantics). Codegen spills deep expressions to the stack; getchar uses a read-string syscall workaround for EOF (-1).