summaryrefslogtreecommitdiff
path: root/src/parser.cc
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2015-10-04 23:16:46 -0400
committerAdrian Thurston <thurston@complang.org>2015-10-04 23:16:46 -0400
commit13d7c884e2a855418d68b8e45041b8ab4a20a85c (patch)
treeeccbfb13e83812b01858317938f972913c7b7bf1 /src/parser.cc
parent6fb0cdffbafb135edaec7d927e5e508997c1d826 (diff)
downloadcolm-13d7c884e2a855418d68b8e45041b8ab4a20a85c.tar.gz
load reduction actions and generate a commit containing them
Diffstat (limited to 'src/parser.cc')
-rw-r--r--src/parser.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/parser.cc b/src/parser.cc
index d1bead20..22348e06 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -261,6 +261,21 @@ Namespace *BaseParser::createNamespace( const InputLoc &loc, const String &name
return nspace;
}
+Reduction *BaseParser::createReduction( const InputLoc loc, const String &name )
+{
+ Namespace *parent = namespaceStack.top();
+ Reduction *reduction = parent->findReduction( name );
+
+ if ( reduction == 0 ) {
+ reduction = new Reduction( loc, name );
+ parent->reductions.append( reduction );
+ }
+
+ reductionStack.push( reduction );
+
+ return reduction;
+}
+
LexJoin *BaseParser::literalJoin( const InputLoc &loc, const String &data )
{
Literal *literal = Literal::cons( loc, data, Literal::LitString );