1 # Lexer and its tokens.
2 # This file was generated by SableCC (http://www.sablecc.org/).
5 intrude import parser_nodes
8 readable writable var _text
: String
10 fun parser_index
: Int is abstract
12 redef fun to_s
: String do
18 redef fun parser_index
: Int
23 init init_tk
(text
: String, loc
: Location)
31 redef fun parser_index
: Int
36 init init_tk
(text
: String, loc
: Location)
43 redef class TKwpackage
44 redef fun parser_index
: Int
49 init init_tk
(loc
: Location)
51 _text
= once
"package"
57 redef fun parser_index
: Int
62 init init_tk
(loc
: Location)
70 redef fun parser_index
: Int
75 init init_tk
(loc
: Location)
82 redef class TKwabstract
83 redef fun parser_index
: Int
88 init init_tk
(loc
: Location)
90 _text
= once
"abstract"
95 redef class TKwinterface
96 redef fun parser_index
: Int
101 init init_tk
(loc
: Location)
103 _text
= once
"interface"
108 redef class TKwuniversal
109 redef fun parser_index
: Int
114 init init_tk
(loc
: Location)
116 _text
= once
"universal"
121 redef class TKwspecial
122 redef fun parser_index
: Int
127 init init_tk
(loc
: Location)
129 _text
= once
"special"
135 redef fun parser_index
: Int
140 init init_tk
(loc
: Location)
148 redef fun parser_index
: Int
153 init init_tk
(loc
: Location)
161 redef fun parser_index
: Int
166 init init_tk
(loc
: Location)
174 redef fun parser_index
: Int
179 init init_tk
(loc
: Location)
187 redef fun parser_index
: Int
192 init init_tk
(loc
: Location)
200 redef fun parser_index
: Int
205 init init_tk
(loc
: Location)
213 redef fun parser_index
: Int
218 init init_tk
(loc
: Location)
225 redef class TKwreadable
226 redef fun parser_index
: Int
231 init init_tk
(loc
: Location)
233 _text
= once
"readable"
238 redef class TKwwritable
239 redef fun parser_index
: Int
244 init init_tk
(loc
: Location)
246 _text
= once
"writable"
252 redef fun parser_index
: Int
257 init init_tk
(loc
: Location)
264 redef class TKwintern
265 redef fun parser_index
: Int
270 init init_tk
(loc
: Location)
272 _text
= once
"intern"
277 redef class TKwextern
278 redef fun parser_index
: Int
283 init init_tk
(loc
: Location)
285 _text
= once
"extern"
290 redef class TKwprotected
291 redef fun parser_index
: Int
296 init init_tk
(loc
: Location)
298 _text
= once
"protected"
303 redef class TKwprivate
304 redef fun parser_index
: Int
309 init init_tk
(loc
: Location)
311 _text
= once
"private"
316 redef class TKwintrude
317 redef fun parser_index
: Int
322 init init_tk
(loc
: Location)
324 _text
= once
"intrude"
330 redef fun parser_index
: Int
335 init init_tk
(loc
: Location)
343 redef fun parser_index
: Int
348 init init_tk
(loc
: Location)
356 redef fun parser_index
: Int
361 init init_tk
(loc
: Location)
369 redef fun parser_index
: Int
374 init init_tk
(loc
: Location)
382 redef fun parser_index
: Int
387 init init_tk
(loc
: Location)
395 redef fun parser_index
: Int
400 init init_tk
(loc
: Location)
408 redef fun parser_index
: Int
413 init init_tk
(loc
: Location)
421 redef fun parser_index
: Int
426 init init_tk
(loc
: Location)
434 redef fun parser_index
: Int
439 init init_tk
(loc
: Location)
446 redef class TKwreturn
447 redef fun parser_index
: Int
452 init init_tk
(loc
: Location)
454 _text
= once
"return"
459 redef class TKwcontinue
460 redef fun parser_index
: Int
465 init init_tk
(loc
: Location)
467 _text
= once
"continue"
473 redef fun parser_index
: Int
478 init init_tk
(loc
: Location)
486 redef fun parser_index
: Int
491 init init_tk
(loc
: Location)
498 redef class TKwassert
499 redef fun parser_index
: Int
504 init init_tk
(loc
: Location)
506 _text
= once
"assert"
512 redef fun parser_index
: Int
517 init init_tk
(loc
: Location)
525 redef fun parser_index
: Int
530 init init_tk
(loc
: Location)
538 redef fun parser_index
: Int
543 init init_tk
(loc
: Location)
551 redef fun parser_index
: Int
556 init init_tk
(loc
: Location)
564 redef fun parser_index
: Int
569 init init_tk
(loc
: Location)
577 redef fun parser_index
: Int
582 init init_tk
(loc
: Location)
590 redef fun parser_index
: Int
595 init init_tk
(loc
: Location)
603 redef fun parser_index
: Int
608 init init_tk
(loc
: Location)
616 redef fun parser_index
: Int
621 init init_tk
(loc
: Location)
628 redef class TKwnullable
629 redef fun parser_index
: Int
634 init init_tk
(loc
: Location)
636 _text
= once
"nullable"
642 redef fun parser_index
: Int
647 init init_tk
(loc
: Location)
655 redef fun parser_index
: Int
660 init init_tk
(loc
: Location)
668 redef fun parser_index
: Int
673 init init_tk
(loc
: Location)
681 redef fun parser_index
: Int
686 init init_tk
(loc
: Location)
694 redef fun parser_index
: Int
699 init init_tk
(loc
: Location)
707 redef fun parser_index
: Int
712 init init_tk
(loc
: Location)
720 redef fun parser_index
: Int
725 init init_tk
(loc
: Location)
733 redef fun parser_index
: Int
738 init init_tk
(loc
: Location)
746 redef fun parser_index
: Int
751 init init_tk
(loc
: Location)
759 redef fun parser_index
: Int
764 init init_tk
(loc
: Location)
772 redef fun parser_index
: Int
777 init init_tk
(loc
: Location)
785 redef fun parser_index
: Int
790 init init_tk
(loc
: Location)
797 redef class TDotdotdot
798 redef fun parser_index
: Int
803 init init_tk
(loc
: Location)
811 redef fun parser_index
: Int
816 init init_tk
(loc
: Location)
824 redef fun parser_index
: Int
829 init init_tk
(loc
: Location)
837 redef fun parser_index
: Int
842 init init_tk
(loc
: Location)
850 redef fun parser_index
: Int
855 init init_tk
(loc
: Location)
863 redef fun parser_index
: Int
868 init init_tk
(loc
: Location)
876 redef fun parser_index
: Int
881 init init_tk
(loc
: Location)
889 redef fun parser_index
: Int
894 init init_tk
(loc
: Location)
902 redef fun parser_index
: Int
907 init init_tk
(loc
: Location)
915 redef fun parser_index
: Int
920 init init_tk
(loc
: Location)
928 redef fun parser_index
: Int
933 init init_tk
(loc
: Location)
941 redef fun parser_index
: Int
946 init init_tk
(loc
: Location)
954 redef fun parser_index
: Int
959 init init_tk
(loc
: Location)
967 redef fun parser_index
: Int
972 init init_tk
(loc
: Location)
979 redef class TStarship
980 redef fun parser_index
: Int
985 init init_tk
(loc
: Location)
993 redef fun parser_index
: Int
998 init init_tk
(loc
: Location)
1005 redef class TClassid
1006 redef fun parser_index
: Int
1011 init init_tk
(text
: String, loc
: Location)
1019 redef fun parser_index
: Int
1024 init init_tk
(text
: String, loc
: Location)
1032 redef fun parser_index
: Int
1037 init init_tk
(text
: String, loc
: Location)
1045 redef fun parser_index
: Int
1050 init init_tk
(text
: String, loc
: Location)
1058 redef fun parser_index
: Int
1063 init init_tk
(text
: String, loc
: Location)
1071 redef fun parser_index
: Int
1076 init init_tk
(text
: String, loc
: Location)
1084 redef fun parser_index
: Int
1089 init init_tk
(text
: String, loc
: Location)
1096 redef class TStartString
1097 redef fun parser_index
: Int
1102 init init_tk
(text
: String, loc
: Location)
1109 redef class TMidString
1110 redef fun parser_index
: Int
1115 init init_tk
(text
: String, loc
: Location)
1122 redef class TEndString
1123 redef fun parser_index
: Int
1128 init init_tk
(text
: String, loc
: Location)
1137 redef fun parser_index
: Int
1150 readable writable var _message
: String
1152 init init_error
(message
: String, loc
: Location)
1160 # The lexer extract NIT tokens from an input stream.
1161 # It is better user with the Parser
1164 var _token
: nullable Token
1166 # Lexer current state
1169 # Name of the stream (as given to tokens)
1170 readable var _filename
: String
1172 # Input stream where character are read
1173 var _stream
: IStream
1175 # Pushback buffer to store unread character
1176 var _stream_buf
: Buffer
1178 # Number of character stored in the pushback buffer
1179 var _stream_pos
: Int
1181 # Current line number in the input stream
1184 # Current column in the input stream
1187 # Was the last character a cariage-return?
1188 var _cr
: Bool = false
1190 # If the end of stream?
1191 var _eof
: Bool = false
1193 # Current working text read from the input stream
1196 # Constante state values
1197 private fun state_initial
: Int do return 0 end
1199 # Create a new lexer for a stream (and a name)
1200 init(stream
: IStream, fname
: String)
1206 _stream_buf
= new Buffer
1211 # Give the next token (but do not consume it)
1214 while _token
== null do
1217 return _token
.as(not null)
1220 # Give and consume the next token
1224 while result
== null do
1228 return result
.as(not null)
1231 # Get a token, or null if it is discarded
1232 private fun get_token
: nullable Token
1236 var start_pos
= _pos
1237 var start_line
= _line
1239 var accept_state
= -1
1240 var accept_token
= -1
1241 var accept_length
= -1
1243 var accept_line
= -1
1245 var goto_table
= _goto_table
[_state
]
1246 var accept
= _accept_table
[_state
]
1264 else if c
== 13 then
1275 var first_loop
= true # aka until
1276 while dfa_state
< -1 or first_loop
do
1277 var old_state
= dfa_state
1278 if dfa_state
< -1 then
1279 old_state
= -2 - dfa_state
1284 var tmp0
= goto_table
[old_state
]
1286 var high
= tmp0
.length
- 1
1289 var tmp1
= tmp0
.intern_items
1290 while low
<= high
do
1291 var middle
= (low
+ high
) / 2
1292 var tmp2
= tmp1
[middle
].intern_items
1296 else if c
> tmp2
[1] then
1300 low
= high
+ 1 # aka break
1304 first_loop
= false # aka until
1314 if dfa_state
>= 0 then
1315 if accept
[dfa_state
] != -1 then
1316 accept_state
= dfa_state
1317 accept_token
= accept
[dfa_state
]
1318 accept_length
= text
.length
1323 if accept_state
!= -1 then
1324 if accept_token
== 0 then
1325 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1326 push_back
(accept_length
)
1331 if accept_token
== 1 then
1332 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1333 var token_text
= text
.substring
(0, accept_length
)
1334 var token
= new TEol.init_tk
(token_text
, location
)
1335 push_back
(accept_length
)
1340 if accept_token
== 2 then
1341 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1342 var token_text
= text
.substring
(0, accept_length
)
1343 var token
= new TComment.init_tk
(token_text
, location
)
1344 push_back
(accept_length
)
1349 if accept_token
== 3 then
1350 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1351 var token
= new TKwpackage.init_tk
(location
)
1352 push_back
(accept_length
)
1357 if accept_token
== 4 then
1358 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1359 var token
= new TKwimport.init_tk
(location
)
1360 push_back
(accept_length
)
1365 if accept_token
== 5 then
1366 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1367 var token
= new TKwclass.init_tk
(location
)
1368 push_back
(accept_length
)
1373 if accept_token
== 6 then
1374 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1375 var token
= new TKwabstract.init_tk
(location
)
1376 push_back
(accept_length
)
1381 if accept_token
== 7 then
1382 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1383 var token
= new TKwinterface.init_tk
(location
)
1384 push_back
(accept_length
)
1389 if accept_token
== 8 then
1390 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1391 var token
= new TKwuniversal.init_tk
(location
)
1392 push_back
(accept_length
)
1397 if accept_token
== 9 then
1398 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1399 var token
= new TKwspecial.init_tk
(location
)
1400 push_back
(accept_length
)
1405 if accept_token
== 10 then
1406 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1407 var token
= new TKwend.init_tk
(location
)
1408 push_back
(accept_length
)
1413 if accept_token
== 11 then
1414 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1415 var token
= new TKwmeth.init_tk
(location
)
1416 push_back
(accept_length
)
1421 if accept_token
== 12 then
1422 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1423 var token
= new TKwtype.init_tk
(location
)
1424 push_back
(accept_length
)
1429 if accept_token
== 13 then
1430 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1431 var token
= new TKwinit.init_tk
(location
)
1432 push_back
(accept_length
)
1437 if accept_token
== 14 then
1438 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1439 var token
= new TKwredef.init_tk
(location
)
1440 push_back
(accept_length
)
1445 if accept_token
== 15 then
1446 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1447 var token
= new TKwis.init_tk
(location
)
1448 push_back
(accept_length
)
1453 if accept_token
== 16 then
1454 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1455 var token
= new TKwdo.init_tk
(location
)
1456 push_back
(accept_length
)
1461 if accept_token
== 17 then
1462 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1463 var token
= new TKwreadable.init_tk
(location
)
1464 push_back
(accept_length
)
1469 if accept_token
== 18 then
1470 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1471 var token
= new TKwwritable.init_tk
(location
)
1472 push_back
(accept_length
)
1477 if accept_token
== 19 then
1478 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1479 var token
= new TKwvar.init_tk
(location
)
1480 push_back
(accept_length
)
1485 if accept_token
== 20 then
1486 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1487 var token
= new TKwintern.init_tk
(location
)
1488 push_back
(accept_length
)
1493 if accept_token
== 21 then
1494 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1495 var token
= new TKwextern.init_tk
(location
)
1496 push_back
(accept_length
)
1501 if accept_token
== 22 then
1502 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1503 var token
= new TKwprotected.init_tk
(location
)
1504 push_back
(accept_length
)
1509 if accept_token
== 23 then
1510 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1511 var token
= new TKwprivate.init_tk
(location
)
1512 push_back
(accept_length
)
1517 if accept_token
== 24 then
1518 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1519 var token
= new TKwintrude.init_tk
(location
)
1520 push_back
(accept_length
)
1525 if accept_token
== 25 then
1526 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1527 var token
= new TKwif.init_tk
(location
)
1528 push_back
(accept_length
)
1533 if accept_token
== 26 then
1534 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1535 var token
= new TKwthen.init_tk
(location
)
1536 push_back
(accept_length
)
1541 if accept_token
== 27 then
1542 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1543 var token
= new TKwelse.init_tk
(location
)
1544 push_back
(accept_length
)
1549 if accept_token
== 28 then
1550 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1551 var token
= new TKwwhile.init_tk
(location
)
1552 push_back
(accept_length
)
1557 if accept_token
== 29 then
1558 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1559 var token
= new TKwfor.init_tk
(location
)
1560 push_back
(accept_length
)
1565 if accept_token
== 30 then
1566 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1567 var token
= new TKwin.init_tk
(location
)
1568 push_back
(accept_length
)
1573 if accept_token
== 31 then
1574 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1575 var token
= new TKwand.init_tk
(location
)
1576 push_back
(accept_length
)
1581 if accept_token
== 32 then
1582 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1583 var token
= new TKwor.init_tk
(location
)
1584 push_back
(accept_length
)
1589 if accept_token
== 33 then
1590 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1591 var token
= new TKwnot.init_tk
(location
)
1592 push_back
(accept_length
)
1597 if accept_token
== 34 then
1598 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1599 var token
= new TKwreturn.init_tk
(location
)
1600 push_back
(accept_length
)
1605 if accept_token
== 35 then
1606 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1607 var token
= new TKwcontinue.init_tk
(location
)
1608 push_back
(accept_length
)
1613 if accept_token
== 36 then
1614 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1615 var token
= new TKwbreak.init_tk
(location
)
1616 push_back
(accept_length
)
1621 if accept_token
== 37 then
1622 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1623 var token
= new TKwabort.init_tk
(location
)
1624 push_back
(accept_length
)
1629 if accept_token
== 38 then
1630 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1631 var token
= new TKwassert.init_tk
(location
)
1632 push_back
(accept_length
)
1637 if accept_token
== 39 then
1638 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1639 var token
= new TKwnew.init_tk
(location
)
1640 push_back
(accept_length
)
1645 if accept_token
== 40 then
1646 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1647 var token
= new TKwisa.init_tk
(location
)
1648 push_back
(accept_length
)
1653 if accept_token
== 41 then
1654 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1655 var token
= new TKwonce.init_tk
(location
)
1656 push_back
(accept_length
)
1661 if accept_token
== 42 then
1662 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1663 var token
= new TKwsuper.init_tk
(location
)
1664 push_back
(accept_length
)
1669 if accept_token
== 43 then
1670 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1671 var token
= new TKwself.init_tk
(location
)
1672 push_back
(accept_length
)
1677 if accept_token
== 44 then
1678 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1679 var token
= new TKwtrue.init_tk
(location
)
1680 push_back
(accept_length
)
1685 if accept_token
== 45 then
1686 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1687 var token
= new TKwfalse.init_tk
(location
)
1688 push_back
(accept_length
)
1693 if accept_token
== 46 then
1694 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1695 var token
= new TKwnull.init_tk
(location
)
1696 push_back
(accept_length
)
1701 if accept_token
== 47 then
1702 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1703 var token
= new TKwas.init_tk
(location
)
1704 push_back
(accept_length
)
1709 if accept_token
== 48 then
1710 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1711 var token
= new TKwnullable.init_tk
(location
)
1712 push_back
(accept_length
)
1717 if accept_token
== 49 then
1718 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1719 var token
= new TKwisset.init_tk
(location
)
1720 push_back
(accept_length
)
1725 if accept_token
== 50 then
1726 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1727 var token
= new TKwlabel.init_tk
(location
)
1728 push_back
(accept_length
)
1733 if accept_token
== 51 then
1734 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1735 var token
= new TOpar.init_tk
(location
)
1736 push_back
(accept_length
)
1741 if accept_token
== 52 then
1742 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1743 var token
= new TCpar.init_tk
(location
)
1744 push_back
(accept_length
)
1749 if accept_token
== 53 then
1750 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1751 var token
= new TObra.init_tk
(location
)
1752 push_back
(accept_length
)
1757 if accept_token
== 54 then
1758 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1759 var token
= new TCbra.init_tk
(location
)
1760 push_back
(accept_length
)
1765 if accept_token
== 55 then
1766 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1767 var token
= new TComma.init_tk
(location
)
1768 push_back
(accept_length
)
1773 if accept_token
== 56 then
1774 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1775 var token
= new TColumn.init_tk
(location
)
1776 push_back
(accept_length
)
1781 if accept_token
== 57 then
1782 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1783 var token
= new TQuad.init_tk
(location
)
1784 push_back
(accept_length
)
1789 if accept_token
== 58 then
1790 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1791 var token
= new TAssign.init_tk
(location
)
1792 push_back
(accept_length
)
1797 if accept_token
== 59 then
1798 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1799 var token
= new TPluseq.init_tk
(location
)
1800 push_back
(accept_length
)
1805 if accept_token
== 60 then
1806 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1807 var token
= new TMinuseq.init_tk
(location
)
1808 push_back
(accept_length
)
1813 if accept_token
== 61 then
1814 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1815 var token
= new TDotdotdot.init_tk
(location
)
1816 push_back
(accept_length
)
1821 if accept_token
== 62 then
1822 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1823 var token
= new TDotdot.init_tk
(location
)
1824 push_back
(accept_length
)
1829 if accept_token
== 63 then
1830 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1831 var token
= new TDot.init_tk
(location
)
1832 push_back
(accept_length
)
1837 if accept_token
== 64 then
1838 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1839 var token
= new TPlus.init_tk
(location
)
1840 push_back
(accept_length
)
1845 if accept_token
== 65 then
1846 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1847 var token
= new TMinus.init_tk
(location
)
1848 push_back
(accept_length
)
1853 if accept_token
== 66 then
1854 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1855 var token
= new TStar.init_tk
(location
)
1856 push_back
(accept_length
)
1861 if accept_token
== 67 then
1862 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1863 var token
= new TSlash.init_tk
(location
)
1864 push_back
(accept_length
)
1869 if accept_token
== 68 then
1870 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1871 var token
= new TPercent.init_tk
(location
)
1872 push_back
(accept_length
)
1877 if accept_token
== 69 then
1878 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1879 var token
= new TEq.init_tk
(location
)
1880 push_back
(accept_length
)
1885 if accept_token
== 70 then
1886 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1887 var token
= new TNe.init_tk
(location
)
1888 push_back
(accept_length
)
1893 if accept_token
== 71 then
1894 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1895 var token
= new TLt.init_tk
(location
)
1896 push_back
(accept_length
)
1901 if accept_token
== 72 then
1902 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1903 var token
= new TLe.init_tk
(location
)
1904 push_back
(accept_length
)
1909 if accept_token
== 73 then
1910 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1911 var token
= new TGt.init_tk
(location
)
1912 push_back
(accept_length
)
1917 if accept_token
== 74 then
1918 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1919 var token
= new TGe.init_tk
(location
)
1920 push_back
(accept_length
)
1925 if accept_token
== 75 then
1926 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1927 var token
= new TStarship.init_tk
(location
)
1928 push_back
(accept_length
)
1933 if accept_token
== 76 then
1934 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1935 var token
= new TBang.init_tk
(location
)
1936 push_back
(accept_length
)
1941 if accept_token
== 77 then
1942 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1943 var token_text
= text
.substring
(0, accept_length
)
1944 var token
= new TClassid.init_tk
(token_text
, location
)
1945 push_back
(accept_length
)
1950 if accept_token
== 78 then
1951 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1952 var token_text
= text
.substring
(0, accept_length
)
1953 var token
= new TId.init_tk
(token_text
, location
)
1954 push_back
(accept_length
)
1959 if accept_token
== 79 then
1960 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1961 var token_text
= text
.substring
(0, accept_length
)
1962 var token
= new TAttrid.init_tk
(token_text
, location
)
1963 push_back
(accept_length
)
1968 if accept_token
== 80 then
1969 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1970 var token_text
= text
.substring
(0, accept_length
)
1971 var token
= new TNumber.init_tk
(token_text
, location
)
1972 push_back
(accept_length
)
1977 if accept_token
== 81 then
1978 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1979 var token_text
= text
.substring
(0, accept_length
)
1980 var token
= new TFloat.init_tk
(token_text
, location
)
1981 push_back
(accept_length
)
1986 if accept_token
== 82 then
1987 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1988 var token_text
= text
.substring
(0, accept_length
)
1989 var token
= new TChar.init_tk
(token_text
, location
)
1990 push_back
(accept_length
)
1995 if accept_token
== 83 then
1996 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1997 var token_text
= text
.substring
(0, accept_length
)
1998 var token
= new TString.init_tk
(token_text
, location
)
1999 push_back
(accept_length
)
2004 if accept_token
== 84 then
2005 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2006 var token_text
= text
.substring
(0, accept_length
)
2007 var token
= new TStartString.init_tk
(token_text
, location
)
2008 push_back
(accept_length
)
2013 if accept_token
== 85 then
2014 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2015 var token_text
= text
.substring
(0, accept_length
)
2016 var token
= new TMidString.init_tk
(token_text
, location
)
2017 push_back
(accept_length
)
2022 if accept_token
== 86 then
2023 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2024 var token_text
= text
.substring
(0, accept_length
)
2025 var token
= new TEndString.init_tk
(token_text
, location
)
2026 push_back
(accept_length
)
2032 var location
= new Location(_filename
, start_line
+ 1, start_line
+ 1, start_pos
+ 1, start_pos
+ 1)
2033 if text
.length
> 0 then
2034 var token
= new AError.init_error
("Syntax error: unknown token {text}.", location
)
2037 var token
= new EOF(location
)
2046 # Read the next character.
2047 # The character is read from the stream of from the pushback buffer.
2048 private fun get_char
: Int
2056 var sp
= _stream_pos
2058 var res
= _stream_buf
[_stream_pos
]
2059 _stream_pos
= sp
- 1
2062 result
= _stream
.read_char
2065 if result
== -1 then
2072 # Unread some characters.
2073 # Unread characters are stored in the pushback buffer.
2074 private fun push_back
(accept_length
: Int)
2076 var length
= _text
.length
2078 while i
>= accept_length
do
2080 _stream_pos
= _stream_pos
+ 1
2081 _stream_buf
[_stream_pos
] = _text
[i
]
2086 var _goto_table
: Array[Array[Array[Array[Int]]]]
2087 private fun build_goto_table
2089 _goto_table
= once
[
3275 private fun nil_array
: Array[Array[Int]]
3277 return once
new Array[Array[Int]]
3280 var _accept_table
: Array[Array[Int]]
3281 private fun build_accept_table
do
3282 _accept_table
= once
[
3284 -1,0,1,1,0,76,-1,-1,68,-1,51,52,66,64,55,65,63,67,80,56,71,58,73,77,53,54,-1,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,-1,1,70,-1,83,-1,84,-1,2,2,-1,82,59,60,62,81,-1,57,72,69,74,77,77,77,77,79,78,78,78,78,78,78,47,78,78,78,16,78,78,78,78,78,78,25,78,30,15,78,78,78,78,78,32,78,78,78,78,78,78,78,78,78,78,78,78,78,-1,86,-1,85,-1,2,61,75,79,79,79,79,78,78,31,78,78,78,78,78,10,78,78,29,11,78,78,78,40,78,78,39,33,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,19,78,78,-1,78,78,78,78,78,78,27,78,78,78,13,78,78,78,78,46,41,78,78,78,78,78,78,43,78,78,26,44,12,78,78,78,37,78,78,36,5,78,78,45,78,78,78,49,50,78,78,78,78,78,14,78,78,42,78,28,78,78,38,78,21,4,78,20,78,78,78,78,78,78,34,78,78,78,78,78,78,24,78,3,23,78,78,9,78,78,6,35,78,48,78,17,78,18,7,22,8