summaryrefslogtreecommitdiff
path: root/test/island.lm
diff options
context:
space:
mode:
Diffstat (limited to 'test/island.lm')
-rw-r--r--test/island.lm85
1 files changed, 85 insertions, 0 deletions
diff --git a/test/island.lm b/test/island.lm
new file mode 100644
index 0000000..8515eb4
--- /dev/null
+++ b/test/island.lm
@@ -0,0 +1,85 @@
+##### LM #####
+
+lex
+ token func_chr /[^{}]+/
+ token func_open /'{'/
+ token func_close /'}'/
+end
+
+def func_item
+ [func_chr]
+| [func_open func_body func_close]
+
+def func_body
+ [func_item*]
+
+def func
+ [ident `( `) `{ func_body func_close ]
+
+lex
+ token ident /[a-zA-Z_]+/
+ token number /[0-9]+/
+
+ rl s_string / "'" ([^'\\\n] | '\\' any )* "'" /
+ rl d_string / '"' ([^"\\\n] | '\\' any )* '"' /
+ token string /s_string | d_string/
+
+ literal `+ `* `; `( `) `{ `}
+
+ ignore wp / [ \t\n]+ /
+end
+
+def class_item
+ [func]
+| [class]
+| [ident `;]
+| [number `;]
+| [string `;]
+
+def class_body
+ [class_item*]
+
+def class
+ [ident `{ class_body `} ]
+
+def top_item
+ [func]
+| [class]
+
+def start
+ [top_item*]
+
+parse S: start[ stdin ]
+print_xml( S )
+print( '\n' )
+
+#pattern start
+# ~class { func() { func() { 1+{2}} } } func() {{a}}
+##### IN #####
+class
+{
+ 1;
+ "string";
+ foo;
+ func()
+ {
+ func()
+ {
+ 1+{2}
+ }
+ }
+}
+
+func()
+{
+ "data"
+ {a}
+}
+##### EXP #####
+<start><_repeat_top_item><top_item><class><ident>class</ident><_literal_0017>{</_literal_0017><class_body><_repeat_class_item><class_item><number>1</number><_literal_0011>;</_literal_0011></class_item><class_item><string>"string"</string><_literal_0011>;</_literal_0011></class_item><class_item><ident>foo</ident><_literal_0011>;</_literal_0011></class_item><class_item><func><ident>func</ident><_literal_0013>(</_literal_0013><_literal_0015>)</_literal_0015><_literal_0017>{</_literal_0017><func_body><_repeat_func_item><func_item><func_chr>func()
+ </func_chr></func_item><func_item><func_open>{</func_open><func_body><_repeat_func_item><func_item><func_chr>
+ 1+</func_chr></func_item><func_item><func_open>{</func_open><func_body><_repeat_func_item><func_item><func_chr>2</func_chr></func_item></_repeat_func_item></func_body><func_close>}</func_close></func_item><func_item><func_chr>
+ </func_chr></func_item></_repeat_func_item></func_body><func_close>}</func_close></func_item><func_item><func_chr>
+ </func_chr></func_item></_repeat_func_item></func_body><func_close>}</func_close></func></class_item></_repeat_class_item></class_body><_literal_0019>}</_literal_0019></class></top_item><top_item><func><ident>func</ident><_literal_0013>(</_literal_0013><_literal_0015>)</_literal_0015><_literal_0017>{</_literal_0017><func_body><_repeat_func_item><func_item><func_chr>"data"
+ </func_chr></func_item><func_item><func_open>{</func_open><func_body><_repeat_func_item><func_item><func_chr>a</func_chr></func_item></_repeat_func_item></func_body><func_close>}</func_close></func_item><func_item><func_chr>
+</func_chr></func_item></_repeat_func_item></func_body><func_close>}</func_close></func></top_item></_repeat_top_item></start>