summaryrefslogtreecommitdiffabout
path: root/src/meta1-gram.y
authorSergey Poznyakoff <gray@gnu.org.ua>2011-05-28 10:22:23 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2011-05-28 10:23:43 (GMT)
commita8e67c64aa6932f11fb81d5c3dd7ae613721edb8 (patch) (side-by-side diff)
tree6fcdb1101560ef8f612f64764294d5e0a5a2522e /src/meta1-gram.y
parent8893389e6bbd27b03d77b7ffa63061e543e8df09 (diff)
downloadgrecs-a8e67c64aa6932f11fb81d5c3dd7ae613721edb8.tar.gz
grecs-a8e67c64aa6932f11fb81d5c3dd7ae613721edb8.tar.bz2
Accept empty input files.
* src/bind-gram.y: Input may be empty. * src/grecs-gram.y: Likewise. * src/meta1-gram.y: Likewise. * tests/empty.at: New test. * tests/Makefile.am: Add new testcase. * tests/testsuite.at: Add new testcase.
Diffstat (limited to 'src/meta1-gram.y') (more/less context) (ignore whitespace changes)
-rw-r--r--src/meta1-gram.y17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/meta1-gram.y b/src/meta1-gram.y
index 2983221..455c362 100644
--- a/src/meta1-gram.y
+++ b/src/meta1-gram.y
@@ -43,7 +43,7 @@ extern int yy_flex_debug;
%token <ident> META1_IDENT
%token <string> META1_STRING
-%type <node> stmt simple block
+%type <node> stmt simple block maybe_stmtlist
%type <node_list> stmtlist
%type <pvalue> tag value
%type <string> string slist
@@ -51,12 +51,23 @@ extern int yy_flex_debug;
%type <list> values list
%%
-input : stmtlist
+input : maybe_stmtlist
{
parse_tree = grecs_node_create(grecs_node_root,
&grecs_current_locus);
parse_tree->v.texttab = grecs_text_table();
- grecs_node_bind(parse_tree, $1.head, 1);
+ grecs_node_bind(parse_tree, $1, 1);
+ }
+ ;
+
+maybe_stmtlist:
+ /* empty */
+ {
+ $$ = NULL;
+ }
+ | stmtlist
+ {
+ $$ = $1.head;
}
;

Return to:

Send suggestions and report system problems to the System administrator.