From b4b00d8a9d3159c5945acc65e2cd6b3eb1b3ec85 Mon Sep 17 00:00:00 2001 From: Jan Max Meyer Date: Tue, 23 Jan 2024 19:12:59 +0100 Subject: [PATCH] fix: Correctly inherit vtypes to all symbols The function `inherit_vtypes` was defined but never called. --- README.md | 1 + src/main.c | 1 + src/rewrite.c | 17 +++++++++++++---- src/virtual.c | 3 --- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7383f7a..9fb3bef 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,7 @@ $ make install Alternatively, the dev-toolchain can be used, by just calling on any recent Linux system. ```bash +$ touch src/parse.? # you have to do this only once $ make -f Makefile.gnu ``` diff --git a/src/main.c b/src/main.c index b4bb36e..23cef2b 100644 --- a/src/main.c +++ b/src/main.c @@ -285,6 +285,7 @@ int main( int argc, char** argv ) if( parser->p_mode == MODE_SCANNERLESS ) rewrite_grammar( parser ); + inherit_vtypes( parser ); unique_charsets( parser ); symbol_orders( parser ); charsets_to_ptn( parser ); diff --git a/src/rewrite.c b/src/rewrite.c index b244a2a..de9ff06 100644 --- a/src/rewrite.c +++ b/src/rewrite.c @@ -509,14 +509,23 @@ void inherit_vtypes( PARSER* parser ) { SYMBOL* sym; plistel* e; + pboolean changes; - plist_for( parser->symbols, e ) + do { - sym = (SYMBOL*)plist_access( e ); + changes = FALSE; + plist_for( parser->symbols, e ) + { + sym = (SYMBOL*)plist_access( e ); - if( !sym->vtype && sym->derived_from ) - sym->vtype = sym->derived_from->vtype; + if( !sym->vtype && sym->derived_from && sym->derived_from->vtype ) + { + sym->vtype = sym->derived_from->vtype; + changes = TRUE; + } + } } + while( changes ); } /** Sets up a single goal symbol, if necessary. */ diff --git a/src/virtual.c b/src/virtual.c index 5e86ac9..cae0d49 100644 --- a/src/virtual.c +++ b/src/virtual.c @@ -31,7 +31,6 @@ SYMBOL* positive_closure( PARSER* parser, SYMBOL* base ) s->generated = TRUE; s->used = TRUE; s->defined = TRUE; - s->vtype = base->vtype; s->derived_from = base; s->line = base->line; @@ -94,7 +93,6 @@ SYMBOL* kleene_closure( PARSER* parser, SYMBOL* base ) s->generated = TRUE; s->used = TRUE; s->defined = TRUE; - s->vtype = base->vtype; s->derived_from = base; s->line = base->line; @@ -142,7 +140,6 @@ SYMBOL* optional_closure( PARSER* parser, SYMBOL* base ) s->generated = TRUE; s->used = TRUE; s->defined = TRUE; - s->vtype = base->vtype; s->derived_from = base; s->line = base->line;