[poincare] Prevent parsing of too long symbol/function names

This prevents the user from doing "3->tooLongFunctionName(x)"
This commit is contained in:
Léa Saviot
2018-10-23 14:16:38 +02:00
committed by Émilie Feral
parent ebb9b040a0
commit 2c3a0ca558

View File

@@ -115,10 +115,13 @@ number : DIGITS { $$ = $1; }
| DIGITS DIGITS { YYERROR; }
;
func : SYMBOL LEFT_PARENTHESIS lstData RIGHT_PARENTHESIS %prec SYMBOL_TO_FUNCTION { if ($3.numberOfChildren() != 1) { YYERROR; } ; $$ = Function(static_cast<Symbol&>($1).name(), $3.childAtIndex(0)); }
short_symb : SYMBOL { if (strlen(static_cast<Symbol&>($1).name()) +1 > SymbolAbstract::k_maxNameSize) { YYERROR; } ; $$ = $1; }
;
func : short_symb LEFT_PARENTHESIS lstData RIGHT_PARENTHESIS %prec SYMBOL_TO_FUNCTION { if ($3.numberOfChildren() != 1) { YYERROR; } ; $$ = Function(static_cast<Symbol&>($1).name(), $3.childAtIndex(0)); }
;
symb : SYMBOL { $$ = $1; }
symb : short_symb { $$ = $1; }
;
term : TERM { $$ = $1; }