This commit is contained in:
Santiago Lo Coco 2022-04-19 07:48:03 -03:00
parent b01b910188
commit 22a31f7637
3 changed files with 16 additions and 17 deletions

View File

@ -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())
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;

View File

@ -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); }
%%

View File

@ -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