diff options
author | Adrian Thurston <thurston@complang.org> | 2008-11-21 16:30:30 +0000 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2008-11-21 16:30:30 +0000 |
commit | 478bc4d7e154e06269d33576432d9e49151131ee (patch) | |
tree | 628183be5d5ed381054cabbf081cec5c33327e02 | |
parent | fa33e4c69e6ef97dfc935d2e407054736ae6b292 (diff) | |
download | colm-478bc4d7e154e06269d33576432d9e49151131ee.tar.gz |
Start on the movement of algorithm data back to the tree structure. Use a flag
to indicate that a tree came out of the parser. We can no longer rely on the
alg pointer being set to determine this.
-rw-r--r-- | colm/bytecode.cpp | 11 | ||||
-rw-r--r-- | colm/bytecode.h | 4 | ||||
-rw-r--r-- | colm/pdarun.h | 8 |
3 files changed, 19 insertions, 4 deletions
diff --git a/colm/bytecode.cpp b/colm/bytecode.cpp index 2d32dac4..0e05ea97 100644 --- a/colm/bytecode.cpp +++ b/colm/bytecode.cpp @@ -81,10 +81,10 @@ using std::endl; void send( Tree **root, Program *prg, PdaRun *parser, Tree *tree, bool ignore ) { - /* If the tree already has an alg (it has been parsed) then we need to - * send a copy of it because the parsing that we are about to do requires - * a fresh alg. */ - if ( tree->alg != 0 ) { + /* If the tree was produced by a parsing function then we need to send a + * copy of it because the parsing that we are about to do requires fresh + * parsing algorithm data. */ + if ( tree->flags & AF_PARSED ) { #ifdef COLM_LOG_BYTECODE cerr << "copying tree in send because alg is set" << endl; #endif @@ -134,6 +134,9 @@ Tree *call_parser( Tree **&sp, Program *prg, Stream *stream, cv = 0; } + /* Indicate that this tree came out of a parser. */ + tree->flags |= AF_PARSED; + return tree; } diff --git a/colm/bytecode.h b/colm/bytecode.h index 9b9c5d5b..0fe40921 100644 --- a/colm/bytecode.h +++ b/colm/bytecode.h @@ -270,6 +270,10 @@ typedef unsigned char uchar; /* There is reverse code associated with this tree node. */ #define AF_HAS_RCODE 0x20 +/* Tree was produced by a parse routine. This means the data fields for + * managing parsing fields will be active. */ +#define AF_PARSED 0x40 + /* * Call stack. */ diff --git a/colm/pdarun.h b/colm/pdarun.h index fb769c9c..27d15a4a 100644 --- a/colm/pdarun.h +++ b/colm/pdarun.h @@ -73,7 +73,15 @@ struct Tree Kid *child; Head *tokdata; + Alg *alg; + + /* Parsing algorithm. */ + long state; + long region; + char causeReduce; + char retry_lower; + char retry_upper; }; struct Int |