summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2020-04-14 10:16:51 +0000
committerAdrian Thurston <thurston@colm.net>2020-04-14 10:16:51 +0000
commitd0a2a2ac6cf0b3ff0c070a83e72a301704493796 (patch)
tree13f4a3986f06001210a1f29d2efbbe9beca44751 /src
parenta39d7909d7b542889481e2b3b7c08df16cc42b61 (diff)
downloadcolm-d0a2a2ac6cf0b3ff0c070a83e72a301704493796.tar.gz
correct prodNum as we combine productions to implement [...]
refs #112
Diffstat (limited to 'src')
-rw-r--r--src/declare.cc14
-rw-r--r--src/pdabuild.cc1
-rw-r--r--src/pdacodegen.cc3
3 files changed, 12 insertions, 6 deletions
diff --git a/src/declare.cc b/src/declare.cc
index bc770c9e..5102746c 100644
--- a/src/declare.cc
+++ b/src/declare.cc
@@ -253,8 +253,8 @@ void Compiler::declareReVars()
LangEl *declareLangEl( Compiler *pd, Namespace *nspace,
const String &data, LangEl::Type type )
{
- /* If the id is already in the dict, it will be placed in last found. If
- * it is not there then it will be inserted and last found will be set to it. */
+ /* If the id is already in the dict, it will be placed in last found. If it
+ * is not there then it will be inserted and last found will be set to it. */
TypeMapEl *inDict = nspace->typeMap.find( data );
if ( inDict != 0 )
error() << "language element '" << data << "' already defined as something else" << endp;
@@ -488,10 +488,14 @@ void Namespace::declare( Compiler *pd )
while ( n->prodList->length() > 0 ) {
Production *prod = n->prodList->detachFirst();
if ( prod->dotDotDot ) {
- prod->prodNum = combined.length();
- combined.append( langEl->prodList );
+ while ( langEl->prodList.length() ) {
+ Production *prod = langEl->prodList.detachFirst();
+ prod->prodNum = combined.length();
+ combined.append( prod );
+ }
}
else {
+ prod->prodNum = combined.length();
combined.append( prod );
}
}
@@ -523,7 +527,7 @@ void Namespace::declare( Compiler *pd )
for ( TypeAliasList::Iter ta = typeAliasList; ta.lte(); ta++ )
declareTypeAlias( pd, this, ta->name, ta->typeRef );
- /* Go into child aliases. */
+ /* Go into child namespaces. */
for ( NamespaceVect::Iter c = childNamespaces; c.lte(); c++ )
(*c)->declare( pd );
}
diff --git a/src/pdabuild.cc b/src/pdabuild.cc
index ae2d4e01..60a23c6b 100644
--- a/src/pdabuild.cc
+++ b/src/pdabuild.cc
@@ -1455,6 +1455,7 @@ void Compiler::makeRuntimeData()
for ( int i = 0; i < nextLelId; i++ ) {
LangEl *lel = langElIndex[i];
if ( lel != 0 ) {
+ assert( lel->id == i );
runtimeData->lel_info[i].name = lel->fullLit;
runtimeData->lel_info[i].xml_tag = lel->xmlTag;
runtimeData->lel_info[i].repeat = lel->isRepeat;
diff --git a/src/pdacodegen.cc b/src/pdacodegen.cc
index c96c9afc..44389b6f 100644
--- a/src/pdacodegen.cc
+++ b/src/pdacodegen.cc
@@ -23,6 +23,7 @@
#include <string.h>
#include <iostream>
+#include <iomanip>
#include "compiler.h"
#include "pdacodegen.h"
@@ -165,7 +166,7 @@ void PdaCodeGen::writeRuntimeData( colm_sections *runtimeData, struct pda_tables
out << "static struct lang_el_info " << lelInfo() << "[] = {\n";
for ( int i = 0; i < runtimeData->num_lang_els; i++ ) {
struct lang_el_info *el = &runtimeData->lel_info[i];
- out << "\t{";
+ out << "/* " << std::setw(4) << i << " */ {";
/* Name. */
out << " \"";