summaryrefslogtreecommitdiff
path: root/test/undofrag1.lm
blob: 4cd23a7e6a9bde5599aa372d4c7012a7ec9a1517 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
##### LM #####
lex
	ignore /space+/
	literal '#', '{', '}'
	token id2 /[a-zA-Z_]+/ 
end

def item2
	[id2]
|	['{' item2* '}']

def start2
	[item2*]


context ctx

	SP: parser<start2> 

	lex
		ignore /space+/
		literal '*', '(', ')', '!', ';\n'
		token id /[a-zA-Z_]+/ 
	end

	def item 
		[id]
	|	['(' item* ')']


	def A [] {
		print( 'A\n' )
		send SP "{ A{d} }"
	}

	def B [] {
		print( 'B\n' )
		send SP "{ B{d} }"
	}

	def start1 
		[A item* '!']
	|	[B item* ';\n']

end # ctx


CTX: ctx = cons ctx []
CTX.SP = cons parser<start2> []
send CTX.SP "a b{c}"

parse Input: ctx::start1( CTX )[stdin]

send CTX.SP "{e}f g"

print( Input )
print( CTX.SP() '\n' )
##### IN #####
a b c ( d ) e f g ;
##### EXP #####
A
B
a b c ( d ) e f g ;
a b{c}{ B{d} }{e}f g