diff options
Diffstat (limited to 'src/grecs-gram.y')
-rw-r--r-- | src/grecs-gram.y | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/grecs-gram.y b/src/grecs-gram.y index bbe3d5e..92de6b2 100644 --- a/src/grecs-gram.y +++ b/src/grecs-gram.y @@ -19,6 +19,7 @@ # include <config.h> #endif #include <grecs.h> +#include <grecs-locus.h> #include <grecs-gram.h> #include <stdlib.h> #include <stdarg.h> @@ -31,11 +32,10 @@ int yyerror(char *s); static struct grecs_node *parse_tree; %} +%error-verbose +%locations + %union { - struct { - grecs_locus_t locus; - char *string; - } ident; char *string; grecs_value_t svalue, *pvalue; struct grecs_list *list; @@ -44,8 +44,7 @@ static struct grecs_node *parse_tree; struct { struct grecs_node *head, *tail; } node_list; } -%token <ident> IDENT -%token <string> STRING QSTRING MSTRING +%token <string> STRING QSTRING MSTRING IDENT %type <string> string slist %type <list> slist0 %type <svalue> value @@ -58,8 +57,7 @@ static struct grecs_node *parse_tree; input : maybe_stmtlist { - parse_tree = grecs_node_create(grecs_node_root, - &grecs_current_locus); + parse_tree = grecs_node_create(grecs_node_root, &@1); parse_tree->v.texttab = grecs_text_table(); grecs_node_bind(parse_tree, $1, 1); } @@ -92,25 +90,27 @@ stmt : simple simple : IDENT vallist ';' { - $$ = grecs_node_create(grecs_node_stmt, - &$1.locus); - $$->ident = $1.string; + $$ = grecs_node_create_points(grecs_node_stmt, + @1.beg, @2.end); + $$->ident = $1; + $$->idloc = @1; $$->v.value = $2; } | IDENT ';' { - $$ = grecs_node_create(grecs_node_stmt, - &$1.locus); - $$->ident = $1.string; + $$ = grecs_node_create(grecs_node_stmt, &@1); + $$->ident = $1; + $$->idloc = @1; $$->v.value = NULL; } ; block : IDENT tag '{' stmtlist '}' opt_sc { - $$ = grecs_node_create(grecs_node_block, - &$1.locus); - $$->ident = $1.string; + $$ = grecs_node_create_points(grecs_node_block, + @1.beg, @5.end); + $$->ident = $1; + $$->idloc = @1; $$->v.value = $2; grecs_node_bind($$, $4.head, 1); } @@ -135,6 +135,7 @@ vallist : vlist $$ = grecs_malloc(sizeof($$[0])); $$->type = GRECS_TYPE_ARRAY; + $$->locus = @1; $$->v.arg.c = n; $$->v.arg.v = grecs_calloc(n, sizeof($$->v.arg.v[0])); @@ -160,25 +161,25 @@ vlist : value value : string { $$.type = GRECS_TYPE_STRING; + $$.locus = @1; $$.v.string = $1; } | list { $$.type = GRECS_TYPE_LIST; + $$.locus = @1; $$.v.list = $1; } | MSTRING { $$.type = GRECS_TYPE_STRING; + $$.locus = @1; $$.v.string = $1; } ; string : STRING | IDENT - { - $$ = $1.string; - } | slist ; @@ -244,7 +245,7 @@ opt_sc : /* empty */ int yyerror(char *s) { - grecs_error(&grecs_current_locus, 0, "%s", s); + grecs_error(&yylloc, 0, "%s", s); return 0; } |