Skip to content

holoubekm/BI-PJP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

BI-PJP Course

Programovací jazyky a překladače

CTU / ČVUT FIT

Joke language

Our semestral work was to create a lexer, parser and frontend for the GCC compiler. This repo contains already working code.

It simply adds a new frontend language for the GCC. Therefore anyone can simple compile file.joke and the GCC will compiler your code and link it against the standard library.

Syntax of the language was inspired by Pascal.

Sources

  • joke1.c - contains definition of a new frontend language
  • Make-lang.in - a modified version of GCC's standard makefile
  • frontend/my.cpp - main file driving the whole frontend - called by the GCC
  • frontend/lexparser.cpp - lexer generated by the flex tool - it's structure is defined in lexparser.ll
  • frontend/symtable.cpp - class working as a symple symbol table for the compiler
  • frontend/syntaxparser.cpp - parser which effectively consumes output of the lexer lexparser.cpp and build the AST as a TreeStatmList*
  • frontend/builder.cpp - converts abstract syntax tree (AST) to GCC's internal structure using macros magic and postorder tree traversal

How to compile

Please look at the GCC's main page and refer to manuals - how to add a new frontend language. Then copy files to appropriate folders and compile the GCC.

Compilation of the GCC should be preferably in the debug mode and the first phase of compilation should be enough. You probably need just the 1st phase - since there is no validation and unnecessary recompilation the whole process is much much faster.

Pro-tip

Compile GCC in the ramdisk - it'll speed up compilation several times.

Compile GCC using many working threads - preferably number of cores + delta