/[eiffelstudio]/trunk/Src/Eiffel/interface/new_graphical/text_window/text/lexer/editor_eiffel_scanner.l
ViewVC logotype

Contents of /trunk/Src/Eiffel/interface/new_graphical/text_window/text/lexer/editor_eiffel_scanner.l

Parent Directory Parent Directory | Revision Log Revision Log


Revision 103347 - (show annotations)
Thu Jul 18 15:24:16 2019 UTC (5 weeks, 2 days ago) by jfiat
File size: 13264 byte(s)
Fixed editor issue with manifest strings ending with %% such as "foo%%".

See bug#19527
1 %{
2 note
3 description:"Scanners for Eiffel parsers"
4 legal: "See notice at end of class."
5 status: "See notice at end of class."
6 author: "Arnaud PICHERY from an Eric Bezault model"
7 revised_by: "Alexander Kogtenkov"
8 date: "$Date$"
9 revision: "$Revision$"
10
11 class EDITOR_EIFFEL_SCANNER
12
13 inherit
14
15 EDITOR_EIFFEL_SCANNER_SKELETON
16
17 create
18 make
19 %}
20
21 %x VERBATIM_STR1
22 %option outfile="editor_eiffel_scanner.e"
23
24 D ([0-9])
25 B ([0-1])
26 O ([0-7])
27 H ([0-9A-Fa-f])
28 A ([0-9A-Za-z])
29
30 -- NON_ASCII: Identical to all code points of Unicode excluding 0 - 127.
31
32 UTF8_char {UTF8_1}|{UTF8_2}|{UTF8_3}|{UTF8_4}
33 NON_ASCII {UTF8_2}|{UTF8_3}|{UTF8_4}
34 UTF8_1 [\x00-\x7F]
35 UTF8_2 [\xC2-\xDF]{UTF8_tail}
36 UTF8_3 (\xE0[\xA0-\xBF]{UTF8_tail})|([\xE1-\xEC]({UTF8_tail}{2}))|(\xED[\x80-\x9F]{UTF8_tail})|([\xEE-\xEF]({UTF8_tail}{2}))
37 UTF8_4 (\xF0[\x90-\xBF]({UTF8_tail}{2}))|([\xF1-\xF3]({UTF8_tail}{3}))|(\xF4[\x80-\x8F]({UTF8_tail}{2}))
38 UTF8_tail [\x80-\xBF]
39
40 %%
41
42 ----------/** Separators **/----------------------------------------------------
43
44 [ ]+ {
45 curr_token := new_space (text_count)
46 update_token_list
47 }
48 [\t]+ {
49 if not in_comments then
50 curr_token := new_tabulation (text_count)
51 else
52 curr_token := new_comment (text)
53 end
54 update_token_list
55 }
56 \r\n {
57 curr_token := new_eol (True)
58 update_token_list
59 in_comments := False
60 }
61 \n {
62 curr_token := new_eol (False)
63 update_token_list
64 in_comments := False
65 }
66 \r {
67 curr_token := new_text (text)
68 update_token_list
69 }
70
71
72 ----------/** Eiffel comments **/-----------------------------------------------
73
74 "--" {
75 -- comments
76 curr_token := new_comment (text)
77 in_comments := True
78 update_token_list
79 }
80
81 ----------/** Eiffel symbols **/------------------------------------------------
82
83 "." |
84 ";" |
85 "," |
86 ":" |
87 "!" |
88 "(" |
89 ")" |
90 "{" |
91 "}" |
92 "[" |
93 "]" |
94 "$" {
95 -- Symbols
96 if not in_comments then
97 curr_token := new_text (text)
98 else
99 curr_token := new_comment (text)
100 end
101 update_token_list
102 }
103
104 "//" |
105 "\\\\" |
106 "/=" |
107 ">=" |
108 "<=" |
109 "->" |
110 ".." |
111 "<<" |
112 ">>" |
113 "?=" |
114 ":=" |
115 "/~" |
116 "-" |
117 "+" |
118 "*" |
119 "/" |
120 "^" |
121 "=" |
122 ">" |
123 "<" |
124 "~" {
125 -- Operator Symbol
126 if not in_comments then
127 curr_token := new_operator (text)
128 else
129 curr_token := new_comment (text)
130 end
131 update_token_list
132 }
133
134 ----------/** Reserved words **/------------------------------------------------
135
136 "!!" |
137 [aA][gG][eE][nN][tT] |
138 [aA][lL][iI][aA][sS] |
139 [aA][lL][lL] |
140 [aA][nN][dD] |
141 [aA][sS] |
142 [aA][sS][sS][iI][gG][nN] |
143 [bB][iI][tT] |
144 [cC][hH][eE][cC][kK] |
145 [cC][lL][aA][sS][sS] |
146 [cC][oO][nN][vV][eE][rR][tT] |
147 [cC][rR][eE][aA][tT][eE] |
148 [cC][rR][eE][aA][tT][iI][oO][nN] |
149 [cC][uU][rR][rR][eE][nN][tT] |
150 [dD][eE][bB][uU][gG] |
151 [dD][eE][fF][eE][rR][rR][eE][dD] |
152 [dD][oO] |
153 [eE][lL][sS][eE] |
154 [eE][lL][sS][eE][iI][fF] |
155 [eE][nN][dD] |
156 [eE][nN][sS][uU][rR][eE] |
157 [eE][xX][pP][aA][nN][dD][eE][dD] |
158 [eE][xX][pP][oO][rR][tT] |
159 [eE][xX][tT][eE][rR][nN][aA][lL] |
160 [fF][aA][lL][sS][eE] |
161 [fF][eE][aA][tT][uU][rR][eE] |
162 [fF][rR][oO][mM] |
163 [fF][rR][oO][zZ][eE][nN] |
164 [iI][fF] |
165 [iI][mM][pP][lL][iI][eE][sS] |
166 [iI][nN][fF][iI][xX] |
167 [iI][nN][hH][eE][rR][iI][tT] |
168 [iI][nN][sS][pP][eE][cC][tT] |
169 [iI][nN][vV][aA][rR][iI][aA][nN][tT] |
170 [iI][sS] |
171 [lL][iI][kK][eE] |
172 [lL][oO][cC][aA][lL] |
173 [lL][oO][oO][pP] |
174 [nN][oO][tT] |
175 [oO][bB][sS][oO][lL][eE][tT][eE] |
176 [oO][lL][dD] |
177 [oO][nN][cC][eE] |
178 [oO][rR] |
179 [pP][rR][eE][cC][uU][rR][sS][oO][rR] |
180 [pP][rR][eE][fF][iI][xX] |
181 [rR][eE][fF][eE][rR][eE][nN][cC][eE] |
182 [rR][eE][dD][eE][fF][iI][nN][eE] |
183 [rR][eE][nN][aA][mM][eE] |
184 [rR][eE][qQ][uU][iI][rR][eE] |
185 [rR][eE][sS][cC][uU][eE] |
186 [rR][eE][sS][uU][lL][tT] |
187 [rR][eE][tT][rR][yY] |
188 [sS][eE][lL][eE][cC][tT] |
189 [sS][eE][pP][aA][rR][aA][tT][eE] |
190 [sS][tT][rR][iI][pP] |
191 [tT][hH][eE][nN] |
192 [tT][rR][uU][eE] |
193 [uU][nN][dD][eE][fF][iI][nN][eE] |
194 [uU][nN][iI][qQ][uU][eE] |
195 [uU][nN][tT][iI][lL] |
196 [vV][aA][rR][iI][aA][nN][tT] |
197 [vV][oO][iI][dD] |
198 [wW][hH][eE][nN] |
199 [xX][oO][rR] {
200 if in_comments then
201 -- Comment.
202 curr_token := new_comment (text)
203 else
204 -- Keyword.
205 curr_token := new_keyword (text)
206 end
207 update_token_list
208 }
209
210 [aA][cC][rR][oO][sS][sS] |
211 [aA][tT][tT][aA][cC][hH][eE][dD] |
212 [aA][tT][tT][rR][iI][bB][uU][tT][eE] |
213 [dD][eE][tT][aA][cC][hH][aA][bB][lL][eE] |
214 [nN][oO][tT][eE] |
215 [sS][oO][mM][eE] {
216 if in_comments then
217 -- Comment
218 curr_token := new_comment (text)
219 elseif syntax_version /= {EIFFEL_SCANNER}.obsolete_syntax then
220 -- Keyword
221 curr_token := new_keyword (text)
222 else
223 -- Identifier
224 curr_token := new_text (text)
225 end
226 update_token_list
227 }
228
229 [iI][nN][dD][eE][xX][iI][nN][gG] {
230 if in_comments then
231 -- Comment
232 curr_token := new_comment (text)
233 elseif
234 syntax_version = {EIFFEL_SCANNER}.obsolete_syntax or else
235 syntax_version = {EIFFEL_SCANNER}.transitional_syntax
236 then
237 -- Keyword
238 curr_token := new_keyword (text)
239 else
240 curr_token := new_text (text)
241 end
242 update_token_list
243 }
244
245
246 ----------/** Eiffel identifiers **/--------------------------------------------
247
248 ([A-Z]|{NON_ASCII})([A-Z0-9_]|{NON_ASCII})* {
249 if not in_comments then
250 if is_current_group_valid then
251 tmp_classes := current_group.class_by_name (text, True)
252 if not tmp_classes.is_empty then
253 curr_token := new_class (text)
254 curr_token.set_pebble (stone_of_class (tmp_classes.first))
255 else
256 curr_token := new_text (text)
257 end
258 else
259 curr_token := new_text (text)
260 end
261 else
262 curr_token := new_comment (text)
263 end
264 update_token_list
265 }
266
267
268 ([a-zA-Z]|{NON_ASCII})([a-zA-Z0-9_]|{NON_ASCII})* {
269 if not in_comments then
270 curr_token := new_text (text)
271 else
272 curr_token := new_comment (text)
273 end
274 update_token_list
275 }
276
277
278 ----------/** Eiffel free operators **/-----------------------------------------
279
280 [@#|&][^%" \t\r\n]* {
281 if not in_comments then
282 curr_token := new_text (text)
283 else
284 curr_token := new_comment (text)
285 end
286 update_token_list
287 }
288 -- Note: Accepts non-printable characters as well,
289 -- provided that they are not break characters.
290
291
292 ----------/** Eiffel characters **/---------------------------------------------
293
294 \'([^%\n']|{NON_ASCII})\' |
295 \'%A\' |
296 \'%B\' |
297 \'%C\' |
298 \'%D\' |
299 \'%F\' |
300 \'%H\' |
301 \'%L\' |
302 \'%N\' |
303 \'%Q\' |
304 \'%R\' |
305 \'%S\' |
306 \'%T\' |
307 \'%U\' |
308 \'%V\' |
309 \'%%\' |
310 \'%\'\' |
311 \'%\"\' |
312 \'%\(\' |
313 \'%\)\' |
314 \'%<\' |
315 \'%>\' {
316 if not in_comments then
317 curr_token := new_character (text)
318 else
319 curr_token := new_comment (text)
320 end
321 update_token_list
322 }
323
324 \'%\/[0-9]+\/\' {
325 if not in_comments then
326 code_ := text_substring (4, text_count - 2).to_integer
327 if code_ > {CHARACTER}.Max_value then
328 -- Character error. Consedered as text.
329 curr_token := new_text (text)
330 else
331 curr_token := new_character (text)
332 end
333 else
334 curr_token := new_comment (text)
335 end
336 update_token_list
337 }
338
339 \'([^' \t\r\n]|{NON_ASCII})+ {
340 -- Character error. Catch-all rules (no backing up)
341 if not in_comments then
342 curr_token := new_text (text)
343 else
344 curr_token := new_comment (text)
345 end
346 update_token_list
347 }
348
349
350 ----------/** Eiffel strings **/------------------------------------------------
351
352 -- We accept here a fully formed Eiffel string which is complete, i.e:
353 -- 1 - whatever but `"' and '\n' except '%"' which is enclosed in
354 -- between (","), (",%), (%,%) or (%,")
355 -- We also accept beginning of a string, i.e:
356 -- 2 - whatever that start with either `"' or `%' and that does
357 -- not finishes with a `"' or `%'. Because we needed to support
358 -- the special character such as %N, %T,... we have to list all of
359 -- them in the second expression.
360
361 \"([^\n"%]|{NON_ASCII})*[\[\{]/[ \t\r]* {
362 if not in_comments then
363 -- Verbatim string opener.
364 curr_token := new_string (text)
365 update_token_list
366 in_verbatim_string := True
367 start_of_verbatim_string := True
368 set_start_condition (VERBATIM_STR1)
369 else
370 curr_token := new_comment (text)
371 update_token_list
372 end
373 }
374
375 <VERBATIM_STR1>{
376 [ \t\r]*[\]\}]([^%\n"]|{NON_ASCII})*\" {
377 -- Verbatim string closer, possibly.
378 curr_token := new_string (text)
379 end_of_verbatim_string := True
380 in_verbatim_string := False
381 set_start_condition (INITIAL)
382 update_token_list
383 }
384 [ ]+ {
385 curr_token := new_space (text_count)
386 update_token_list
387 }
388
389 [\t]+ {
390 curr_token := new_tabulation (text_count)
391 update_token_list
392 }
393
394 \r\n {
395 curr_token := new_eol (True)
396 update_token_list
397 in_comments := False
398 }
399 \n {
400 curr_token := new_eol (False)
401 update_token_list
402 in_comments := False
403 }
404 \r {
405 curr_token := new_text (text)
406 update_token_list
407 }
408 \" {
409 curr_token := new_string (text)
410 update_token_list
411 }
412 ([^\n\ \t\"]|{NON_ASCII})* {
413 curr_token := new_string (text)
414 update_token_list
415 }
416 }
417
418 [%\"]([^\n\"%]|{NON_ASCII}|%\"|%A|%B|%C|%D|%F|%H|%L|%N|%Q|%R|%S|%T|%U|%V|%%|%\'|%\(|%\)|%<|%>|%\/[0-9]{1,3}\/)*[%\"] {
419 -- Eiffel String
420 if not in_comments then
421 curr_token := new_string (text)
422 else
423 curr_token := new_comment (text)
424 end
425 update_token_list
426 }
427
428 ----------/** Eiffel integers **/-----------------------------------------------
429
430 {D}(({D}|_)*{D})? |
431 0[xX]{H}(({H}|_)*{H})? |
432 0[cC]{O}(({O}|_)*{O})? |
433 0[bB]{B}(({B}|_)*{B})? {
434 -- Eiffel Integer
435 if not in_comments then
436 curr_token := new_number (text)
437 else
438 curr_token := new_comment (text)
439 end
440 update_token_list
441 }
442
443
444 0[xX]{A}(({A}|_)*{A})? |
445 0[cC]{A}(({A}|_)*{A})? |
446 0[bB]{A}(({A}|_)*{A})? |
447 {D}(({A}|_)*{A})? {
448 -- Bad Eiffel Integer
449 if not in_comments then
450 curr_token := new_text (text)
451 else
452 curr_token := new_comment (text)
453 end
454 update_token_list
455 }
456
457 ---------/** Eiffel reals **/---------------------------------------------------
458
459 [0-9]+\./[^.0-9] |
460 [0-9]+\.[0-9]*[eE][+-]?[0-9]+ |
461 [0-9]*\.[0-9]+([eE][+-]?[0-9]+)? |
462 [0-9]{1,3}(_[0-9]{3})+\./[^.0-9] |
463 [0-9]{1,3}(_[0-9]{3})*\.([0-9]{1,3}(_[0-9]{3})*)?[eE][+-]?[0-9]{1,3}(_[0-9]{3})* |
464 ([0-9]{1,3}(_[0-9]{3})*)?\.[0-9]{1,3}(_[0-9]{3})*([eE][+-]?[0-9]{1,3}(_[0-9]{3})*)? {
465 -- Eiffel reals & doubles
466 if not in_comments then
467 curr_token := new_number (text)
468 else
469 curr_token := new_comment (text)
470 end
471 update_token_list
472 }
473
474 -- The first and fourth expressions use a trailing context
475 -- to make sure that an integer followed by two dots is
476 -- not recognized as a real followed by a dot.
477
478 ----------/** Comments enable/disable **/-----------------------------------------
479
480 \`([^%\n\`']|{NON_ASCII})+\` |
481 \`([^%\n\`']|{NON_ASCII})+\' {
482 curr_token := new_text_in_comment (text)
483 update_token_list
484 }
485
486 --------------------------------------------------------------------------------
487
488 <<EOF>> terminate
489 . {
490 -- Error (considered as text)
491 if not in_comments then
492 curr_token := new_text (text)
493 else
494 curr_token := new_comment (text)
495 end
496 update_token_list
497 }
498
499 --------------------------------------------------------------------------------
500 %%
501
502 note
503 copyright: "Copyright (c) 1984-2018, Eiffel Software"
504 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
505 licensing_options: "http://www.eiffel.com/licensing"
506 copying: "[
507 This file is part of Eiffel Software's Eiffel Development Environment.
508
509 Eiffel Software's Eiffel Development Environment is free
510 software; you can redistribute it and/or modify it under
511 the terms of the GNU General Public License as published
512 by the Free Software Foundation, version 2 of the License
513 (available at the URL listed under "license" above).
514
515 Eiffel Software's Eiffel Development Environment is
516 distributed in the hope that it will be useful, but
517 WITHOUT ANY WARRANTY; without even the implied warranty
518 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
519 See the GNU General Public License for more details.
520
521 You should have received a copy of the GNU General Public
522 License along with Eiffel Software's Eiffel Development
523 Environment; if not, write to the Free Software Foundation,
524 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
525 ]"
526 source: "[
527 Eiffel Software
528 5949 Hollister Ave., Goleta, CA 93117 USA
529 Telephone 805-685-1006, Fax 805-685-6869
530 Website http://www.eiffel.com
531 Customer support http://support.eiffel.com
532 ]"
533
534 end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23