Fix warnings
Co-authored-by: Ezequiel Bellver <ebellver@itba.edu.ar> Co-authored-by: Juan Barmasch <jbarmasch@itba.edu.ar>
This commit is contained in:
parent
af3d848aec
commit
01d08db37b
|
@ -7,7 +7,9 @@ project(Compiler C)
|
|||
# Compilar el parser con Bison:
|
||||
add_custom_command(
|
||||
OUTPUT ../src/frontend/syntactic-analysis/bison-parser.c ../src/frontend/syntactic-analysis/bison-parser.h
|
||||
COMMAND bison -t -d ../src/frontend/syntactic-analysis/bison-grammar.y -o ../src/frontend/syntactic-analysis/bison-parser.c)
|
||||
COMMAND bison -d ../src/frontend/syntactic-analysis/bison-grammar.y -o ../src/frontend/syntactic-analysis/bison-parser.c)
|
||||
# COMMAND bison -Wcounterexamples -d ../src/frontend/syntactic-analysis/bison-grammar.y -o ../src/frontend/syntactic-analysis/bison-parser.c)
|
||||
# COMMAND bison -t -d ../src/frontend/syntactic-analysis/bison-grammar.y -o ../src/frontend/syntactic-analysis/bison-parser.c)
|
||||
|
||||
# Seleccionar estrategia según el compilador de C disponible en el sistema:
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
|
@ -21,8 +23,9 @@ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
|||
# Compilar el scanner con Flex:
|
||||
add_custom_command(
|
||||
OUTPUT ../src/frontend/lexical-analysis/flex-scanner.c
|
||||
COMMAND flex --debug -o ../src/frontend/lexical-analysis/flex-scanner.c ../src/frontend/lexical-analysis/flex-patterns.l
|
||||
COMMAND flex -o ../src/frontend/lexical-analysis/flex-scanner.c ../src/frontend/lexical-analysis/flex-patterns.l
|
||||
DEPENDS ../src/frontend/syntactic-analysis/bison-parser.c ../src/frontend/syntactic-analysis/bison-parser.h)
|
||||
# COMMAND flex --debug -o ../src/frontend/lexical-analysis/flex-scanner.c ../src/frontend/lexical-analysis/flex-patterns.l
|
||||
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "MSVC")
|
||||
message(NOTICE "El compilador de C es Microsoft Visual Studio.")
|
||||
|
|
|
@ -7,29 +7,29 @@
|
|||
*/
|
||||
|
||||
TokenID IntegerPatternAction(const char * lexeme) {
|
||||
LogDebug("IntegerPatternAction: '%s'.", lexeme);
|
||||
// LogDebug("IntegerPatternAction: '%s'.", lexeme);
|
||||
yylval = atoi(lexeme);
|
||||
return INTEGER;
|
||||
}
|
||||
|
||||
TokenID DoublePatternAction(const char * lexeme) {
|
||||
LogDebug("DoublePatternAction: '%s'.", lexeme);
|
||||
// LogDebug("DoublePatternAction: '%s'.", lexeme);
|
||||
yylval = atof(lexeme);
|
||||
return DOUBLE;
|
||||
}
|
||||
|
||||
TokenID StringPatternAction(const char * lexeme) {
|
||||
LogDebug("StringPatternAction: '%s'.", lexeme);
|
||||
// LogDebug("StringPatternAction: '%s'.", lexeme);
|
||||
return STRING;
|
||||
}
|
||||
|
||||
TokenID EscapeStringPatternAction(const char * lexeme) {
|
||||
LogDebug("EscapeStringPatternAction: '%s'.", lexeme);
|
||||
// LogDebug("EscapeStringPatternAction: '%s'.", lexeme);
|
||||
return ESCAPESTRING;
|
||||
}
|
||||
|
||||
void IgnoredPatternAction(const char * lexeme) {
|
||||
LogDebug("IgnoredPatternAction: '%s'.", lexeme);
|
||||
// LogDebug("IgnoredPatternAction: '%s'.", lexeme);
|
||||
}
|
||||
|
||||
TokenID UnknownPatternAction(const char * lexeme) {
|
||||
|
|
|
@ -20,7 +20,7 @@ void yyerror(const char * string) {
|
|||
}
|
||||
|
||||
int ProgramGrammarAction(const int value) {
|
||||
LogDebug("ProgramGrammarAction(%d)", value);
|
||||
// LogDebug("ProgramGrammarAction(%d)", value);
|
||||
state.succeed = true;
|
||||
state.result = value;
|
||||
return value;
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
|
||||
%%
|
||||
|
||||
program: statements
|
||||
program: statements { $$ = ProgramGrammarAction($1); }
|
||||
;
|
||||
|
||||
expression: constant
|
||||
|
@ -239,7 +239,7 @@ while_statement: WHILE OPEN_PARENTHESIS boolean CLOSE_PARENTHESIS OPEN_BRACKETS
|
|||
;
|
||||
|
||||
declare_variable: VAR STRING
|
||||
| VAR STRING ASSIGN expression
|
||||
| declare_variable ASSIGN expression
|
||||
;
|
||||
|
||||
printCSV: PRINTCSV OPEN_PARENTHESIS escapeStringArray COMMA arrayNumArray COMMA escapeString CLOSE_PARENTHESIS
|
||||
|
@ -258,8 +258,7 @@ number: constant
|
|||
| OPEN_PARENTHESIS number CLOSE_PARENTHESIS
|
||||
;
|
||||
|
||||
assign_variable: STRING ASSIGN number
|
||||
| STRING ADD_ASSIGN number
|
||||
assign_variable: STRING ADD_ASSIGN number
|
||||
| STRING SUB_ASSIGN number
|
||||
| STRING MUL_ASSIGN number
|
||||
| STRING DIV_ASSIGN number
|
||||
|
|
|
@ -10,9 +10,9 @@ CompilerState state;
|
|||
// Punto de entrada principal del compilador.
|
||||
const int main(const int argumentCount, const char ** arguments) {
|
||||
|
||||
#ifdef YYDEBUG
|
||||
yydebug = 1;
|
||||
#endif
|
||||
// #ifdef YYDEBUG
|
||||
// yydebug = 1;
|
||||
// #endif
|
||||
// Inicializar estado de la aplicación.
|
||||
state.result = 0;
|
||||
state.succeed = false;
|
||||
|
@ -29,7 +29,7 @@ const int main(const int argumentCount, const char ** arguments) {
|
|||
case 0:
|
||||
if (state.succeed) {
|
||||
LogInfo("La compilacion fue exitosa.");
|
||||
Generator(state.result);
|
||||
// Generator(state.result);
|
||||
}
|
||||
else {
|
||||
LogError("Se produjo un error en la aplicacion.");
|
||||
|
|
Loading…
Reference in New Issue