summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2011-06-08 15:14:47 +0000
committerAdrian Thurston <thurston@complang.org>2011-06-08 15:14:47 +0000
commitefb5fa61a49b5d7ee47287ffd4aabe7c2c94b1bf (patch)
tree4cabd96e3cbfd6c2397fba8c67e78747655faaca
parent553ef7e9a1d160cd21bdc0a343159c058e9b80df (diff)
downloadcolm-efb5fa61a49b5d7ee47287ffd4aabe7c2c94b1bf.tar.gz
Eliminated two calls to getKlangEl by replacing with passing up the tree. This
is in prep for moving all type resolution a pass after parsing and before compiling.
-rw-r--r--colm/lmparse.kh2
-rw-r--r--colm/lmparse.kl32
2 files changed, 28 insertions, 6 deletions
diff --git a/colm/lmparse.kh b/colm/lmparse.kh
index e89cf601..f2074309 100644
--- a/colm/lmparse.kh
+++ b/colm/lmparse.kh
@@ -26,6 +26,8 @@
#include "avltree.h"
#include "parsedata.h"
+#define PROPERTY_REDUCE_FIRST 0x1
+
struct Parser
{
%%{
diff --git a/colm/lmparse.kl b/colm/lmparse.kl
index 0a12b264..d19ca335 100644
--- a/colm/lmparse.kl
+++ b/colm/lmparse.kl
@@ -346,12 +346,20 @@ pred_token:
cfl_def: cfl_def_head obj_var_list properties_list cfl_prod_list
final {
/* Get the language element. */
- KlangEl *langEl = getKlangEl( pd, namespaceStack.top(), curDefineId );
+ KlangEl *langEl = $1->langEl;
langEl->objectDef = pd->objectDef;
if ( contextStack.length() > 0 )
langEl->contextIn = contextStack.top();
+
+ if ( $3->property & PROPERTY_REDUCE_FIRST )
+ langEl->reduceFirst = true;
};
+nonterm cfl_def_head
+{
+ KlangEl *langEl;
+};
+
cfl_def_head: KW_Def TK_Word
final {
curDefineId = $2->data;
@@ -366,20 +374,32 @@ cfl_def_head: KW_Def TK_Word
}
langEl->type = KlangEl::NonTerm;
+ $$->langEl = langEl;
};
cfl_prod_list: cfl_prod_list '|' define_prod;
cfl_prod_list: define_prod;
-properties_list: properties_list property;
-properties_list: ;
+nonterm property
+{
+ long property;
+};
+
+nonterm properties_list uses property;
+
+properties_list: properties_list property
+ final {
+ $$->property = $1->property | $2->property;
+ };
+properties_list:
+ final {
+ $$->property = 0;
+ };
property:
KW_ReduceFirst
final {
- /* Get the language element. */
- KlangEl *prodName = getKlangEl( pd, namespaceStack.top(), curDefineId );
- prodName->reduceFirst = true;
+ $$->property = PROPERTY_REDUCE_FIRST;
};
nonterm opt_prec