Skip to content

Commit 70b0637

Browse files
committed
fix: Correctly inherit vtypes to all symbols
The function `inherit_vtypes` was defined but never called.
1 parent 4eb1e9b commit 70b0637

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ $ make install
137137
Alternatively, the dev-toolchain can be used, by just calling on any recent Linux system.
138138

139139
```bash
140+
$ touch src/parse.? # you have to do this only once
140141
$ make -f Makefile.gnu
141142
```
142143

src/main.c

+1
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ int main( int argc, char** argv )
285285
if( parser->p_mode == MODE_SCANNERLESS )
286286
rewrite_grammar( parser );
287287

288+
inherit_vtypes( parser );
288289
unique_charsets( parser );
289290
symbol_orders( parser );
290291
charsets_to_ptn( parser );

src/rewrite.c

+13-4
Original file line numberDiff line numberDiff line change
@@ -509,14 +509,23 @@ void inherit_vtypes( PARSER* parser )
509509
{
510510
SYMBOL* sym;
511511
plistel* e;
512+
pboolean changes;
512513

513-
plist_for( parser->symbols, e )
514+
do
514515
{
515-
sym = (SYMBOL*)plist_access( e );
516+
changes = FALSE;
517+
plist_for( parser->symbols, e )
518+
{
519+
sym = (SYMBOL*)plist_access( e );
516520

517-
if( !sym->vtype && sym->derived_from )
518-
sym->vtype = sym->derived_from->vtype;
521+
if( !sym->vtype && sym->derived_from )
522+
{
523+
sym->vtype = sym->derived_from->vtype;
524+
changes = TRUE;
525+
}
526+
}
519527
}
528+
while( changes );
520529
}
521530

522531
/** Sets up a single goal symbol, if necessary. */

src/virtual.c

-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ SYMBOL* positive_closure( PARSER* parser, SYMBOL* base )
3131
s->generated = TRUE;
3232
s->used = TRUE;
3333
s->defined = TRUE;
34-
s->vtype = base->vtype;
3534
s->derived_from = base;
3635
s->line = base->line;
3736

@@ -94,7 +93,6 @@ SYMBOL* kleene_closure( PARSER* parser, SYMBOL* base )
9493
s->generated = TRUE;
9594
s->used = TRUE;
9695
s->defined = TRUE;
97-
s->vtype = base->vtype;
9896
s->derived_from = base;
9997
s->line = base->line;
10098

@@ -142,7 +140,6 @@ SYMBOL* optional_closure( PARSER* parser, SYMBOL* base )
142140
s->generated = TRUE;
143141
s->used = TRUE;
144142
s->defined = TRUE;
145-
s->vtype = base->vtype;
146143
s->derived_from = base;
147144
s->line = base->line;
148145

0 commit comments

Comments
 (0)