9e56c836230d480ded50e609830be24ace40b113
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
(text
: String, 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)
226 redef fun parser_index
: Int
231 init init_tk
(loc
: Location)
238 redef class TKwreadable
239 redef fun parser_index
: Int
244 init init_tk
(loc
: Location)
246 _text
= once
"readable"
251 redef class TKwwritable
252 redef fun parser_index
: Int
257 init init_tk
(loc
: Location)
259 _text
= once
"writable"
265 redef fun parser_index
: Int
270 init init_tk
(loc
: Location)
277 redef class TKwintern
278 redef fun parser_index
: Int
283 init init_tk
(loc
: Location)
285 _text
= once
"intern"
290 redef class TKwextern
291 redef fun parser_index
: Int
296 init init_tk
(loc
: Location)
298 _text
= once
"extern"
303 redef class TKwprotected
304 redef fun parser_index
: Int
309 init init_tk
(loc
: Location)
311 _text
= once
"protected"
316 redef class TKwprivate
317 redef fun parser_index
: Int
322 init init_tk
(loc
: Location)
324 _text
= once
"private"
329 redef class TKwintrude
330 redef fun parser_index
: Int
335 init init_tk
(loc
: Location)
337 _text
= once
"intrude"
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)
447 redef fun parser_index
: Int
452 init init_tk
(loc
: Location)
459 redef class TKwreturn
460 redef fun parser_index
: Int
465 init init_tk
(loc
: Location)
467 _text
= once
"return"
472 redef class TKwcontinue
473 redef fun parser_index
: Int
478 init init_tk
(loc
: Location)
480 _text
= once
"continue"
486 redef fun parser_index
: Int
491 init init_tk
(loc
: Location)
499 redef fun parser_index
: Int
504 init init_tk
(loc
: Location)
511 redef class TKwassert
512 redef fun parser_index
: Int
517 init init_tk
(loc
: Location)
519 _text
= once
"assert"
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)
629 redef fun parser_index
: Int
634 init init_tk
(loc
: Location)
642 redef fun parser_index
: Int
647 init init_tk
(loc
: Location)
654 redef class TKwnullable
655 redef fun parser_index
: Int
660 init init_tk
(loc
: Location)
662 _text
= once
"nullable"
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)
798 redef fun parser_index
: Int
803 init init_tk
(loc
: Location)
810 redef class TDotdotdot
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)
980 redef fun parser_index
: Int
985 init init_tk
(loc
: Location)
992 redef class TStarship
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_text
= text
.substring
(0, accept_length
)
1416 var token
= new TKwmeth.init_tk
(token_text
, location
)
1417 push_back
(accept_length
)
1422 if accept_token
== 12 then
1423 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1424 var token
= new TKwtype.init_tk
(location
)
1425 push_back
(accept_length
)
1430 if accept_token
== 13 then
1431 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1432 var token
= new TKwattr.init_tk
(location
)
1433 push_back
(accept_length
)
1438 if accept_token
== 14 then
1439 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1440 var token
= new TKwinit.init_tk
(location
)
1441 push_back
(accept_length
)
1446 if accept_token
== 15 then
1447 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1448 var token
= new TKwredef.init_tk
(location
)
1449 push_back
(accept_length
)
1454 if accept_token
== 16 then
1455 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1456 var token
= new TKwis.init_tk
(location
)
1457 push_back
(accept_length
)
1462 if accept_token
== 17 then
1463 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1464 var token
= new TKwdo.init_tk
(location
)
1465 push_back
(accept_length
)
1470 if accept_token
== 18 then
1471 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1472 var token
= new TKwreadable.init_tk
(location
)
1473 push_back
(accept_length
)
1478 if accept_token
== 19 then
1479 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1480 var token
= new TKwwritable.init_tk
(location
)
1481 push_back
(accept_length
)
1486 if accept_token
== 20 then
1487 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1488 var token
= new TKwvar.init_tk
(location
)
1489 push_back
(accept_length
)
1494 if accept_token
== 21 then
1495 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1496 var token
= new TKwintern.init_tk
(location
)
1497 push_back
(accept_length
)
1502 if accept_token
== 22 then
1503 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1504 var token
= new TKwextern.init_tk
(location
)
1505 push_back
(accept_length
)
1510 if accept_token
== 23 then
1511 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1512 var token
= new TKwprotected.init_tk
(location
)
1513 push_back
(accept_length
)
1518 if accept_token
== 24 then
1519 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1520 var token
= new TKwprivate.init_tk
(location
)
1521 push_back
(accept_length
)
1526 if accept_token
== 25 then
1527 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1528 var token
= new TKwintrude.init_tk
(location
)
1529 push_back
(accept_length
)
1534 if accept_token
== 26 then
1535 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1536 var token
= new TKwif.init_tk
(location
)
1537 push_back
(accept_length
)
1542 if accept_token
== 27 then
1543 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1544 var token
= new TKwthen.init_tk
(location
)
1545 push_back
(accept_length
)
1550 if accept_token
== 28 then
1551 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1552 var token
= new TKwelse.init_tk
(location
)
1553 push_back
(accept_length
)
1558 if accept_token
== 29 then
1559 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1560 var token
= new TKwwhile.init_tk
(location
)
1561 push_back
(accept_length
)
1566 if accept_token
== 30 then
1567 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1568 var token
= new TKwfor.init_tk
(location
)
1569 push_back
(accept_length
)
1574 if accept_token
== 31 then
1575 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1576 var token
= new TKwin.init_tk
(location
)
1577 push_back
(accept_length
)
1582 if accept_token
== 32 then
1583 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1584 var token
= new TKwand.init_tk
(location
)
1585 push_back
(accept_length
)
1590 if accept_token
== 33 then
1591 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1592 var token
= new TKwor.init_tk
(location
)
1593 push_back
(accept_length
)
1598 if accept_token
== 34 then
1599 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1600 var token
= new TKwnot.init_tk
(location
)
1601 push_back
(accept_length
)
1606 if accept_token
== 35 then
1607 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1608 var token
= new TKwreturn.init_tk
(location
)
1609 push_back
(accept_length
)
1614 if accept_token
== 36 then
1615 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1616 var token
= new TKwcontinue.init_tk
(location
)
1617 push_back
(accept_length
)
1622 if accept_token
== 37 then
1623 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1624 var token
= new TKwbreak.init_tk
(location
)
1625 push_back
(accept_length
)
1630 if accept_token
== 38 then
1631 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1632 var token
= new TKwabort.init_tk
(location
)
1633 push_back
(accept_length
)
1638 if accept_token
== 39 then
1639 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1640 var token
= new TKwassert.init_tk
(location
)
1641 push_back
(accept_length
)
1646 if accept_token
== 40 then
1647 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1648 var token
= new TKwnew.init_tk
(location
)
1649 push_back
(accept_length
)
1654 if accept_token
== 41 then
1655 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1656 var token
= new TKwisa.init_tk
(location
)
1657 push_back
(accept_length
)
1662 if accept_token
== 42 then
1663 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1664 var token
= new TKwonce.init_tk
(location
)
1665 push_back
(accept_length
)
1670 if accept_token
== 43 then
1671 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1672 var token
= new TKwsuper.init_tk
(location
)
1673 push_back
(accept_length
)
1678 if accept_token
== 44 then
1679 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1680 var token
= new TKwself.init_tk
(location
)
1681 push_back
(accept_length
)
1686 if accept_token
== 45 then
1687 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1688 var token
= new TKwtrue.init_tk
(location
)
1689 push_back
(accept_length
)
1694 if accept_token
== 46 then
1695 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1696 var token
= new TKwfalse.init_tk
(location
)
1697 push_back
(accept_length
)
1702 if accept_token
== 47 then
1703 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1704 var token
= new TKwnull.init_tk
(location
)
1705 push_back
(accept_length
)
1710 if accept_token
== 48 then
1711 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1712 var token
= new TKwas.init_tk
(location
)
1713 push_back
(accept_length
)
1718 if accept_token
== 49 then
1719 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1720 var token
= new TKwwith.init_tk
(location
)
1721 push_back
(accept_length
)
1726 if accept_token
== 50 then
1727 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1728 var token
= new TKwnullable.init_tk
(location
)
1729 push_back
(accept_length
)
1734 if accept_token
== 51 then
1735 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1736 var token
= new TKwisset.init_tk
(location
)
1737 push_back
(accept_length
)
1742 if accept_token
== 52 then
1743 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1744 var token
= new TOpar.init_tk
(location
)
1745 push_back
(accept_length
)
1750 if accept_token
== 53 then
1751 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1752 var token
= new TCpar.init_tk
(location
)
1753 push_back
(accept_length
)
1758 if accept_token
== 54 then
1759 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1760 var token
= new TObra.init_tk
(location
)
1761 push_back
(accept_length
)
1766 if accept_token
== 55 then
1767 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1768 var token
= new TCbra.init_tk
(location
)
1769 push_back
(accept_length
)
1774 if accept_token
== 56 then
1775 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1776 var token
= new TComma.init_tk
(location
)
1777 push_back
(accept_length
)
1782 if accept_token
== 57 then
1783 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1784 var token
= new TColumn.init_tk
(location
)
1785 push_back
(accept_length
)
1790 if accept_token
== 58 then
1791 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1792 var token
= new TQuad.init_tk
(location
)
1793 push_back
(accept_length
)
1798 if accept_token
== 59 then
1799 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1800 var token
= new TAssign.init_tk
(location
)
1801 push_back
(accept_length
)
1806 if accept_token
== 60 then
1807 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1808 var token
= new TPluseq.init_tk
(location
)
1809 push_back
(accept_length
)
1814 if accept_token
== 61 then
1815 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1816 var token
= new TMinuseq.init_tk
(location
)
1817 push_back
(accept_length
)
1822 if accept_token
== 62 then
1823 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1824 var token
= new TDotdotdot.init_tk
(location
)
1825 push_back
(accept_length
)
1830 if accept_token
== 63 then
1831 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1832 var token
= new TDotdot.init_tk
(location
)
1833 push_back
(accept_length
)
1838 if accept_token
== 64 then
1839 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1840 var token
= new TDot.init_tk
(location
)
1841 push_back
(accept_length
)
1846 if accept_token
== 65 then
1847 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1848 var token
= new TPlus.init_tk
(location
)
1849 push_back
(accept_length
)
1854 if accept_token
== 66 then
1855 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1856 var token
= new TMinus.init_tk
(location
)
1857 push_back
(accept_length
)
1862 if accept_token
== 67 then
1863 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1864 var token
= new TStar.init_tk
(location
)
1865 push_back
(accept_length
)
1870 if accept_token
== 68 then
1871 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1872 var token
= new TSlash.init_tk
(location
)
1873 push_back
(accept_length
)
1878 if accept_token
== 69 then
1879 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1880 var token
= new TPercent.init_tk
(location
)
1881 push_back
(accept_length
)
1886 if accept_token
== 70 then
1887 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1888 var token
= new TEq.init_tk
(location
)
1889 push_back
(accept_length
)
1894 if accept_token
== 71 then
1895 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1896 var token
= new TNe.init_tk
(location
)
1897 push_back
(accept_length
)
1902 if accept_token
== 72 then
1903 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1904 var token
= new TLt.init_tk
(location
)
1905 push_back
(accept_length
)
1910 if accept_token
== 73 then
1911 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1912 var token
= new TLe.init_tk
(location
)
1913 push_back
(accept_length
)
1918 if accept_token
== 74 then
1919 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1920 var token
= new TGt.init_tk
(location
)
1921 push_back
(accept_length
)
1926 if accept_token
== 75 then
1927 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1928 var token
= new TGe.init_tk
(location
)
1929 push_back
(accept_length
)
1934 if accept_token
== 76 then
1935 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1936 var token
= new TStarship.init_tk
(location
)
1937 push_back
(accept_length
)
1942 if accept_token
== 77 then
1943 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1944 var token_text
= text
.substring
(0, accept_length
)
1945 var token
= new TClassid.init_tk
(token_text
, location
)
1946 push_back
(accept_length
)
1951 if accept_token
== 78 then
1952 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1953 var token_text
= text
.substring
(0, accept_length
)
1954 var token
= new TId.init_tk
(token_text
, location
)
1955 push_back
(accept_length
)
1960 if accept_token
== 79 then
1961 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1962 var token_text
= text
.substring
(0, accept_length
)
1963 var token
= new TAttrid.init_tk
(token_text
, location
)
1964 push_back
(accept_length
)
1969 if accept_token
== 80 then
1970 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1971 var token_text
= text
.substring
(0, accept_length
)
1972 var token
= new TNumber.init_tk
(token_text
, location
)
1973 push_back
(accept_length
)
1978 if accept_token
== 81 then
1979 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1980 var token_text
= text
.substring
(0, accept_length
)
1981 var token
= new TFloat.init_tk
(token_text
, location
)
1982 push_back
(accept_length
)
1987 if accept_token
== 82 then
1988 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1989 var token_text
= text
.substring
(0, accept_length
)
1990 var token
= new TChar.init_tk
(token_text
, location
)
1991 push_back
(accept_length
)
1996 if accept_token
== 83 then
1997 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1998 var token_text
= text
.substring
(0, accept_length
)
1999 var token
= new TString.init_tk
(token_text
, location
)
2000 push_back
(accept_length
)
2005 if accept_token
== 84 then
2006 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2007 var token_text
= text
.substring
(0, accept_length
)
2008 var token
= new TStartString.init_tk
(token_text
, location
)
2009 push_back
(accept_length
)
2014 if accept_token
== 85 then
2015 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2016 var token_text
= text
.substring
(0, accept_length
)
2017 var token
= new TMidString.init_tk
(token_text
, location
)
2018 push_back
(accept_length
)
2023 if accept_token
== 86 then
2024 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2025 var token_text
= text
.substring
(0, accept_length
)
2026 var token
= new TEndString.init_tk
(token_text
, location
)
2027 push_back
(accept_length
)
2033 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2034 if text
.length
> 0 then
2035 var token
= new PError.init_error
("Unknown token: {text}", location
)
2038 var token
= new EOF(location
)
2047 # Read the next character.
2048 # The character is read from the stream of from the pushback buffer.
2049 private fun get_char
: Int
2057 var sp
= _stream_pos
2059 var res
= _stream_buf
[_stream_pos
]
2060 _stream_pos
= sp
- 1
2063 result
= _stream
.read_char
2066 if result
== -1 then
2073 # Unread some characters.
2074 # Unread characters are stored in the pushback buffer.
2075 private fun push_back
(accept_length
: Int)
2077 var length
= _text
.length
2079 while i
>= accept_length
do
2081 _stream_pos
= _stream_pos
+ 1
2082 _stream_buf
[_stream_pos
] = _text
[i
]
2087 var _goto_table
: Array[Array[Array[Array[Int]]]]
2088 private fun build_goto_table
2090 _goto_table
= once
[
3298 private fun nil_array
: Array[Array[Int]]
3300 return once
new Array[Array[Int]]
3303 var _accept_table
: Array[Array[Int]]
3304 private fun build_accept_table
do
3305 _accept_table
= once
[
3307 -1 , 0 , 1 , 1 , 0 , -1 , -1 , -1 , 69 , -1 , 52 , 53 , 67 , 65 , 56 , 66 , 64 , 68 , 80 , 57 , 72 , 59 , 74 , 77 , 54 , 55 , -1 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , -1 , 1 , 71 , -1 , 83 , -1 , 84 , -1 , 2 , 2 , -1 , 82 , 60 , 61 , 63 , 81 , -1 , 58 , 73 , 70 , 75 , 77 , 77 , 77 , 77 , 79 , 78 , 78 , 78 , 78 , 78 , 78 , 48 , 78 , 78 , 78 , 78 , 17 , 78 , 78 , 78 , 78 , 78 , 78 , 26 , 78 , 31 , 16 , 78 , 78 , 78 , 78 , 78 , 33 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , -1 , 86 , -1 , 85 , -1 , 2 , 62 , 76 , 79 , 79 , 79 , 79 , 78 , 78 , 32 , 78 , 78 , 78 , 78 , 78 , 78 , 10 , 78 , 78 , 30 , 11 , 78 , 78 , 78 , 41 , 78 , 78 , 40 , 34 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 20 , 78 , 78 , 78 , -1 , 78 , 78 , 78 , 13 , 78 , 78 , 78 , 28 , 78 , 78 , 78 , 14 , 78 , 78 , 78 , 11 , 47 , 42 , 78 , 78 , 78 , 78 , 78 , 78 , 44 , 78 , 78 , 27 , 45 , 12 , 78 , 78 , 49 , 78 , 38 , 78 , 78 , 37 , 5 , 78 , 78 , 46 , 78 , 78 , 78 , 51 , 78 , 78 , 78 , 78 , 78 , 15 , 78 , 78 , 43 , 78 , 29 , 78 , 78 , 39 , 78 , 22 , 4 , 78 , 21 , 78 , 78 , 78 , 78 , 78 , 78 , 35 , 78 , 78 , 78 , 78 , 78 , 78 , 25 , 78 , 3 , 24 , 78 , 78 , 9 , 78 , 78 , 6 , 36 , 78 , 50 , 78 , 18 , 78 , 19 , 7 , 23 , 8