/Compiler

編譯器作業 - 實作編譯器 (Scanner, Parser, Bytecode)

Primary LanguageC++

Compiler Project

  • for Scala

project1 - Scanner

  • yylex()
  • Regular Expression

project2 - Parser

  • add "return" in lex.l
  • move main() to yacc.y
  • use yyparse() instead of yylex()
  • use %union pass common variables between lex.l and yacc.y
  • rewrite SymbolTable
  • !! remember there must be main function here.

project3 - Java ByteCode

  • fix SymbolTable: add isGlobal()
  • In parser
    • use fstream to write the .jasm
    • record nowStack and nowLabel
    • for IF ELSE, use vector to store elseLabel
    • for WHILE, add union to store beginLabel and exitLabel
  • add javaa in file

Compile

$ make

Excute

$ make run file=`fileName`