diff options
author | Adrian Thurston <thurston@complang.org> | 2013-03-23 13:47:39 -0400 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2013-03-23 13:47:39 -0400 |
commit | 52cd20f9b4d21204dc9f46a69bde7cf6e58d719e (patch) | |
tree | 89c123d264c8fb2b38d9258f060d481eefb36daa | |
parent | 9922542d39edd209212541baeac8cfc7def13a83 (diff) | |
download | colm-52cd20f9b4d21204dc9f46a69bde7cf6e58d719e.tar.gz |
added reducefirst
-rw-r--r-- | colm/colm.lm | 10 | ||||
-rw-r--r-- | colm/load.cc | 5 | ||||
-rw-r--r-- | test/ragelambig3.exp | 1 | ||||
-rw-r--r-- | test/ragelambig3.in | 1 | ||||
-rw-r--r-- | test/ragelambig3.lm | 5 | ||||
-rw-r--r-- | test/ragelambig4.exp | 1 | ||||
-rw-r--r-- | test/ragelambig4.in | 1 | ||||
-rw-r--r-- | test/ragelambig4.lm | 5 |
8 files changed, 23 insertions, 6 deletions
diff --git a/colm/colm.lm b/colm/colm.lm index 6369f1bf..1bebaeac 100644 --- a/colm/colm.lm +++ b/colm/colm.lm @@ -34,6 +34,7 @@ lex token RETURN / 'return' / token BREAK / 'break' / token REJECT / 'reject' / + token REDUCEFIRST / 'reducefirst' / token MAKE_TOKEN / 'make_token' / token MAKE_TREE / 'make_tree' / @@ -241,8 +242,15 @@ def namespace_def def obj_var_list [] +def opt_reduce_first + [ReduceFirst: REDUCEFIRST] +| [] + def cfl_def - [DEF DefId: id VarDefList: var_def* ProdList: prod_list] + [DEF DefId: id + VarDefList: var_def* + OptReduceFirst: opt_reduce_first + ProdList: prod_list] def region_def [LEX RootItemList: root_item* END] diff --git a/colm/load.cc b/colm/load.cc index 9b5b6847..fa0dd5fc 100644 --- a/colm/load.cc +++ b/colm/load.cc @@ -888,7 +888,10 @@ void LoadSource::walkCflDef( cfl_def cflDef ) LelDefList *defList = new LelDefList; walkProdList( defList, cflDef.ProdList() ); - NtDef *ntDef = NtDef::cons( name, namespaceStack.top(), contextStack.top(), false ); + bool reduceFirst = cflDef.OptReduceFirst().ReduceFirst() != 0; + + NtDef *ntDef = NtDef::cons( name, namespaceStack.top(), + contextStack.top(), reduceFirst ); BaseParser::cflDef( ntDef, objectDef, defList ); } diff --git a/test/ragelambig3.exp b/test/ragelambig3.exp deleted file mode 100644 index 176173ba..00000000 --- a/test/ragelambig3.exp +++ /dev/null @@ -1 +0,0 @@ -<start><expression><expression><term_short><term><factor_with_rep><factor_with_neg><factor><alphabet_num><uint>1</uint></alphabet_num></factor></factor_with_neg></factor_with_rep></term></term_short></expression><_literal_0007>-</_literal_0007><term_short><term><factor_with_rep><factor_with_neg><factor><alphabet_num><uint>1</uint></alphabet_num></factor></factor_with_neg></factor_with_rep></term></term_short></expression></start> diff --git a/test/ragelambig3.in b/test/ragelambig3.in deleted file mode 100644 index 0b4439e5..00000000 --- a/test/ragelambig3.in +++ /dev/null @@ -1 +0,0 @@ -1 - 1 diff --git a/test/ragelambig3.lm b/test/ragelambig3.lm index 10061f6a..a7b37d7d 100644 --- a/test/ragelambig3.lm +++ b/test/ragelambig3.lm @@ -1,3 +1,4 @@ +##### LM ##### lex ignore /[\t\n ]+/ literal '^', '|', '-', ',', ':', '!', '?', '.' @@ -65,3 +66,7 @@ def alphabet_num parse start[ stdin ] print( '\n' ) +##### IN ##### +1 - 1 +##### EXP ##### +<start><expression><expression><term_short><term><factor_with_rep><factor_with_neg><factor><alphabet_num><uint>1</uint></alphabet_num></factor></factor_with_neg></factor_with_rep></term></term_short></expression><_literal_0007>-</_literal_0007><term_short><term><factor_with_rep><factor_with_neg><factor><alphabet_num><uint>1</uint></alphabet_num></factor></factor_with_neg></factor_with_rep></term></term_short></expression></start> diff --git a/test/ragelambig4.exp b/test/ragelambig4.exp deleted file mode 100644 index 7c20735c..00000000 --- a/test/ragelambig4.exp +++ /dev/null @@ -1 +0,0 @@ -<start><expression><term><factor_rep><factor_neg><factor><alphabet_num><uint>1</uint></alphabet_num></factor></factor_neg><_repeat_factor_rep_op></_repeat_factor_rep_op></factor_rep><term_op_list_short></term_op_list_short></term><_repeat_expression_op><expression_op><_literal_0007>-</_literal_0007><term><factor_rep><factor_neg><factor><alphabet_num><uint>1</uint></alphabet_num></factor></factor_neg><_repeat_factor_rep_op></_repeat_factor_rep_op></factor_rep><term_op_list_short></term_op_list_short></term></expression_op></_repeat_expression_op></expression></start> diff --git a/test/ragelambig4.in b/test/ragelambig4.in deleted file mode 100644 index 0b4439e5..00000000 --- a/test/ragelambig4.in +++ /dev/null @@ -1 +0,0 @@ -1 - 1 diff --git a/test/ragelambig4.lm b/test/ragelambig4.lm index 9ae6458d..8a4b7b51 100644 --- a/test/ragelambig4.lm +++ b/test/ragelambig4.lm @@ -1,3 +1,4 @@ +##### LM ##### lex ignore /[\t\n ]+/ literal '^', '|', '-', ',', ':', '!', '?', '.' @@ -69,3 +70,7 @@ def alphabet_num parse start[ stdin ] print( '\n' ) +##### IN ##### +1 - 1 +##### EXP ##### +<start><expression><term><factor_rep><factor_neg><factor><alphabet_num><uint>1</uint></alphabet_num></factor></factor_neg><_repeat_factor_rep_op></_repeat_factor_rep_op></factor_rep><term_op_list_short></term_op_list_short></term><_repeat_expression_op><expression_op><_literal_0007>-</_literal_0007><term><factor_rep><factor_neg><factor><alphabet_num><uint>1</uint></alphabet_num></factor></factor_neg><_repeat_factor_rep_op></_repeat_factor_rep_op></factor_rep><term_op_list_short></term_op_list_short></term></expression_op></_repeat_expression_op></expression></start> |