Skip to content

Commit

Permalink
fix: Correctly inherit vtypes to all symbols
Browse files Browse the repository at this point in the history
The function `inherit_vtypes` was defined but never called.
  • Loading branch information
phorward committed Jan 23, 2024
1 parent 4eb1e9b commit b4b00d8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
17 changes: 13 additions & 4 deletions src/rewrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
3 changes: 0 additions & 3 deletions src/virtual.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit b4b00d8

Please sign in to comment.