summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/colm.lm12
-rw-r--r--src/consinit.cc8
-rw-r--r--src/loadcolm.cc98
-rw-r--r--src/loadinit.cc2
-rw-r--r--src/parser.cc28
-rw-r--r--src/parser.h20
6 files changed, 86 insertions, 82 deletions
diff --git a/src/colm.lm b/src/colm.lm
index 8527cf25..268dd145 100644
--- a/src/colm.lm
+++ b/src/colm.lm
@@ -208,7 +208,7 @@ def root_item
| [ignore_def] :Ignore commit
| [cfl_def] :Cfl commit
| [region_def] :Region commit
-| [context_def] :Context commit
+| [struct_def] :Struct commit
| [namespace_def] :Namespace commit
| [function_def] :Function commit
| [iter_def] :Iter commit
@@ -245,7 +245,7 @@ def pre_eof_def
def alias_def
[ALIAS id type_ref]
-def context_item
+def struct_item
[context_var_def] :ContextVar commit
| [literal_def] :Literal commit
| [rl_def] :Rl commit
@@ -254,7 +254,7 @@ def context_item
| [ignore_def] :Ignore commit
| [cfl_def] :Cfl commit
| [region_def] :Region commit
-| [context_def] :Context commit
+| [struct_def] :Struct commit
| [function_def] :Function commit
| [iter_def] :Iter commit
| [export_def] :Export commit
@@ -297,8 +297,8 @@ def context_var_def
def struct_key
[STRUCT] | [CONTEXT]
-def context_def
- [struct_key id ItemList: context_item* END]
+def struct_def
+ [struct_key id ItemList: struct_item* END]
def literal_def
[LITERAL literal_list]
@@ -329,7 +329,7 @@ def namespace_item
| [ignore_def] :Ignore commit
| [cfl_def] :Cfl commit
| [region_def] :Region commit
-| [context_def] :Context commit
+| [struct_def] :Struct commit
| [namespace_def] :Namespace commit
| [function_def] :Function commit
| [iter_def] :Iter commit
diff --git a/src/consinit.cc b/src/consinit.cc
index b91748d7..af3854f5 100644
--- a/src/consinit.cc
+++ b/src/consinit.cc
@@ -437,7 +437,7 @@ void ConsInit::definition( const String &name, Production *prod1, Production *pr
prodAppend( defList, prod3 );
prodAppend( defList, prod4 );
- NtDef *ntDef = NtDef::cons( name, curNspace(), curContext(), false );
+ NtDef *ntDef = NtDef::cons( name, curNspace(), curStruct(), false );
ObjectDef *objectDef = ObjectDef::cons( ObjectDef::UserType, name, pd->nextObjectId++ );
cflDef( ntDef, objectDef, defList );
}
@@ -449,7 +449,7 @@ void ConsInit::definition( const String &name, Production *prod1, Production *pr
prodAppend( defList, prod2 );
prodAppend( defList, prod3 );
- NtDef *ntDef = NtDef::cons( name, curNspace(), curContext(), false );
+ NtDef *ntDef = NtDef::cons( name, curNspace(), curStruct(), false );
ObjectDef *objectDef = ObjectDef::cons( ObjectDef::UserType, name, pd->nextObjectId++ );
cflDef( ntDef, objectDef, defList );
}
@@ -460,7 +460,7 @@ void ConsInit::definition( const String &name, Production *prod1, Production *pr
prodAppend( defList, prod1 );
prodAppend( defList, prod2 );
- NtDef *ntDef = NtDef::cons( name, curNspace(), curContext(), false );
+ NtDef *ntDef = NtDef::cons( name, curNspace(), curStruct(), false );
ObjectDef *objectDef = ObjectDef::cons( ObjectDef::UserType, name, pd->nextObjectId++ );
cflDef( ntDef, objectDef, defList );
}
@@ -470,7 +470,7 @@ void ConsInit::definition( const String &name, Production *prod )
LelDefList *defList = new LelDefList;
prodAppend( defList, prod );
- NtDef *ntDef = NtDef::cons( name, curNspace(), curContext(), false );
+ NtDef *ntDef = NtDef::cons( name, curNspace(), curStruct(), false );
ObjectDef *objectDef = ObjectDef::cons( ObjectDef::UserType, name, pd->nextObjectId++ );
cflDef( ntDef, objectDef, defList );
}
diff --git a/src/loadcolm.cc b/src/loadcolm.cc
index eb64fc89..1546bdf9 100644
--- a/src/loadcolm.cc
+++ b/src/loadcolm.cc
@@ -430,7 +430,7 @@ struct LoadColm
if ( optLabel.prodName() == opt_label::Id ) {
String id = optLabel.id().data();
varRef = LangVarRef::cons( optLabel.id().loc(),
- curContext(), curScope, id );
+ curStruct(), curScope, id );
}
return varRef;
}
@@ -657,7 +657,7 @@ struct LoadColm
ObjectDef *localFrame = blockOpen();
StmtList *stmtList = walkLangStmtList( optTranslate.lang_stmt_list() );
block = CodeBlock::cons( stmtList, localFrame );
- block->context = curContext();
+ block->context = curStruct();
blockClose();
}
return block;
@@ -930,7 +930,7 @@ struct LoadColm
StmtList *stmtList = walkLangStmtList( OptReduce.lang_stmt_list() );
block = CodeBlock::cons( stmtList, localFrame );
- block->context = curContext();
+ block->context = curStruct();
blockClose();
}
@@ -1171,7 +1171,7 @@ struct LoadColm
bool reduceFirst = cflDef.opt_reduce_first().REDUCEFIRST() != 0;
NtDef *ntDef = NtDef::cons( name, curNspace(),
- curContext(), reduceFirst );
+ curStruct(), reduceFirst );
BaseParser::cflDef( ntDef, objectDef, defList );
}
@@ -1246,7 +1246,7 @@ struct LoadColm
QualItemVect *qualItemVect = walkQual( Qual );
String id = varRef.id().data();
LangVarRef *langVarRef = LangVarRef::cons( varRef.id().loc(),
- curContext(), curScope, qualItemVect, id );
+ curStruct(), curScope, qualItemVect, id );
return langVarRef;
}
@@ -1965,7 +1965,7 @@ struct LoadColm
case iter_call::Id: {
String tree = Tree.id().data();
LangVarRef *varRef = LangVarRef::cons( Tree.id().loc(),
- curContext(), curScope, tree );
+ curStruct(), curScope, tree );
LangTerm *langTerm = LangTerm::cons( Tree.id().loc(),
LangTerm::VarRefType, varRef );
LangExpr *langExpr = LangExpr::cons( langTerm );
@@ -2068,7 +2068,7 @@ struct LoadColm
void walkContextVarDef( context_var_def ContextVarDef )
{
- ObjectDef *contextObj = curContext()->objectDef;
+ ObjectDef *contextObj = curStruct()->objectDef;
ObjectField::Type type = contextObj->type == ObjectDef::StructType ?
ObjectField::StructFieldType : ObjectField::UserFieldType;
@@ -2144,66 +2144,66 @@ struct LoadColm
blockClose();
}
- void walkContextItem( context_item contextItem )
+ void walkContextItem( struct_item structItem )
{
- switch ( contextItem.prodName() ) {
- case context_item::Rl:
- walkRlDef( contextItem.rl_def() );
+ switch ( structItem.prodName() ) {
+ case struct_item::Rl:
+ walkRlDef( structItem.rl_def() );
break;
- case context_item::ContextVar:
- walkContextVarDef( contextItem.context_var_def() );
+ case struct_item::ContextVar:
+ walkContextVarDef( structItem.context_var_def() );
break;
- case context_item::Token:
- walkTokenDef( contextItem.token_def() );
+ case struct_item::Token:
+ walkTokenDef( structItem.token_def() );
break;
- case context_item::IgnoreCollector:
- walkIgnoreCollector( contextItem.ic_def() );
+ case struct_item::IgnoreCollector:
+ walkIgnoreCollector( structItem.ic_def() );
break;
- case context_item::Ignore:
- walkIgnoreDef( contextItem.ignore_def() );
+ case struct_item::Ignore:
+ walkIgnoreDef( structItem.ignore_def() );
break;
- case context_item::Literal:
- walkLiteralDef( contextItem.literal_def() );
+ case struct_item::Literal:
+ walkLiteralDef( structItem.literal_def() );
break;
- case context_item::Cfl:
- walkCflDef( contextItem.cfl_def() );
+ case struct_item::Cfl:
+ walkCflDef( structItem.cfl_def() );
break;
- case context_item::Region:
- walkLexRegion( contextItem.region_def() );
+ case struct_item::Region:
+ walkLexRegion( structItem.region_def() );
break;
- case context_item::Context:
- walkContextDef( contextItem.context_def() );
+ case struct_item::Struct:
+ walkStructDef( structItem.struct_def() );
break;
- case context_item::Function:
- walkFunctionDef( contextItem.function_def() );
+ case struct_item::Function:
+ walkFunctionDef( structItem.function_def() );
break;
- case context_item::Iter:
- walkIterDef( contextItem.iter_def() );
+ case struct_item::Iter:
+ walkIterDef( structItem.iter_def() );
break;
- case context_item::PreEof:
- walkPreEof( contextItem.pre_eof_def() );
+ case struct_item::PreEof:
+ walkPreEof( structItem.pre_eof_def() );
break;
- case context_item::Export:
- walkExportDef( contextItem.export_def() );
+ case struct_item::Export:
+ walkExportDef( structItem.export_def() );
break;
- case context_item::Precedence:
- walkPrecedenceDef( contextItem.precedence_def() );
+ case struct_item::Precedence:
+ walkPrecedenceDef( structItem.precedence_def() );
break;
}
}
- void walkContextDef( context_def contextDef )
+ void walkStructDef( struct_def structDef )
{
- String name = contextDef.id().data();
- structHead( contextDef.id().loc(), name, ObjectDef::StructType );
+ String name = structDef.id().data();
+ structHead( structDef.id().loc(), name, ObjectDef::StructType );
- _repeat_context_item contextItemList = contextDef.ItemList();
- while ( !contextItemList.end() ) {
- walkContextItem( contextItemList.value() );
- contextItemList = contextItemList.next();
+ _repeat_struct_item structItemList = structDef.ItemList();
+ while ( !structItemList.end() ) {
+ walkContextItem( structItemList.value() );
+ structItemList = structItemList.next();
}
- contextStack.pop();
+ structStack.pop();
namespaceStack.pop();
}
@@ -2245,8 +2245,8 @@ struct LoadColm
stmtList->append( stmt );
break;
}
- case root_item::Context:
- walkContextDef( rootItem.context_def() );
+ case root_item::Struct:
+ walkStructDef( rootItem.struct_def() );
break;
case root_item::Namespace:
walkNamespaceDef( rootItem.namespace_def() );
@@ -2309,8 +2309,8 @@ struct LoadColm
case namespace_item::Region:
walkLexRegion( item.region_def() );
break;
- case namespace_item::Context:
- walkContextDef( item.context_def() );
+ case namespace_item::Struct:
+ walkStructDef( item.struct_def() );
break;
case namespace_item::Namespace:
walkNamespaceDef( item.namespace_def() );
diff --git a/src/loadinit.cc b/src/loadinit.cc
index 07b78701..9c0dd06d 100644
--- a/src/loadinit.cc
+++ b/src/loadinit.cc
@@ -254,7 +254,7 @@ void LoadInit::walkDefinition( item &define )
LelDefList *defList = new LelDefList;
walkProdList( name, defList, ProdList );
- NtDef *ntDef = NtDef::cons( name, curNspace(), curContext(), false );
+ NtDef *ntDef = NtDef::cons( name, curNspace(), curStruct(), false );
ObjectDef *objectDef = ObjectDef::cons( ObjectDef::UserType, name, pd->nextObjectId++ );
cflDef( ntDef, objectDef, defList );
}
diff --git a/src/parser.cc b/src/parser.cc
index 95ddbc40..25595f9d 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -184,7 +184,7 @@ void BaseParser::defineToken( const InputLoc &loc, String name, LexJoin *join, O
RegionSet *regionSet = regionStack.top();
TokenDef *tokenDef = TokenDef::cons( name, String(), false, ignore, join,
- transBlock, loc, 0, nspace, regionSet, objectDef, curContext() );
+ transBlock, loc, 0, nspace, regionSet, objectDef, curStruct() );
regionSet->tokenDefList.append( tokenDef );
nspace->tokenDefList.append( tokenDef );
@@ -242,7 +242,7 @@ void BaseParser::zeroDef( const InputLoc &loc, const String &name )
LexJoin *join = literalJoin( loc, String("`") );
TokenDef *tokenDef = TokenDef::cons( name, String(), false, false, join,
- 0, loc, 0, nspace, regionSet, 0, curContext() );
+ 0, loc, 0, nspace, regionSet, 0, curStruct() );
tokenDef->isZero = true;
@@ -343,7 +343,7 @@ void BaseParser::functionDef( StmtList *stmtList, ObjectDef *localFrame,
Function *newFunction = Function::cons( typeRef, name,
paramList, codeBlock, pd->nextFuncId++, false, exprt );
pd->functionList.append( newFunction );
- newFunction->inContext = curContext();
+ newFunction->inContext = curStruct();
}
void BaseParser::iterDef( StmtList *stmtList, ObjectDef *localFrame,
@@ -362,10 +362,10 @@ LangStmt *BaseParser::globalDef( ObjectField *objField, LangExpr *expr,
Context *context = 0;
ObjectDef *object = 0;
- if ( curContext() == 0 )
+ if ( curStruct() == 0 )
object = pd->globalObjectDef;
else {
- context = curContext();
+ context = curStruct();
objField->context = context;
object = context->objectDef;
}
@@ -560,7 +560,7 @@ LangExpr *BaseParser::parseCmd( const InputLoc &loc, bool tree, bool stop,
LangVarRef *varRef = 0;
if ( objField != 0 ) {
varRef = LangVarRef::cons( objField->loc,
- curContext(), curScope, objField->name );
+ curStruct(), curScope, objField->name );
}
/* The typeref for the parser. */
@@ -674,7 +674,7 @@ LangStmt *BaseParser::forScope( const InputLoc &loc, const String &data,
curScope->insertField( data, iterField );
LangStmt *stmt = LangStmt::cons( loc, LangStmt::ForIterType,
- iterField, typeRef, iterCall, stmtList, curContext(), scope );
+ iterField, typeRef, iterCall, stmtList, curStruct(), scope );
return stmt;
}
@@ -685,7 +685,7 @@ void BaseParser::preEof( const InputLoc &loc, StmtList *stmtList, ObjectDef *loc
error(loc) << "preeof must be used inside an existing region" << endl;
CodeBlock *codeBlock = CodeBlock::cons( stmtList, localFrame );
- codeBlock->context = curContext();
+ codeBlock->context = curStruct();
RegionSet *regionSet = regionStack.top();
regionSet->tokenIgnore->preEofBlock = codeBlock;
@@ -763,7 +763,7 @@ LangExpr *BaseParser::construct( const InputLoc &loc, ObjectField *objField,
LangVarRef *varRef = 0;
if ( objField != 0 ) {
varRef = LangVarRef::cons( objField->loc,
- curContext(), curScope, objField->name );
+ curStruct(), curScope, objField->name );
}
LangExpr *expr = LangExpr::cons( LangTerm::cons( loc, LangTerm::ConstructType,
@@ -815,7 +815,7 @@ LangStmt *BaseParser::varDef( ObjectField *objField,
if ( expr != 0 ) {
LangVarRef *varRef = LangVarRef::cons( objField->loc,
- curContext(), curScope, objField->name );
+ curStruct(), curScope, objField->name );
stmt = LangStmt::cons( objField->loc, assignType, varRef, expr );
}
@@ -828,7 +828,7 @@ LangStmt *BaseParser::exportStmt( ObjectField *objField,
{
LangStmt *stmt = 0;
- if ( curContext() != 0 )
+ if ( curStruct() != 0 )
error(objField->loc) << "cannot export parser context variables" << endp;
ObjectDef *object = pd->globalObjectDef;
@@ -864,10 +864,10 @@ LangExpr *BaseParser::require( const InputLoc &loc,
void BaseParser::contextVarDef( const InputLoc &loc, ObjectField *objField )
{
ObjectDef *object;
- if ( curContext() == 0 )
+ if ( curStruct() == 0 )
error(loc) << "internal error: no context stack items found" << endp;
- Context *context = curContext();
+ Context *context = curStruct();
objField->context = context;
object = context->objectDef;
@@ -886,7 +886,7 @@ void BaseParser::structHead( const InputLoc &loc,
data, pd->nextObjectId++ );
Context *context = new Context( loc, data, objectDef );
- contextStack.push( context );
+ structStack.push( context );
inNspace->structDefList.append( context );
diff --git a/src/parser.h b/src/parser.h
index 8ce0a21e..70436edd 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -24,7 +24,7 @@ struct BaseParser
RegionSetVect regionStack;
NamespaceVect namespaceStack;
- ContextStack contextStack;
+ ContextStack structStack;
ObjectDef *curLocalFrame;
NameScope *curScope;
@@ -33,8 +33,8 @@ struct BaseParser
bool insideRegion()
{ return regionStack.length() > 0; }
- Context *curContext()
- { return contextStack.length() == 0 ? 0 : contextStack.top(); }
+ Context *curStruct()
+ { return structStack.length() == 0 ? 0 : structStack.top(); }
Namespace *curNspace()
{ return namespaceStack.top(); }
@@ -50,12 +50,14 @@ struct BaseParser
void pushRegionSet( const InputLoc &loc );
void popRegionSet();
void addProduction( const InputLoc &loc, const String &name,
- ProdElList *prodElList, bool commit, CodeBlock *redBlock, LangEl *predOf );
+ ProdElList *prodElList, bool commit,
+ CodeBlock *redBlock, LangEl *predOf );
void addArgvList();
LexJoin *literalJoin( const InputLoc &loc, const String &data );
- void defineToken( const InputLoc &loc, String name, LexJoin *join, ObjectDef *objectDef,
- CodeBlock *transBlock, bool ignore, bool noPreIgnore, bool noPostIgnore );
+ void defineToken( const InputLoc &loc, String name, LexJoin *join,
+ ObjectDef *objectDef, CodeBlock *transBlock,
+ bool ignore, bool noPreIgnore, bool noPostIgnore );
void zeroDef( const InputLoc &loc, const String &name );
void literalDef( const InputLoc &loc, const String &data,
@@ -64,10 +66,12 @@ struct BaseParser
ObjectDef *blockOpen();
void blockClose();
void functionDef( StmtList *stmtList, ObjectDef *localFrame,
- ParameterList *paramList, TypeRef *typeRef, const String &name, bool exprt );
+ ParameterList *paramList, TypeRef *typeRef,
+ const String &name, bool exprt );
void iterDef( StmtList *stmtList, ObjectDef *localFrame,
ParameterList *paramList, const String &name );
- LangStmt *globalDef( ObjectField *objField, LangExpr *expr, LangStmt::Type assignType );
+ LangStmt *globalDef( ObjectField *objField, LangExpr *expr,
+ LangStmt::Type assignType );
void cflDef( NtDef *ntDef, ObjectDef *objectDef, LelDefList *defList );
ReOrBlock *lexRegularExprData( ReOrBlock *reOrBlock, ReOrItem *reOrItem );