...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package expr
18
19 var op1ch = [...]bool {
20 '+': true,
21 '-': true,
22 '*': true,
23 '/': true,
24 '%': true,
25 '&': true,
26 '|': true,
27 '^': true,
28 '~': true,
29 '(': true,
30 ')': true,
31 }
32
33 var op2ch = [...]bool {
34 '*': true,
35 '<': true,
36 '>': true,
37 }
38
39 func neg2(v *Expr, err error) (*Expr, error) {
40 if err != nil {
41 return nil, err
42 } else {
43 return v.Neg(), nil
44 }
45 }
46
47 func not2(v *Expr, err error) (*Expr, error) {
48 if err != nil {
49 return nil, err
50 } else {
51 return v.Not(), nil
52 }
53 }
54
55 func isop1ch(ch rune) bool {
56 return ch >= 0 && int(ch) < len(op1ch) && op1ch[ch]
57 }
58
59 func isop2ch(ch rune) bool {
60 return ch >= 0 && int(ch) < len(op2ch) && op2ch[ch]
61 }
62
63 func isdigit(ch rune) bool {
64 return ch >= '0' && ch <= '9'
65 }
66
67 func isident(ch rune) bool {
68 return isdigit(ch) || isident0(ch)
69 }
70
71 func isident0(ch rune) bool {
72 return (ch == '_') || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')
73 }
74
75 func ishexdigit(ch rune) bool {
76 return isdigit(ch) || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F')
77 }
78
View as plain text