summaryrefslogtreecommitdiff
path: root/src/colm.lm
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2015-10-04 16:23:19 -0400
committerAdrian Thurston <thurston@complang.org>2015-10-04 16:23:19 -0400
commit6fb0cdffbafb135edaec7d927e5e508997c1d826 (patch)
tree878b580f8c8cdd4ae4dc1ea942b14c8f17940fc0 /src/colm.lm
parent514d1771d7956df29ea8e9f0c5f0a35d47bc8bc4 (diff)
downloadcolm-6fb0cdffbafb135edaec7d927e5e508997c1d826.tar.gz
sketched a grammar for reduction sections
Diffstat (limited to 'src/colm.lm')
-rw-r--r--src/colm.lm48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/colm.lm b/src/colm.lm
index 85c86f73..a5f15b9c 100644
--- a/src/colm.lm
+++ b/src/colm.lm
@@ -19,6 +19,7 @@ lex
token SEND / 'send' /
token SEND_TREE / 'send_tree' /
token NAMESPACE / 'namespace' /
+ token REDUCTION / 'reduction' /
token FOR / 'for' /
token IF / 'if' /
token YIELD / 'yield' /
@@ -221,6 +222,7 @@ def root_item
| [precedence_def] :Precedence commit
| [alias_def] :Alias commit
| [include] :Include commit
+| [reduction_def] :Reduction commit
def include
[INCLUDE SQ SqConsDataList: sq_cons_data* sq_lit_term]
@@ -331,6 +333,52 @@ def no_ignore_right
[MINUS NI] :Ni
| []
+def reduction_def
+ [REDUCTION id ItemList: reduction_item* END]
+
+lex
+ token ROPEN / '{' /
+ token RCLOSE / '}' /
+
+ token red_id /
+ ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) .
+ ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' ) *
+ /
+
+ token red_comment /
+ '//' . ( ^'\n' )* . '\n' |
+ '/*' . any* :> '*/'
+ /
+
+ token red_ws /
+ ( '\n' | '\t' | ' ' )+
+ /
+
+ token red_lit /
+ '\'' . ( ^( '\'' | '\\' ) | '\\' . any )* . ( '\'' | '\'i' ) |
+ '\"' . ( ^( '\"' | '\\' ) | '\\' . any )* . ( '\"' | '\"i' )
+ /
+
+ token red_any / any /
+end
+
+def red_nonterm
+ [id ROPEN host_item* RCLOSE]
+
+def red_action
+ [id COLON id ROPEN host_item* RCLOSE]
+
+def host_item
+ [red_id]
+| [red_lit]
+| [red_comment]
+| [red_ws]
+| [red_any]
+
+def reduction_item
+ [red_nonterm] commit
+| [red_action] commit
+
def namespace_def
[NAMESPACE id ItemList: namespace_item* END]