Projeto da matéria de Lógica da Computação.
Para utilizar o programa basta executar o seguinte comando:
python3 main.py source.c
Para rodar em modo debug
basta executar o programa com a flag -d
e -vvvv
(o número de v
controla a quantidade de informações geradas):
python3 main.py -d source.c
-d : CRITICAL & ERROR
-d -v : CRITICAL & ERROR & WARN & SUCCESS
-d -vv : CRITICAL & ERROR & WARN & SUCCESS & INFO
-d -vvv : CRITICAL & ERROR & WARN & SUCCESS & INFO & DEBUG
-d -vvvv : CRITICAL & ERROR & WARN & SUCCESS & INFO & DEBUG & TRACE
Para rodar os testes é necessário ter o pytest
instalado ou criar um virtual environment usando o Pipfile dado.
pytest test.py
Ou
pipenv run pytest test.py
BLOCK = "{", { COMMAND }, "}";
COMMAND = ( λ | VARIABLE_DECLARATION | ASSIGNMENT | PRINT | IF | WHILE | BLOCK), ";" ;
VARIABLE_DECLARATION = ( TYPE, " ", IDENTIFIER, "=", EXPRESSION ) |
( TYPE, " ", IDENTIFIER );
ASSIGNMENT = IDENTIFIER, "=", EXPRESSION ;
PRINT = "println", "(", EXPRESSION, ")" ;
WHILE = "while", "(", OREXPR, ")", COMMAND;
IF = "if", "(", OREXPR, ")", COMMAND |
"if", "(", OREXPR, ")", COMMAND, "else", COMMAND;
OREXPR = ANDEXPR, {"||", ANDEXPR};
ANDEXPR = EQEXPR, {"&&", EQEXPR};
EQEXPR = RELEXPR, {"==", RELEXPR};
RELEXPR = EXPRESSION, {(">" | "<"), EXPRESSION};
EXPRESSION = TERM, { ("+" | "-"), TERM } ;
TERM = FACTOR, { ("*" | "/"), FACTOR } ;
FACTOR = (("+" | "-"), FACTOR) | NUMBER | BOOL_VALUE | STRING_VALUE | "(", EXPRESSION, ")" | IDENTIFIER ;
TYPE = INT | BOOL | STRING;
INT = "int";
BOOL = "bool";
STRING = "string";
IDENTIFIER = LETTER, { LETTER | DIGIT | "_" } ;
NUMBER = DIGIT, { DIGIT } ;
BOOL_VALUE = "true" | "false" ;
STRING_VALUE = '"', ( LETTER | NUMBER ), {( LETTER | NUMBER )}, '"';
LETTER = ( a | ... | z | A | ... | Z ) ;
DIGIT = ( 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 ) ;