/[eiffelstudio]/vendor/gobosoft.com/gobo/4.0d/library/tools/src/eiffel/parser/et_eiffel_preparser.l
ViewVC logotype

Contents of /vendor/gobosoft.com/gobo/4.0d/library/tools/src/eiffel/parser/et_eiffel_preparser.l

Parent Directory Parent Directory | Revision Log Revision Log


Revision 98698 - (show annotations)
Mon May 9 13:53:54 2016 UTC (3 years, 5 months ago) by manus
File size: 17802 byte(s)
Update 4.0d version with changes in Gobo from 2016/05/09

1 %{
2 note
3
4 description:
5
6 "Eiffel preparsers"
7
8 library: "Gobo Eiffel Tools Library"
9 copyright: "Copyright (c) 2002-2016, Eric Bezault and others"
10 license: "MIT License"
11 date: "$Date$"
12 revision: "$Revision$"
13
14 class ET_EIFFEL_PREPARSER
15
16 inherit
17
18 ET_EIFFEL_PREPARSER_SKELETON
19
20 create
21
22 make
23 %}
24
25 UTF8_BOM (\xEF\xBB\xBF)
26
27 %x MS MSN MSN1 VS1 VS2 VS3 LAVS1 LAVS2 LAVS3
28 %option nodefault line outfile="et_eiffel_preparser.e"
29
30 %%
31
32 ----------/** BOM **/-----------------------------------------------------------
33
34 {UTF8_BOM} {
35 -- Ignore byte order mark (BOM).
36 -- See http://en.wikipedia.org/wiki/Byte_order_mark
37 }
38
39
40 ----------/** Separators, Comments, Symbols **/----------------------------------------------------
41
42 ([ \t\r\n]|"--".*)+ |
43 [-+*/^=><.;,:!?(){}[\]$~] |
44 ("//"|"\\\\"|"/="|"/~"|">="|"<="|"->"|".."|"<<"|">>"|":="|"?=") {
45 }
46
47 ----------/** Reserved words **/------------------------------------------------
48
49 [aA][gG][eE][nN][tT] |
50 [aA][lL][iI][aA][sS] |
51 [aA][lL][lL] |
52 [aA][nN][dD] |
53 [aA][sS] |
54 [aA][sS][sS][iI][gG][nN] |
55 [cC][hH][eE][cC][kK] |
56 [cC][oO][nN][vV][eE][rR][tT] |
57 [cC][rR][eE][aA][tT][eE] |
58 [cC][rR][eE][aA][tT][iI][oO][nN] |
59 [cC][uU][rR][rR][eE][nN][tT] |
60 [dD][eE][bB][uU][gG] |
61 [dD][eE][fF][eE][rR][rR][eE][dD] |
62 [dD][oO] |
63 [eE][lL][sS][eE] |
64 [eE][lL][sS][eE][iI][fF] |
65 [eE][nN][dD] |
66 [eE][nN][sS][uU][rR][eE] |
67 [eE][xX][pP][aA][nN][dD][eE][dD] |
68 [eE][xX][pP][oO][rR][tT] |
69 [eE][xX][tT][eE][rR][nN][aA][lL] |
70 [fF][aA][lL][sS][eE] |
71 [fF][eE][aA][tT][uU][rR][eE] |
72 [fF][rR][oO][mM] |
73 [fF][rR][oO][zZ][eE][nN] |
74 [iI][fF] |
75 [iI][mM][pP][lL][iI][eE][sS] |
76 [iI][nN][dD][eE][xX][iI][nN][gG] |
77 [iI][nN][fF][iI][xX] |
78 [iI][nN][hH][eE][rR][iI][tT] |
79 [iI][nN][sS][pP][eE][cC][tT] |
80 [iI][nN][vV][aA][rR][iI][aA][nN][tT] |
81 [iI][sS] |
82 [lL][iI][kK][eE] |
83 [lL][oO][cC][aA][lL] |
84 [lL][oO][oO][pP] |
85 [nN][oO][tT] |
86 [oO][bB][sS][oO][lL][eE][tT][eE] |
87 [oO][lL][dD] |
88 [oO][nN][cC][eE] |
89 [oO][rR] |
90 [pP][rR][eE][cC][uU][rR][sS][oO][rR] |
91 [pP][rR][eE][fF][iI][xX] |
92 [rR][eE][dD][eE][fF][iI][nN][eE] |
93 [rR][eE][nN][aA][mM][eE] |
94 [rR][eE][qQ][uU][iI][rR][eE] |
95 [rR][eE][sS][cC][uU][eE] |
96 [rR][eE][sS][uU][lL][tT] |
97 [rR][eE][tT][rR][yY] |
98 [sS][eE][lL][eE][cC][tT] |
99 [sS][eE][pP][aA][rR][aA][tT][eE] |
100 [sS][tT][rR][iI][pP] |
101 [tT][hH][eE][nN] |
102 [tT][rR][uU][eE] |
103 [uU][nN][dD][eE][fF][iI][nN][eE] |
104 [uU][nN][iI][qQ][uU][eE] |
105 [uU][nN][tT][iI][lL] |
106 [vV][aA][rR][iI][aA][nN][tT] |
107 [vV][oO][iI][dD] |
108 [wW][hH][eE][nN] |
109 [xX][oO][rR] {
110 }
111 [cC][lL][aA][sS][sS] {
112 class_keyword_found := True
113 }
114 [aA][tT][tT][aA][cC][hH][eE][dD] {
115 if use_attached_keyword then
116 -- Do nothing.
117 elseif class_keyword_found then
118 last_token := E_IDENTIFIER
119 last_literal_start := 1
120 last_literal_end := 9
121 last_break_end := 0
122 last_comment_end := 0
123 last_classname := ast_factory.new_identifier (Current)
124 end
125 }
126 [aA][tT][tT][rR][iI][bB][uU][tT][eE] {
127 if use_attribute_keyword then
128 -- Do nothing.
129 elseif class_keyword_found then
130 last_token := E_IDENTIFIER
131 last_literal_start := 1
132 last_literal_end := 9
133 last_break_end := 0
134 last_comment_end := 0
135 last_classname := ast_factory.new_identifier (Current)
136 end
137 }
138 [dD][eE][tT][aA][cC][hH][aA][bB][lL][eE] {
139 if use_detachable_keyword then
140 -- Do nothing.
141 elseif class_keyword_found then
142 last_token := E_IDENTIFIER
143 last_literal_start := 1
144 last_literal_end := 9
145 last_break_end := 0
146 last_comment_end := 0
147 last_classname := ast_factory.new_identifier (Current)
148 end
149 }
150 [nN][oO][tT][eE] {
151 if use_note_keyword then
152 -- Do nothing.
153 elseif class_keyword_found then
154 last_token := E_IDENTIFIER
155 last_literal_start := 1
156 last_literal_end := 4
157 last_break_end := 0
158 last_comment_end := 0
159 last_classname := ast_factory.new_identifier (Current)
160 end
161 }
162 [rR][eE][fF][eE][rR][eE][nN][cC][eE] {
163 if use_reference_keyword then
164 -- Do nothing.
165 elseif class_keyword_found then
166 last_token := E_IDENTIFIER
167 last_literal_start := 1
168 last_literal_end := 9
169 last_break_end := 0
170 last_comment_end := 0
171 last_classname := ast_factory.new_identifier (Current)
172 end
173 }
174
175
176 ----------/** Eiffel identifiers **/--------------------------------------------
177
178 [a-zA-Z][a-zA-Z0-9_]* {
179 if class_keyword_found then
180 last_token := E_IDENTIFIER
181 last_literal_start := 1
182 last_literal_end := text_count
183 last_break_end := 0
184 last_comment_end := 0
185 last_classname := ast_factory.new_identifier (Current)
186 end
187 }
188
189
190 ----------/** Eiffel free operators **/-----------------------------------------
191
192 [@#|&][^%" \t\r\n]* {
193 }
194
195 -- Note: Accepts non-printable characters as well,
196 -- provided that they are not break characters.
197
198
199 ----------/** Eiffel characters **/---------------------------------------------
200
201 \'[^%\n]\' |
202 \'%.\' |
203 \'%\/[0-9]+\/\' {
204 }
205
206 \'%\/[0-9]+ {
207 -- Syntax error: missing character / at end
208 -- of special character specification %/code/.
209 column := column + text_count
210 set_syntax_error
211 error_handler.report_SCAS_error (filename, current_position)
212 column := column - text_count
213 last_token := E_CHARERR
214 }
215 \'%\/ {
216 -- Syntax error: missing ASCII code in
217 -- special character specification %/code/.
218 column := column + 3
219 set_syntax_error
220 error_handler.report_SCAC_error (filename, current_position)
221 column := column - 3
222 last_token := E_CHARERR
223 }
224 \'\' {
225 -- Syntax error: missing character between quotes.
226 column := column + 1
227 set_syntax_error
228 error_handler.report_SCQQ_error (filename, current_position)
229 column := column - 1
230 last_token := E_CHARERR
231 }
232 \'(.|%.|%\/[0-9]+\/)? {
233 -- Syntax error: missing quote at
234 -- end of character constant.
235 column := column + text_count
236 set_syntax_error
237 error_handler.report_SCEQ_error (filename, current_position)
238 column := column - text_count
239 last_token := E_CHARERR
240 }
241
242
243 ----------/** Eiffel strings **/------------------------------------------------
244
245 \"[^%\n"]*\" {
246 }
247
248 \"[^\n"%]*\{/[ \t\r]*\n {
249 -- Verbatim string.
250 verbatim_marker := text_substring (2, text_count - 1)
251 set_start_condition (VS1)
252 }
253 <VS1>{
254 -- Discard space characters at the
255 -- end of Verbatim_string_opener.
256 [ \t\r]*\n {
257 last_literal_start := 1
258 last_literal_end := 0
259 set_start_condition (VS2)
260 }
261 . {
262 -- No final brace-double-quote.
263 last_token := E_STRERR
264 report_syntax_error (current_position)
265 set_start_condition (INITIAL)
266 }
267 <<EOF>> {
268 -- No final brace-double-quote.
269 last_token := E_STRERR
270 report_syntax_error (current_position)
271 set_start_condition (INITIAL)
272 }
273 }
274 <VS2>{
275 -- Read one line of a verbatim string body
276 -- from the beginning of line.
277 [ \t\r]*\}[^%\n"]*\" {
278 if is_verbatim_string_closer (last_literal_end + 1, text_count - 1) then
279 verbatim_marker := no_verbatim_marker
280 set_start_condition (INITIAL)
281 else
282 more
283 set_start_condition (VS3)
284 end
285 }
286 [^"\n]*\" {
287 more
288 set_start_condition (VS3)
289 }
290 [^"\n]*\r\n {
291 more
292 last_literal_end := text_count - 2
293 }
294 [^"\n]*\n {
295 more
296 last_literal_end := text_count - 1
297 }
298 [^"\n]* {
299 -- No final brace-double-quote.
300 last_token := E_STRERR
301 report_syntax_error (current_position)
302 set_start_condition (INITIAL)
303 }
304 <<EOF>> {
305 -- No final brace-double-quote.
306 last_token := E_STRERR
307 report_syntax_error (current_position)
308 set_start_condition (INITIAL)
309 }
310 }
311 <VS3>{
312 -- Read remaining characters of a line
313 -- in verbatim string body.
314 .*\r\n {
315 more
316 last_literal_end := text_count - 2
317 set_start_condition (VS2)
318 }
319 .*\n {
320 more
321 last_literal_end := text_count - 1
322 set_start_condition (VS2)
323 }
324 .* {
325 -- No final brace-double-quote.
326 last_token := E_STRERR
327 report_syntax_error (current_position)
328 set_start_condition (INITIAL)
329 }
330 <<EOF>> {
331 -- No final brace-double-quote.
332 last_token := E_STRERR
333 report_syntax_error (current_position)
334 set_start_condition (INITIAL)
335 }
336 }
337
338 \"[^\n"%]*\[/[ \t\r]*\n {
339 -- Left aligned verbatim string.
340 verbatim_marker := text_substring (2, text_count - 1)
341 set_start_condition (LAVS1)
342 }
343 <LAVS1>{
344 -- Discard space characters at the
345 -- end of Verbatim_string_opener.
346 [ \t\r]*\n {
347 last_literal_start := 1
348 last_literal_end := 0
349 set_start_condition (LAVS2)
350 }
351 . {
352 -- No final bracket-double-quote.
353 last_token := E_STRERR
354 report_syntax_error (current_position)
355 set_start_condition (INITIAL)
356 }
357 <<EOF>> {
358 -- No final bracket-double-quote.
359 last_token := E_STRERR
360 report_syntax_error (current_position)
361 set_start_condition (INITIAL)
362 }
363 }
364 <LAVS2>{
365 -- Read one line of a verbatim string body
366 -- from the beginning of line.
367 [ \t\r]*\][^%\n"]*\" {
368 if is_verbatim_string_closer (last_literal_end + 1, text_count - 1) then
369 verbatim_marker := no_verbatim_marker
370 set_start_condition (INITIAL)
371 else
372 more
373 set_start_condition (LAVS3)
374 end
375 }
376 [^"\n]*\" {
377 more
378 set_start_condition (LAVS3)
379 }
380 [^"\n]*\r\n {
381 more
382 last_literal_end := text_count - 2
383 }
384 [^"\n]*\n {
385 more
386 last_literal_end := text_count - 1
387 }
388 [^"\n]* {
389 -- No final bracket-double-quote.
390 last_token := E_STRERR
391 report_syntax_error (current_position)
392 set_start_condition (INITIAL)
393 }
394 <<EOF>> {
395 -- No final bracket-double-quote.
396 last_token := E_STRERR
397 report_syntax_error (current_position)
398 set_start_condition (INITIAL)
399 }
400 }
401 <LAVS3>{
402 -- Read remaining characters of a line
403 -- in verbatim string body.
404 .*\r\n {
405 more
406 last_literal_end := text_count - 2
407 set_start_condition (LAVS2)
408 }
409 .*\n {
410 more
411 last_literal_end := text_count - 1
412 set_start_condition (LAVS2)
413 }
414 .* {
415 -- No final bracket-double-quote.
416 last_token := E_STRERR
417 report_syntax_error (current_position)
418 set_start_condition (INITIAL)
419 }
420 <<EOF>> {
421 -- No final bracket-double-quote.
422 last_token := E_STRERR
423 report_syntax_error (current_position)
424 set_start_condition (INITIAL)
425 }
426 }
427
428 \"([^%\n"]|%([ABCDFHLNQRSTUV%'"()<>]|\/[0-9]+\/))*\" {
429 -- Manifest string with special characters.
430 }
431 \"([^%\n"]|%([ABCDFHLNQRSTUV%'"()<>]|\/[0-9]+\/))* {
432 -- Manifest string with special characters which may be made
433 -- up of several lines or may include invalid characters.
434 -- Keep track of current line and column.
435 ms_line := line
436 ms_column := column
437 more
438 set_start_condition (MS)
439 }
440
441 <MS>{
442 %\r?\n {
443 -- Multi-line manifest string.
444 more
445 set_start_condition (MSN)
446 }
447 %[ \t\r]/[ \t\r]*\n {
448 -- Multi-line manifest string.
449
450 -- Syntax error: no space allowed after character
451 -- % at end of line in multi-line manifest strings.
452 column := yy_column - 1
453 line := yy_line
454 -- set_syntax_error
455 -- error_handler.report_SSNS_error (filename, current_position)
456 column := ms_column
457 line := ms_line
458
459 more
460 set_start_condition (MSN1)
461 }
462 %\/[0-9]+\/ {
463 more
464 }
465 %\/[0-9]+ {
466 -- Syntax error: missing character / at end of special
467 -- character specification %/code/ in manifest string.
468 column := yy_column
469 line := yy_line
470 -- set_syntax_error
471 -- error_handler.report_SSAS_error (filename, current_position)
472 column := ms_column
473 line := ms_line
474
475 more
476 }
477 %\/ {
478 -- Syntax error: missing ASCII code in special character
479 -- specification %/code/ in manifest string.
480 column := yy_column
481 line := yy_line
482 -- set_syntax_error
483 -- error_handler.report_SSAC_error (filename, current_position)
484 column := ms_column
485 line := ms_line
486
487 more
488 }
489 %[abcdfhlnqrstuv] {
490 -- Syntax error: special character specification
491 -- %l where l is a letter code should be in
492 -- upper-case in manifest strings.
493 column := yy_column - 1
494 line := yy_line
495 -- set_syntax_error
496 -- error_handler.report_SSCU_error (filename, current_position)
497 column := ms_column
498 line := ms_line
499
500 more
501 }
502 ([^%\n"]|%([ABCDFHLNQRSTUV%'"()<>]|\/[0-9]+\/))+ {
503 more
504 }
505 ([^%\n"]|%([ABCDFHLNQRSTUV%'"()<>]|\/[0-9]+\/))*\" {
506 set_start_condition (INITIAL)
507 }
508 %. {
509 -- Syntax error: Invalid special character
510 -- in manifest strings.
511 column := yy_column - 1
512 line := yy_line
513 -- set_syntax_error
514 -- error_handler.report_SSSC_error (filename, current_position)
515 column := ms_column
516 line := ms_line
517
518 more
519 }
520 % {
521 -- Syntax error: invalid special character
522 -- %l in manifest strings.
523 column := yy_column
524 line := yy_line
525 set_syntax_error
526 error_handler.report_SSSC_error (filename, current_position)
527 column := ms_column
528 line := ms_line
529
530 last_token := E_STRERR
531 set_start_condition (INITIAL)
532 }
533 \n {
534 -- Syntax error: Invalid new-line in manifest string.
535 column := 1
536 line := yy_line
537 set_syntax_error
538 error_handler.report_SSNL_error (filename, current_position)
539 column := ms_column
540 line := ms_line
541
542 last_token := E_STRERR
543 set_start_condition (INITIAL)
544 }
545 <<EOF>> {
546 -- Syntax error: missing double quote at
547 -- end of manifest string.
548 column := yy_column
549 line := yy_line
550 set_syntax_error
551 error_handler.report_SSEQ_error (filename, current_position)
552 column := ms_column
553 line := ms_line
554
555 last_token := E_STRERR
556 set_start_condition (INITIAL)
557 }
558 }
559
560 <MSN1>{
561 [ \t\r]*\n {
562 more
563 set_start_condition (MSN)
564 }
565 . {
566 -- Should never happen.
567 last_token := E_STRERR
568 report_syntax_error (current_position)
569 set_start_condition (INITIAL)
570 }
571 <<EOF>> {
572 -- Should never happen.
573 last_token := E_STRERR
574 report_syntax_error (current_position)
575 set_start_condition (INITIAL)
576 }
577 }
578
579 <MSN>{
580 [ \r\t]*% {
581 more
582 set_start_condition (MS)
583 }
584 [ \r\t]*\n {
585 -- Syntax error: empty line in middle of
586 -- multi-line manifest string.
587 column := 1
588 line := yy_line - 1
589 -- set_syntax_error
590 -- error_handler.report_SSEL_error (filename, current_position)
591 column := ms_column
592 line := ms_line
593
594 more
595 }
596 . {
597 -- Syntax error: missing character % at beginning
598 -- of line in multi-line manifest string.
599 column := yy_column - 1
600 line := yy_line
601 set_syntax_error
602 error_handler.report_SSNP_error (filename, current_position)
603 column := ms_column
604 line := ms_line
605
606 last_token := E_STRERR
607 set_start_condition (INITIAL)
608 }
609 <<EOF>> {
610 -- Syntax error: missing character % at beginning
611 -- of line in multi-line manifest string.
612 column := yy_column
613 line := yy_line
614 set_syntax_error
615 error_handler.report_SSNP_error (filename, current_position)
616 column := ms_column
617 line := ms_line
618
619 last_token := E_STRERR
620 set_start_condition (INITIAL)
621 }
622 }
623
624
625 ----------/** Eiffel integers **/-----------------------------------------------
626
627 [0-9]+ {
628 }
629 [0-9]+(_+[0-9]+)+ {
630 }
631 (_+[0-9]+)+ {
632 -- Syntax error: an underscore may not be
633 -- the first character of an integer.
634 set_syntax_error
635 error_handler.report_SIFU_error (filename, current_position)
636 last_token := E_INTEGER
637 }
638 ([0-9]+_+)+ {
639 -- Syntax error: an underscore may not be
640 -- the last character of an integer.
641 set_syntax_error
642 error_handler.report_SILU_error (filename, current_position)
643 last_token := E_INTEGER
644 }
645 0[xX][0-9a-fA-F]+(_+[0-9a-fA-F]+)* {
646 }
647 0[xX](_+[0-9a-fA-F]+)+ {
648 -- Syntax error: an underscore may not be
649 -- the first character of an integer.
650 set_syntax_error
651 error_handler.report_SIFU_error (filename, current_position)
652 last_token := E_INTEGER
653 }
654 0[xX]([0-9a-fA-F]+_+)+ {
655 -- Syntax error: an underscore may not be
656 -- the last character of an integer.
657 set_syntax_error
658 error_handler.report_SILU_error (filename, current_position)
659 last_token := E_INTEGER
660 }
661 0[cC][0-7]+(_+[0-7]+)* {
662 }
663 0[cC](_+[0-7]+)+ {
664 -- Syntax error: an underscore may not be
665 -- the first character of an integer.
666 set_syntax_error
667 error_handler.report_SIFU_error (filename, current_position)
668 last_token := E_INTEGER
669 }
670 0[cC]([0-7]+_+)+ {
671 -- Syntax error: an underscore may not be
672 -- the last character of an integer.
673 set_syntax_error
674 error_handler.report_SILU_error (filename, current_position)
675 last_token := E_INTEGER
676 }
677 0[bB][0-1]+(_+[0-1]+)* {
678 }
679 0[bB](_+[0-1]+)+ {
680 -- Syntax error: an underscore may not be
681 -- the first character of an integer.
682 set_syntax_error
683 error_handler.report_SIFU_error (filename, current_position)
684 last_token := E_INTEGER
685 }
686 0[bB]([0-1]+_+)+ {
687 -- Syntax error: an underscore may not be
688 -- the last character of an integer.
689 set_syntax_error
690 error_handler.report_SILU_error (filename, current_position)
691 last_token := E_INTEGER
692 }
693
694
695 ---------/** Eiffel reals **/---------------------------------------------------
696
697 [0-9]+\./[^.0-9] |
698 [0-9]+\.[0-9]*[eE][+-]?[0-9]+ |
699 [0-9]*\.[0-9]+([eE][+-]?[0-9]+)? {
700 }
701 [0-9]+(_+[0-9]+)+\./[^.0-9] |
702 [0-9]+(_+[0-9]+)*\.([0-9]+(_+[0-9]+)*)?[eE][+-]?[0-9]+(_+[0-9]+)* |
703 ([0-9]+(_+[0-9]+)*)?\.[0-9]+(_+[0-9]+)*([eE][+-]?[0-9]+(_+[0-9]+)*)? {
704 }
705
706 -- The first and fourth expressions use a trailing context
707 -- to make sure that an integer followed by two dots is
708 -- not recognized as a real followed by a dot.
709
710 --------------------------------------------------------------------------------
711
712 <<EOF>> terminate
713 . {
714 last_token := E_UNKNOWN
715 }
716
717 --------------------------------------------------------------------------------
718 %%
719
720 end

  ViewVC Help
Powered by ViewVC 1.1.23