summaryrefslogtreecommitdiff
path: root/test/heredoc.lm
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2008-11-01 17:35:50 +0000
committerAdrian Thurston <thurston@complang.org>2008-11-01 17:35:50 +0000
commit10ff0e06801af15050848c701f606ac5de3ebc06 (patch)
tree21e08beb963d6208ef236afe8c9ca16469895547 /test/heredoc.lm
downloadcolm-10ff0e06801af15050848c701f606ac5de3ebc06.tar.gz
Moved from private repository.
Diffstat (limited to 'test/heredoc.lm')
-rw-r--r--test/heredoc.lm45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/heredoc.lm b/test/heredoc.lm
new file mode 100644
index 00000000..54dcc33d
--- /dev/null
+++ b/test/heredoc.lm
@@ -0,0 +1,45 @@
+rl ident_char /[a-zA-Z_]/
+
+lex start
+{
+ # Tokens
+ token other /(^(ident_char|0|'\n'))+/
+
+ token here_close //
+ token id
+ /ident_char+/
+ {
+ if HereId && HereId == match_text {
+ send( make_token(
+ typeid here_close,
+ pull(stdin, match_length - 1) ) )
+ } else {
+ send( make_token( typeid id, pull(stdin, match_length) ) )
+ }
+ }
+
+ token nl /'\n'/
+}
+
+def here_name
+ [id]
+ {
+ HereId = r1.data
+ }
+
+global str HereId
+
+def here_data
+ [here_data_item*]
+
+def here_data_item
+ [id]
+| [other]
+| [nl]
+
+def heredoc
+ [here_name here_data here_close id nl]
+
+
+heredoc S = parse heredoc( stdin )
+print_xml(S)