summaryrefslogtreecommitdiff
path: root/src/colm.lm
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2013-12-15 14:33:45 -0500
committerAdrian Thurston <thurston@complang.org>2013-12-15 14:33:45 -0500
commit6dbc65a7d74b183172331748e76a1937184deacc (patch)
tree02b6b1ab0ea78b3b5ba532cee9c334f98f4da81c /src/colm.lm
parentd1ac9cb83fc276925bad0c68009fa72830b33f6d (diff)
downloadcolm-6dbc65a7d74b183172331748e76a1937184deacc.tar.gz
added the cast operator
The cast operator converts a tree to another type by copying over tokdata, ignore tokens, and children. The new tree has the type of the target of the cast. Attributes are cleared (# determined by target type). The production number is set to -1.
Diffstat (limited to 'src/colm.lm')
-rw-r--r--src/colm.lm2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/colm.lm b/src/colm.lm
index 1a0c54e3..f9125b36 100644
--- a/src/colm.lm
+++ b/src/colm.lm
@@ -42,6 +42,7 @@ lex
token PREEOF / 'preeof' /
token GLOBAL / 'global' /
token EOS / 'eos' /
+ token CAST / 'cast' /
token MAKE_TOKEN / 'make_token' /
token MAKE_TREE / 'make_tree' /
@@ -480,6 +481,7 @@ def code_factor
| [MAKE_TOKEN POPEN MakeTokenExprList: code_expr* PCLOSE] :MakeToken
| [TYPEID LT type_ref GT] :TypeId
| [NEW code_factor] :New
+| [CAST LT type_ref GT code_factor] :Cast
def type_ref
[region_qual id opt_repeat] :Id