Skip to content

jbancamper/Bob-the-Compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bob-the-Compiler

Bob the Compiler, can he compile it? Bob the Compiler, YES HE CAN!

##Compile To build the compiler, type in Terminal

g++ lex.cpp parse.cpp cst.cpp semantic.cpp code_gen.cpp bobc.cpp -o bobc

Usage:

./bobc [option] testCode.txt

##Grammar

Non-Terminals Terminals
Program Block $
Block { StatementList }
StatementList Statement StatementList
Ø
Statement PrintStatement
AssignmentStatement
VarDecl
WhileStatement
IfStatement
Block
PrintStatement print ( Expr )
AssignmentStatement Id = Expr
VarDecl type Id
WhileStatement while BooleanExpr Block
IfStatement if BooleanExpr Block
Expr IntExpr
StringExpr
BooleanExpr
Id
IntExpr digit intop Expr
digit
StringExpr " CharList "
BooleanExpr ( Expr boolop Expr )
boolval
Id char
CharList char CharList
Ø
type int : string : boolean
char a : b : c ... z
space the space character
digit 1 : 2 : 3 : 4 : 5 : 6 : 7 : 8 : 9 : 0
boolop == : !=
boolval true : false
intop +

About

Bob the Compiler, can he compile it?! Bob the Compiler, YES HE CAN!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages