diff options
author | Adrian Thurston <thurston@complang.org> | 2015-01-02 12:46:36 -0500 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2015-01-02 12:46:36 -0500 |
commit | c8bf7e7cba2b61c0b87d0192ae5a5d3868b6d857 (patch) | |
tree | 8f83d7a2474c348db8161b29df044c355c47eefa /src/struct.c | |
parent | 0b223651fcb525374e87935c2de894b7849903c2 (diff) | |
download | colm-c8bf7e7cba2b61c0b87d0192ae5a5d3868b6d857.tar.gz |
make stream and parser overlay struct
Diffstat (limited to 'src/struct.c')
-rw-r--r-- | src/struct.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/struct.c b/src/struct.c index 3e1b6394..f17ce779 100644 --- a/src/struct.c +++ b/src/struct.c @@ -65,3 +65,30 @@ void colm_struct_delete( Program *prg, Tree **sp, struct colm_struct *el ) } free( el ); } + +void colm_parser_destroy( Program *prg, Tree **sp, struct colm_struct *parser ) +{ + /* Free the PDA run. */ + PdaRun *pdaRun = colm_struct_get_field_type( parser, PdaRun *, 6 ); + clearPdaRun( prg, sp, pdaRun ); + free( pdaRun ); + + /* Free the result. */ + Tree *result = colm_struct_get_field_type( parser, Tree *, 8 ); + treeDownref( prg, sp, result ); +} + +Parser *colm_parser_new( Program *prg, GenericInfo *gi ) +{ + PdaRun *pdaRun = malloc( sizeof(PdaRun) ); + + /* Start off the parsing process. */ + colm_pda_init( prg, pdaRun, prg->rtd->pdaTables, + gi->parserId, 0, 0, 0 ); + + struct colm_struct *s = colm_struct_inbuilt( prg, 16, colm_parser_destroy ); + colm_struct_set_field_type( s, PdaRun*, 6, pdaRun ); + + return (Parser*) s; +} + |