From 8a12a62c211446b18639e19435524e7ef03e496d Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sat, 31 May 2014 20:12:20 +1000 Subject: [PATCH] parsergen: make sure result in start symbol is returned. Because we synthesize production-zero, we need to make sure to add the relevant 'code' to it to preserve the returned value. Signed-off-by: NeilBrown --- csrc/parsergen.mdc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/csrc/parsergen.mdc b/csrc/parsergen.mdc index 8e088b5..f8d8a39 100644 --- a/csrc/parsergen.mdc +++ b/csrc/parsergen.mdc @@ -540,8 +540,13 @@ where `START` is the first non-terminal given. struct production *p = calloc(1,sizeof(*p)); struct text start = {"$start",6}; struct text eof = {"$eof",4}; + struct text code = {"$0 = $<1;", 9}; p->head = sym_find(g, start); p->head->type = Nonterminal; + p->head->struct_name = g->current_type; + p->head->isref = g->type_isref; + if (g->current_type.txt) + p->code = code; array_add(&p->body, &p->body_size, head); array_add(&p->body, &p->body_size, sym_find(g, eof)); p->head->first_production = g->production_count; -- 2.43.0