travis trusty
[m6w6/ext-psi] / src / parser_proc.y
index 0d0aa61ceb99a33824033d2b030a3400595b2348..5813b42912815c963d9c1496b553952f7b17a3a7 100644 (file)
 
 #include "parser.h"
 }
-%include { void psi_error(int, const char *, int, const char *, ...); }
 %name psi_parser_proc_
 %token_prefix PSI_T_
 %token_type {struct psi_token *}
 %token_destructor {free($$);}
 %default_destructor {(void)P;}
 %extra_argument {struct psi_parser *P}
-%syntax_error { ++P->errors; if (TOKEN && TOKEN->type != PSI_T_EOF) { psi_error(PSI_WARNING, TOKEN->file, TOKEN->line, "PSI syntax error: Unexpected token '%s'", TOKEN->text); } else { psi_error(PSI_WARNING, P->psi.file.fn, P->line, "PSI syntax error: Unexpected end of input"); } }
+%syntax_error { ++P->errors; if (TOKEN && TOKEN->type != PSI_T_EOF) { psi_error(PSI_WARNING, TOKEN->file, TOKEN->line, "PSI syntax error: Unexpected token '%s' at pos %u", TOKEN->text, TOKEN->col); } else { psi_error(PSI_WARNING, P->psi.file.fn, P->line, "PSI syntax error: Unexpected end of input"); } }
 %nonassoc NAME.
 %left PLUS MINUS.
 %left SLASH ASTERISK.
 %destructor callback_args {free_set_values($$);}
 %type let_val {let_val*}
 %destructor let_val {free_let_val($$);}
+%type let_vals {let_vals*}
+%destructor let_vals {free_let_vals($$);}
 %type set_stmt {set_stmt*}
 %destructor set_stmt {free_set_stmt($$);}
 %type set_value {set_value*}
@@ -668,6 +669,17 @@ let_func(func) ::= let_func_token(T) LPAREN impl_var(var) RPAREN. {
  func = init_let_func(T->type, T->text, var);
  free(T);
 }
+let_vals(vals) ::= let_val(val). {
+ vals = init_let_vals(val);
+}
+let_vals(vals) ::= let_vals(vals_) COMMA let_val(val). {
+ vals = add_let_val(vals_, val);
+}
+let_func(func) ::= let_func_token(T) LPAREN impl_var(var) COMMA let_vals(vals) RPAREN. {
+ func = init_let_func(T->type, T->text, var);
+ func->inner = vals;
+ free(T);
+}
 callback_arg_list ::= .
 callback_arg_list(args) ::= callback_args(args_). {
  args = args_;
@@ -678,6 +690,12 @@ callback_args(args) ::= set_value(val). {
 callback_args(args) ::= callback_args(args_) COMMA set_value(val). {
  args = add_set_value(args_, val);
 }
+callback_rval(rval) ::= let_func_token(F). {
+ rval = F;
+}
+callback_rval(rval) ::= VOID(V). {
+ rval = V;
+}
 let_val(val) ::= NULL. {
  val = init_let_val(PSI_LET_NULL, NULL);
 }
@@ -687,10 +705,10 @@ let_val(val) ::= num_exp(exp). {
 let_val(val) ::= CALLOC LPAREN let_calloc(alloc) RPAREN. {
  val = init_let_val(PSI_LET_CALLOC, alloc);
 }
-let_val(val) ::= let_func(func). {
- val = init_let_val(PSI_LET_FUNC, func);
+let_val(val) ::= let_func(func_). {
+ val = init_let_val(PSI_LET_FUNC, func_);
 }
-let_val(val) ::= CALLBACK let_func_token(F) LPAREN impl_var(var) LPAREN callback_arg_list(args_) RPAREN RPAREN. {
+let_val(val) ::= CALLBACK callback_rval(F) LPAREN impl_var(var) LPAREN callback_arg_list(args_) RPAREN RPAREN. {
  val = init_let_val(PSI_LET_CALLBACK, init_let_callback(
   init_let_func(F->type, F->text, var), args_));
  free(F);