summaryrefslogtreecommitdiff
path: root/src/colm.lm
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2015-06-08 17:20:29 -0400
committerAdrian Thurston <thurston@complang.org>2015-06-08 17:20:29 -0400
commitcc7e3b47c527c48be1513d34c3ebf69da6526054 (patch)
tree5f8bab42dec89cde447a9bb3f4cfb135dcd466a5 /src/colm.lm
parentb104d124867e77c8baef7b6fe52dffb4608d94df (diff)
downloadcolm-cc7e3b47c527c48be1513d34c3ebf69da6526054.tar.gz
adding commit points to switch clauses
Diffstat (limited to 'src/colm.lm')
-rw-r--r--src/colm.lm32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/colm.lm b/src/colm.lm
index 65964817..4104140f 100644
--- a/src/colm.lm
+++ b/src/colm.lm
@@ -431,29 +431,35 @@ def prod_list
| [prod] :Base
def case_clause
- [CASE pattern block_or_single]
+ [CASE pattern block_or_single] commit
def default_clause
- [DEFAULT block_or_single]
+ [DEFAULT block_or_single] commit
def case_clause_list
[case_clause case_clause_list] :Recursive
| [case_clause] :BaseCase
| [default_clause] :BaseDefault
+# Note a commit on switch doesn't work because the default clause in
+# case_clause follow sets cause a premature commit. We could use a proper list
+# for case clauses, followed by an optional default, but just move the commits
+# to the clauses, which is is a better commit strategy anyways. Gives more
+# regular commits.
+
def statement
- [print_stmt] :Print
-| [expr_stmt] :Expr
-| [var_def opt_def_init] :VarDef
-| [FOR id COLON type_ref IN iter_call block_or_single] :For
-| [IF code_expr block_or_single elsif_list] :If
+ [print_stmt] :Print commit
+| [expr_stmt] :Expr commit
+| [var_def opt_def_init] :VarDef commit
+| [FOR id COLON type_ref IN iter_call block_or_single] :For commit
+| [IF code_expr block_or_single elsif_list] :If commit
| [SWITCH var_ref case_clause_list] :Switch
-| [WHILE code_expr block_or_single] :While
-| [var_ref EQUALS code_expr] :LhsVarRef
-| [YIELD var_ref] :Yield
-| [RETURN code_expr] :Return
-| [BREAK] :Break
-| [REJECT] :Reject
+| [WHILE code_expr block_or_single] :While commit
+| [var_ref EQUALS code_expr] :LhsVarRef commit
+| [YIELD var_ref] :Yield commit
+| [RETURN code_expr] :Return commit
+| [BREAK] :Break commit
+| [REJECT] :Reject commit
def elsif_list
[elsif_clause elsif_list] :Clause