yylval->literal = jv_parse_sized(yytext, yyleng); return LITERAL;
}
+\"(\\.|[^\\\"])* {
+ yylval->literal = jv_invalid_with_msg(jv_string("Unterminated string"));
+ return LITERAL;
+}
+
+
[[:alnum:]]+ { yylval->literal = jv_string(yytext); return IDENT;}
[ \n\t]+ {}
#include <string.h>
#include "compile.h"
%}
-
%code requires {
#include "locfile.h"
#define YYLTYPE location
"if" Exp "then" Exp ElseBody {
$$ = gen_cond($2, $4, $5);
} |
+"if" Exp error {
+ FAIL(@$, "Possibly unterminated 'if' statment");
+ $$ = $2;
+} |
Exp '=' Exp {
block assign = gen_op_simple(DUP);
$$ = gen_and($1, $3);
} |
-
"not" Exp {
$$ = gen_not($2);
} |
$$ = $1;
}
+
+
ElseBody:
"elif" Exp "then" Exp ElseBody {
$$ = gen_cond($2, $4, $5);
block_join($3, gen_op_simple(RET))),
gen_noop(), OP_IS_CALL_PSEUDO)));
jv_free($1);
-}
+} |
+'(' error ')' { $$ = gen_noop(); } |
+'[' error ']' { $$ = gen_noop(); } |
+Term '[' error ']' { $$ = $1; } |
+'{' error '}' { $$ = gen_noop(); }
MkDict:
{
$$=gen_noop();
-}
-|
-MkDictPair
-{ $$ = $1; }
+} |
+ MkDictPair { $$ = $1; }
| MkDictPair ',' MkDict { $$=block_join($1, $3); }
+| error ',' MkDict { $$ = $3; }
MkDictPair
: IDENT ':' ExpD {
| '(' Exp ')' ':' ExpD {
$$ = gen_dictpair($2, $5);
}
+| '(' error ')' ':' ExpD { $$ = $5; }
%%
int compile(const char* str, block* answer) {