-
Notifications
You must be signed in to change notification settings - Fork 1
/
sample.exp
82 lines (55 loc) · 1.61 KB
/
sample.exp
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
> a
name("a")
> 1
integer("1")
> a=b=c
assign("a", assign("b", name("c")))
> a?b:c
cond(name("a"), name("b"), name("c"))
> a?b?c:d:e
cond(name("a"), cond(name("b"), name("c"), name("d")), name("e"))
> a?b:c?d:e
cond(name("a"), name("b"), cond(name("c"), name("d"), name("e")))
> a?b=c?d:e:f
cond(name("a"), assign("b", cond(name("c"), name("d"), name("e"))), name("f"))
> -a
prefix(minus, name("a"))
> -+a
prefix(minus, prefix(plus, name("a")))
> -x^k
prefix(minus, infix(name("x"), caret, name("k")))
> !a
prefix(bang, name("a"))
> a!
postfix(name("a"), bang)
> !a!
prefix(bang, postfix(name("a"), bang))
> a+b
infix(name("a"), plus, name("b"))
> a+b*c
infix(name("a"), plus, infix(name("b"), star, name("c")))
> a*b+c
infix(infix(name("a"), star, name("b")), plus, name("c"))
> a*(b+c)
infix(name("a"), star, infix(name("b"), plus, name("c")))
> a*-b/c^k+d!!
infix(infix(infix(name("a"), star, prefix(minus, name("b"))), slash, infix(name("c"), caret, name("k"))), plus, postfix(postfix(name("d"), bang), bang))
> a^b^c
infix(name("a"), caret, infix(name("b"), caret, name("c")))
> f()
call(name("f"), [])
> f(a, ! b^g(c,d)!)
call(name("f"), [name("a"), prefix(bang, infix(name("b"), caret, postfix(call(name("g"), [name("c"), name("d")]), bang)))])
> a<b
infix(name("a"), lt, name("b"))
> !a<b!
infix(prefix(bang, name("a")), lt, postfix(name("b"), bang))
> a<b>c
parse failed
> a<(b<c)
infix(name("a"), lt, infix(name("b"), lt, name("c")))
> a<(b<c)<d
parse failed
> x=a?b+1!<-c:d
assign("x", cond(name("a"), infix(infix(name("b"), plus, postfix(integer("1"), bang)), lt, prefix(minus, name("c"))), name("d")))
>