1syntax .vala-esc
2
3state char-esc special
4    char "bfnrt\\'\"" END special
5    char 0 oct
6    char u hex4
7    noeat short
8
9state oct special
10    char 0-3 oct2
11    char 4-7 oct1
12    noeat END
13
14state oct2 special
15    char 0-7 oct1
16    noeat END
17
18state oct1 special
19    char 0-7 END special
20    noeat END
21
22state hex4 special
23    char 0-9a-fA-F hex3
24    noeat END
25
26state hex3 special
27    char 0-9a-fA-F hex2
28    noeat END
29
30state hex2 special
31    char 0-9a-fA-F hex1
32    noeat END
33
34state hex1 special
35    char 0-9a-fA-F END special
36    noeat END
37
38state short special
39    char "\x80-\xff" not-ascii
40    # Any ASCII character but \n
41    char -n "\n" END error
42    # Don't eat \n
43    noeat END
44
45# Eats (at least) one multibyte UTF-8 character
46state not-ascii error
47    char "\x80-\xff" this
48    noeat END
49
50# TODO: Check against the Vala spec (was copied from the Java syntax)
51syntax vala
52
53state code
54    char -b a-zA-Z_ ident
55    char 0 zero
56    char 1-9 dec
57    char . dot
58    char \" string
59    char \' char
60    str "//" cpp-comment
61    str "/*" c-comment
62    eat this
63
64state cpp-comment comment
65    char "\n" code
66    eat this
67
68state c-comment comment
69    str "*/" code comment
70    eat this
71
72state ident
73    char -b a-zA-Z0-9_ this
74    inlist keyword code
75    inlist type code
76    inlist constant code
77    noeat code
78
79state zero numeric
80    char xX hex
81    char 0-7 oct
82    char . float
83    noeat num-suffix
84
85state oct numeric
86    char 0-7 this
87    noeat num-suffix
88
89state dec numeric
90    char 0-9 this
91    char eE exp
92    char . float
93    noeat num-suffix
94
95state hex numeric
96    char 0-9a-fA-F this
97    noeat num-suffix
98
99state num-suffix
100    char lLfFdD check-suffix numeric
101    noeat check-suffix
102
103state float-suffix
104    char fFdD check-suffix numeric
105    noeat check-suffix
106
107state check-suffix error
108    char a-zA-Z0-9_ this
109    noeat code
110
111state dot numeric
112    char 0-9 float
113    recolor code 1
114    noeat code
115
116state float numeric
117    char 0-9 this
118    char eE exp
119    noeat float-suffix
120
121state exp numeric
122    char +- exp-digit
123    char 0-9 exp-digit
124    noeat float-suffix
125
126state exp-digit numeric
127    char 0-9 this
128    noeat float-suffix
129
130state string
131    char \\ .vala-esc:this
132    char \" code string
133    eat this
134
135state char
136    char "\\" .vala-esc:char-end
137    char "\n" code
138    char \' code error
139    char "\x80-\xff" not-ascii
140    eat char-end
141
142# Eats (at least) one multibyte UTF-8 character
143state not-ascii char
144    char "\x80-\xff" this
145    noeat char-end
146
147state char-end char
148    char \' code char
149    eat code error
150
151list keyword \
152    if else switch case default do while for foreach in break continue \
153    return try catch finally throw lock class interface struct enum \
154    delegate errordomain const weak unowned dynamic abstract virtual \
155    override signal extern static async inline new public private \
156    protected internal out ref throws requires ensures namespace using \
157    as is in new delete sizeof typeof this base null true false get set \
158    construct default value construct static construct class construct \
159    void var yield global owned
160
161list type \
162    bool char uchar short ushort int uint long ulong size_t ssize_t int8 \
163    uint8 int16 uint16 int32 uint32 int64 uint64 unichar float double string
164
165list constant \
166    false true null
167