From 22a31f7637702e0dc7afb5b22ed731d4a4411b92 Mon Sep 17 00:00:00 2001 From: Santiago Lo Coco Date: Tue, 19 Apr 2022 07:48:03 -0300 Subject: [PATCH] Fix bug --- doc/examples/use-case-8.b | 3 +-- src/frontend/lexical-analysis/flex-patterns.l | 26 +++++++++---------- .../syntactic-analysis/bison-grammar.y | 4 +-- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/doc/examples/use-case-8.b b/doc/examples/use-case-8.b index 5d79582..ee36fd6 100644 --- a/doc/examples/use-case-8.b +++ b/doc/examples/use-case-8.b @@ -1,3 +1,2 @@ fun f = f(3) * x * 4 + 3; -fun g = f(3) + f'(3)*(x-3) + f''(3)/2 * (x-3)^2 + f'''(3) / 6 * (x-3)^3 + f''''(3) / 24 * (x-3)^4; -fun g = f(2) + integrate(derivative()) \ No newline at end of file +fun g = f(3) + f'(3)*(x-3) + f''(3)/2 * (x-3)^2 + f'''(3) / 6 * (x-3)^3 + f''''(3) / 24 * (x-3)^4; \ No newline at end of file diff --git a/src/frontend/lexical-analysis/flex-patterns.l b/src/frontend/lexical-analysis/flex-patterns.l index f5a65cf..a2f9d35 100644 --- a/src/frontend/lexical-analysis/flex-patterns.l +++ b/src/frontend/lexical-analysis/flex-patterns.l @@ -14,21 +14,21 @@ %option yylineno /* Patrones reutilizables. */ -crlf \r\n -digit [0-9] +crlf \r\n +digit [0-9] char [a-zA-Z] characters [a-zA-Z., ] decimal [.] -endline \n +endline \n whitespace [ \f\n\r\t\v] %% -"+" { return ADD; } -"-" { return SUB; } -"*" { return MUL; } -"/" { return DIV; } -"^" { return POW; } +"+" { return ADD; } +"-" { return SUB; } +"*" { return MUL; } +"/" { return DIV; } +"^" { return POW; } "fun" { return FUNCTION; } "function" { return FUNCTION; } "if" { return IF; } @@ -59,8 +59,8 @@ whitespace [ \f\n\r\t\v] "}" { return CLOSE_BRACES; } "[" { return OPEN_BRACKETS; } "]" { return CLOSE_BRACKETS; } -"(" { return OPEN_PARENTHESIS; } -")" { return CLOSE_PARENTHESIS; } +"(" { return OPEN_PARENTHESIS; } +")" { return CLOSE_PARENTHESIS; } "=" { return ASSIGN; } "==" { return EQUAL; } "&&" { return AND; } @@ -81,14 +81,14 @@ whitespace [ \f\n\r\t\v] {digit}+{decimal}{digit}+ { return DoublePatternAction(yytext); } -{digit}+ { return IntegerPatternAction(yytext); } +{digit}+ { return IntegerPatternAction(yytext); } {char}+ { return StringPatternAction(yytext); } \"{characters}+\" { return EscapeStringPatternAction(yytext); } -{whitespace} { IgnoredPatternAction(yytext); } +{whitespace} { IgnoredPatternAction(yytext); } -. { return UnknownPatternAction(yytext); } +. { return UnknownPatternAction(yytext); } %% diff --git a/src/frontend/syntactic-analysis/bison-grammar.y b/src/frontend/syntactic-analysis/bison-grammar.y index 87a5d9d..d36e898 100644 --- a/src/frontend/syntactic-analysis/bison-grammar.y +++ b/src/frontend/syntactic-analysis/bison-grammar.y @@ -68,7 +68,7 @@ %% -program: statements { $$ = ProgramGrammarAction($1); } +program: statements { $$ = ProgramGrammarAction($1); } ; statement: evaluate SEMICOLON @@ -86,7 +86,7 @@ statement: evaluate SEMICOLON ; expression: positive_constant - | evaluate + | evaluate | integrate | derivative | STRING