Fix bug
This commit is contained in:
parent
b01b910188
commit
22a31f7637
|
@ -1,3 +1,2 @@
|
||||||
fun f = f(3) * x * 4 + 3;
|
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(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())
|
|
|
@ -14,21 +14,21 @@
|
||||||
%option yylineno
|
%option yylineno
|
||||||
|
|
||||||
/* Patrones reutilizables. */
|
/* Patrones reutilizables. */
|
||||||
crlf \r\n
|
crlf \r\n
|
||||||
digit [0-9]
|
digit [0-9]
|
||||||
char [a-zA-Z]
|
char [a-zA-Z]
|
||||||
characters [a-zA-Z., ]
|
characters [a-zA-Z., ]
|
||||||
decimal [.]
|
decimal [.]
|
||||||
endline \n
|
endline \n
|
||||||
whitespace [ \f\n\r\t\v]
|
whitespace [ \f\n\r\t\v]
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
"+" { return ADD; }
|
"+" { return ADD; }
|
||||||
"-" { return SUB; }
|
"-" { return SUB; }
|
||||||
"*" { return MUL; }
|
"*" { return MUL; }
|
||||||
"/" { return DIV; }
|
"/" { return DIV; }
|
||||||
"^" { return POW; }
|
"^" { return POW; }
|
||||||
"fun" { return FUNCTION; }
|
"fun" { return FUNCTION; }
|
||||||
"function" { return FUNCTION; }
|
"function" { return FUNCTION; }
|
||||||
"if" { return IF; }
|
"if" { return IF; }
|
||||||
|
@ -59,8 +59,8 @@ whitespace [ \f\n\r\t\v]
|
||||||
"}" { return CLOSE_BRACES; }
|
"}" { return CLOSE_BRACES; }
|
||||||
"[" { return OPEN_BRACKETS; }
|
"[" { return OPEN_BRACKETS; }
|
||||||
"]" { return CLOSE_BRACKETS; }
|
"]" { return CLOSE_BRACKETS; }
|
||||||
"(" { return OPEN_PARENTHESIS; }
|
"(" { return OPEN_PARENTHESIS; }
|
||||||
")" { return CLOSE_PARENTHESIS; }
|
")" { return CLOSE_PARENTHESIS; }
|
||||||
"=" { return ASSIGN; }
|
"=" { return ASSIGN; }
|
||||||
"==" { return EQUAL; }
|
"==" { return EQUAL; }
|
||||||
"&&" { return AND; }
|
"&&" { return AND; }
|
||||||
|
@ -81,14 +81,14 @@ whitespace [ \f\n\r\t\v]
|
||||||
|
|
||||||
{digit}+{decimal}{digit}+ { return DoublePatternAction(yytext); }
|
{digit}+{decimal}{digit}+ { return DoublePatternAction(yytext); }
|
||||||
|
|
||||||
{digit}+ { return IntegerPatternAction(yytext); }
|
{digit}+ { return IntegerPatternAction(yytext); }
|
||||||
|
|
||||||
{char}+ { return StringPatternAction(yytext); }
|
{char}+ { return StringPatternAction(yytext); }
|
||||||
|
|
||||||
\"{characters}+\" { return EscapeStringPatternAction(yytext); }
|
\"{characters}+\" { return EscapeStringPatternAction(yytext); }
|
||||||
|
|
||||||
{whitespace} { IgnoredPatternAction(yytext); }
|
{whitespace} { IgnoredPatternAction(yytext); }
|
||||||
|
|
||||||
. { return UnknownPatternAction(yytext); }
|
. { return UnknownPatternAction(yytext); }
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
|
@ -68,7 +68,7 @@
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
program: statements { $$ = ProgramGrammarAction($1); }
|
program: statements { $$ = ProgramGrammarAction($1); }
|
||||||
;
|
;
|
||||||
|
|
||||||
statement: evaluate SEMICOLON
|
statement: evaluate SEMICOLON
|
||||||
|
@ -86,7 +86,7 @@ statement: evaluate SEMICOLON
|
||||||
;
|
;
|
||||||
|
|
||||||
expression: positive_constant
|
expression: positive_constant
|
||||||
| evaluate
|
| evaluate
|
||||||
| integrate
|
| integrate
|
||||||
| derivative
|
| derivative
|
||||||
| STRING
|
| STRING
|
||||||
|
|
Loading…
Reference in New Issue