Skip to content

This compiler was developed as a project of the Formal Languages and Compilers class at State University of Feira de Santana.

Notifications You must be signed in to change notification settings

matheustdo/compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Compiler

This code was made using python to learn about formal languages and compilers.

How to use

The main code is at 'compiler.py' file.

A folder named as 'input/' must be created at the root path, containing the input files, which are named as 'entradaXYZ.txt', where 'XYZ" represents an integer value.

To execute the compiler you should have python 3 instaled at your machine, and run the following command:

python3 compiler.py

or

python compiler.py

The output files are created on 'output/' folder, located at the root.

Lexical structure table

The analyzer follows the lexical structure below:

Type Format
Reserved words var, const, typedef, struct, extends, procedure, function, start, return, if, else, then, while, read, print, int, real, boolean, string, true, false, global, local
Identifiers letter(letter | digit | _ ) *
Numbers Digit+(.Digit+))?
Digit [0-9]
Letter [a-z] | [A-Z]
Arithmetic operator + - * / ++ --
Relational operator == != > >= < <= =
Logical operator && || !
Comment delimiters // This is a comment
/* This is
a comment */
Delimiters ; , ( ) { } [ ] .
String " ( letter | digit | symbol | " )* "
Symbol ASCII code from 32 to 126 (except ASCII 34)

Grammar

The grammar is factored on the left, without left recursion, respecting the precedence and associativity of the arithmetic, logical and relational operators, using the GOLD Parser Builder software.

Its code was built by the class and can be found at Compiler Grammar.

About

Developed by Matheus Teles.

About

This compiler was developed as a project of the Formal Languages and Compilers class at State University of Feira de Santana.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages