257b3050d148cead059c0b11316f3f350432a576
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)
811 redef fun parser_index
: Int
816 init init_tk
(loc
: Location)
823 redef class TDotdotdot
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)
993 redef fun parser_index
: Int
998 init init_tk
(loc
: Location)
1005 redef class TStarship
1006 redef fun parser_index
: Int
1011 init init_tk
(loc
: Location)
1018 redef class TClassid
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)
1097 redef fun parser_index
: Int
1102 init init_tk
(text
: String, loc
: Location)
1109 redef class TStartString
1110 redef fun parser_index
: Int
1115 init init_tk
(text
: String, loc
: Location)
1122 redef class TMidString
1123 redef fun parser_index
: Int
1128 init init_tk
(text
: String, loc
: Location)
1135 redef class TEndString
1136 redef fun parser_index
: Int
1141 init init_tk
(text
: String, loc
: Location)
1150 redef fun parser_index
: Int
1163 readable writable var _message
: String
1165 init init_error
(message
: String, loc
: Location)
1173 # The lexer extract NIT tokens from an input stream.
1174 # It is better user with the Parser
1177 var _token
: nullable Token
1179 # Lexer current state
1182 # Name of the stream (as given to tokens)
1183 readable var _filename
: String
1185 # Input stream where character are read
1186 var _stream
: IStream
1188 # Pushback buffer to store unread character
1189 var _stream_buf
: Buffer
1191 # Number of character stored in the pushback buffer
1192 var _stream_pos
: Int
1194 # Current line number in the input stream
1197 # Current column in the input stream
1200 # Was the last character a cariage-return?
1201 var _cr
: Bool = false
1203 # If the end of stream?
1204 var _eof
: Bool = false
1206 # Current working text read from the input stream
1209 # Constante state values
1210 private fun state_initial
: Int do return 0 end
1212 # Create a new lexer for a stream (and a name)
1213 init(stream
: IStream, fname
: String)
1219 _stream_buf
= new Buffer
1224 # Give the next token (but do not consume it)
1227 while _token
== null do
1230 return _token
.as(not null)
1233 # Give and consume the next token
1237 while result
== null do
1241 return result
.as(not null)
1244 # Get a token, or null if it is discarded
1245 private fun get_token
: nullable Token
1249 var start_pos
= _pos
1250 var start_line
= _line
1252 var accept_state
= -1
1253 var accept_token
= -1
1254 var accept_length
= -1
1256 var accept_line
= -1
1258 var goto_table
= _goto_table
[_state
]
1259 var accept
= _accept_table
[_state
]
1277 else if c
== 13 then
1288 var first_loop
= true # aka until
1289 while dfa_state
< -1 or first_loop
do
1290 var old_state
= dfa_state
1291 if dfa_state
< -1 then
1292 old_state
= -2 - dfa_state
1297 var tmp0
= goto_table
[old_state
]
1299 var high
= tmp0
.length
- 1
1302 var tmp1
= tmp0
.intern_items
1303 while low
<= high
do
1304 var middle
= (low
+ high
) / 2
1305 var tmp2
= tmp1
[middle
].intern_items
1309 else if c
> tmp2
[1] then
1313 low
= high
+ 1 # aka break
1317 first_loop
= false # aka until
1327 if dfa_state
>= 0 then
1328 if accept
[dfa_state
] != -1 then
1329 accept_state
= dfa_state
1330 accept_token
= accept
[dfa_state
]
1331 accept_length
= text
.length
1336 if accept_state
!= -1 then
1337 if accept_token
== 0 then
1338 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1339 push_back
(accept_length
)
1344 if accept_token
== 1 then
1345 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1346 var token_text
= text
.substring
(0, accept_length
)
1347 var token
= new TEol.init_tk
(token_text
, location
)
1348 push_back
(accept_length
)
1353 if accept_token
== 2 then
1354 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1355 var token_text
= text
.substring
(0, accept_length
)
1356 var token
= new TComment.init_tk
(token_text
, location
)
1357 push_back
(accept_length
)
1362 if accept_token
== 3 then
1363 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1364 var token
= new TKwpackage.init_tk
(location
)
1365 push_back
(accept_length
)
1370 if accept_token
== 4 then
1371 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1372 var token
= new TKwimport.init_tk
(location
)
1373 push_back
(accept_length
)
1378 if accept_token
== 5 then
1379 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1380 var token
= new TKwclass.init_tk
(location
)
1381 push_back
(accept_length
)
1386 if accept_token
== 6 then
1387 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1388 var token
= new TKwabstract.init_tk
(location
)
1389 push_back
(accept_length
)
1394 if accept_token
== 7 then
1395 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1396 var token
= new TKwinterface.init_tk
(location
)
1397 push_back
(accept_length
)
1402 if accept_token
== 8 then
1403 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1404 var token
= new TKwuniversal.init_tk
(location
)
1405 push_back
(accept_length
)
1410 if accept_token
== 9 then
1411 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1412 var token
= new TKwspecial.init_tk
(location
)
1413 push_back
(accept_length
)
1418 if accept_token
== 10 then
1419 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1420 var token
= new TKwend.init_tk
(location
)
1421 push_back
(accept_length
)
1426 if accept_token
== 11 then
1427 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1428 var token_text
= text
.substring
(0, accept_length
)
1429 var token
= new TKwmeth.init_tk
(token_text
, location
)
1430 push_back
(accept_length
)
1435 if accept_token
== 12 then
1436 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1437 var token
= new TKwtype.init_tk
(location
)
1438 push_back
(accept_length
)
1443 if accept_token
== 13 then
1444 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1445 var token
= new TKwattr.init_tk
(location
)
1446 push_back
(accept_length
)
1451 if accept_token
== 14 then
1452 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1453 var token
= new TKwinit.init_tk
(location
)
1454 push_back
(accept_length
)
1459 if accept_token
== 15 then
1460 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1461 var token
= new TKwredef.init_tk
(location
)
1462 push_back
(accept_length
)
1467 if accept_token
== 16 then
1468 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1469 var token
= new TKwis.init_tk
(location
)
1470 push_back
(accept_length
)
1475 if accept_token
== 17 then
1476 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1477 var token
= new TKwdo.init_tk
(location
)
1478 push_back
(accept_length
)
1483 if accept_token
== 18 then
1484 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1485 var token
= new TKwreadable.init_tk
(location
)
1486 push_back
(accept_length
)
1491 if accept_token
== 19 then
1492 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1493 var token
= new TKwwritable.init_tk
(location
)
1494 push_back
(accept_length
)
1499 if accept_token
== 20 then
1500 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1501 var token
= new TKwvar.init_tk
(location
)
1502 push_back
(accept_length
)
1507 if accept_token
== 21 then
1508 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1509 var token
= new TKwintern.init_tk
(location
)
1510 push_back
(accept_length
)
1515 if accept_token
== 22 then
1516 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1517 var token
= new TKwextern.init_tk
(location
)
1518 push_back
(accept_length
)
1523 if accept_token
== 23 then
1524 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1525 var token
= new TKwprotected.init_tk
(location
)
1526 push_back
(accept_length
)
1531 if accept_token
== 24 then
1532 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1533 var token
= new TKwprivate.init_tk
(location
)
1534 push_back
(accept_length
)
1539 if accept_token
== 25 then
1540 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1541 var token
= new TKwintrude.init_tk
(location
)
1542 push_back
(accept_length
)
1547 if accept_token
== 26 then
1548 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1549 var token
= new TKwif.init_tk
(location
)
1550 push_back
(accept_length
)
1555 if accept_token
== 27 then
1556 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1557 var token
= new TKwthen.init_tk
(location
)
1558 push_back
(accept_length
)
1563 if accept_token
== 28 then
1564 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1565 var token
= new TKwelse.init_tk
(location
)
1566 push_back
(accept_length
)
1571 if accept_token
== 29 then
1572 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1573 var token
= new TKwwhile.init_tk
(location
)
1574 push_back
(accept_length
)
1579 if accept_token
== 30 then
1580 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1581 var token
= new TKwfor.init_tk
(location
)
1582 push_back
(accept_length
)
1587 if accept_token
== 31 then
1588 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1589 var token
= new TKwin.init_tk
(location
)
1590 push_back
(accept_length
)
1595 if accept_token
== 32 then
1596 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1597 var token
= new TKwand.init_tk
(location
)
1598 push_back
(accept_length
)
1603 if accept_token
== 33 then
1604 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1605 var token
= new TKwor.init_tk
(location
)
1606 push_back
(accept_length
)
1611 if accept_token
== 34 then
1612 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1613 var token
= new TKwnot.init_tk
(location
)
1614 push_back
(accept_length
)
1619 if accept_token
== 35 then
1620 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1621 var token
= new TKwreturn.init_tk
(location
)
1622 push_back
(accept_length
)
1627 if accept_token
== 36 then
1628 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1629 var token
= new TKwcontinue.init_tk
(location
)
1630 push_back
(accept_length
)
1635 if accept_token
== 37 then
1636 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1637 var token
= new TKwbreak.init_tk
(location
)
1638 push_back
(accept_length
)
1643 if accept_token
== 38 then
1644 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1645 var token
= new TKwabort.init_tk
(location
)
1646 push_back
(accept_length
)
1651 if accept_token
== 39 then
1652 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1653 var token
= new TKwassert.init_tk
(location
)
1654 push_back
(accept_length
)
1659 if accept_token
== 40 then
1660 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1661 var token
= new TKwnew.init_tk
(location
)
1662 push_back
(accept_length
)
1667 if accept_token
== 41 then
1668 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1669 var token
= new TKwisa.init_tk
(location
)
1670 push_back
(accept_length
)
1675 if accept_token
== 42 then
1676 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1677 var token
= new TKwonce.init_tk
(location
)
1678 push_back
(accept_length
)
1683 if accept_token
== 43 then
1684 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1685 var token
= new TKwsuper.init_tk
(location
)
1686 push_back
(accept_length
)
1691 if accept_token
== 44 then
1692 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1693 var token
= new TKwself.init_tk
(location
)
1694 push_back
(accept_length
)
1699 if accept_token
== 45 then
1700 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1701 var token
= new TKwtrue.init_tk
(location
)
1702 push_back
(accept_length
)
1707 if accept_token
== 46 then
1708 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1709 var token
= new TKwfalse.init_tk
(location
)
1710 push_back
(accept_length
)
1715 if accept_token
== 47 then
1716 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1717 var token
= new TKwnull.init_tk
(location
)
1718 push_back
(accept_length
)
1723 if accept_token
== 48 then
1724 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1725 var token
= new TKwas.init_tk
(location
)
1726 push_back
(accept_length
)
1731 if accept_token
== 49 then
1732 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1733 var token
= new TKwwith.init_tk
(location
)
1734 push_back
(accept_length
)
1739 if accept_token
== 50 then
1740 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1741 var token
= new TKwnullable.init_tk
(location
)
1742 push_back
(accept_length
)
1747 if accept_token
== 51 then
1748 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1749 var token
= new TKwisset.init_tk
(location
)
1750 push_back
(accept_length
)
1755 if accept_token
== 52 then
1756 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1757 var token
= new TKwlabel.init_tk
(location
)
1758 push_back
(accept_length
)
1763 if accept_token
== 53 then
1764 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1765 var token
= new TOpar.init_tk
(location
)
1766 push_back
(accept_length
)
1771 if accept_token
== 54 then
1772 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1773 var token
= new TCpar.init_tk
(location
)
1774 push_back
(accept_length
)
1779 if accept_token
== 55 then
1780 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1781 var token
= new TObra.init_tk
(location
)
1782 push_back
(accept_length
)
1787 if accept_token
== 56 then
1788 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1789 var token
= new TCbra.init_tk
(location
)
1790 push_back
(accept_length
)
1795 if accept_token
== 57 then
1796 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1797 var token
= new TComma.init_tk
(location
)
1798 push_back
(accept_length
)
1803 if accept_token
== 58 then
1804 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1805 var token
= new TColumn.init_tk
(location
)
1806 push_back
(accept_length
)
1811 if accept_token
== 59 then
1812 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1813 var token
= new TQuad.init_tk
(location
)
1814 push_back
(accept_length
)
1819 if accept_token
== 60 then
1820 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1821 var token
= new TAssign.init_tk
(location
)
1822 push_back
(accept_length
)
1827 if accept_token
== 61 then
1828 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1829 var token
= new TPluseq.init_tk
(location
)
1830 push_back
(accept_length
)
1835 if accept_token
== 62 then
1836 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1837 var token
= new TMinuseq.init_tk
(location
)
1838 push_back
(accept_length
)
1843 if accept_token
== 63 then
1844 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1845 var token
= new TDotdotdot.init_tk
(location
)
1846 push_back
(accept_length
)
1851 if accept_token
== 64 then
1852 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1853 var token
= new TDotdot.init_tk
(location
)
1854 push_back
(accept_length
)
1859 if accept_token
== 65 then
1860 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1861 var token
= new TDot.init_tk
(location
)
1862 push_back
(accept_length
)
1867 if accept_token
== 66 then
1868 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1869 var token
= new TPlus.init_tk
(location
)
1870 push_back
(accept_length
)
1875 if accept_token
== 67 then
1876 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1877 var token
= new TMinus.init_tk
(location
)
1878 push_back
(accept_length
)
1883 if accept_token
== 68 then
1884 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1885 var token
= new TStar.init_tk
(location
)
1886 push_back
(accept_length
)
1891 if accept_token
== 69 then
1892 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1893 var token
= new TSlash.init_tk
(location
)
1894 push_back
(accept_length
)
1899 if accept_token
== 70 then
1900 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1901 var token
= new TPercent.init_tk
(location
)
1902 push_back
(accept_length
)
1907 if accept_token
== 71 then
1908 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1909 var token
= new TEq.init_tk
(location
)
1910 push_back
(accept_length
)
1915 if accept_token
== 72 then
1916 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1917 var token
= new TNe.init_tk
(location
)
1918 push_back
(accept_length
)
1923 if accept_token
== 73 then
1924 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1925 var token
= new TLt.init_tk
(location
)
1926 push_back
(accept_length
)
1931 if accept_token
== 74 then
1932 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1933 var token
= new TLe.init_tk
(location
)
1934 push_back
(accept_length
)
1939 if accept_token
== 75 then
1940 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1941 var token
= new TGt.init_tk
(location
)
1942 push_back
(accept_length
)
1947 if accept_token
== 76 then
1948 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1949 var token
= new TGe.init_tk
(location
)
1950 push_back
(accept_length
)
1955 if accept_token
== 77 then
1956 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1957 var token
= new TStarship.init_tk
(location
)
1958 push_back
(accept_length
)
1963 if accept_token
== 78 then
1964 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1965 var token_text
= text
.substring
(0, accept_length
)
1966 var token
= new TClassid.init_tk
(token_text
, location
)
1967 push_back
(accept_length
)
1972 if accept_token
== 79 then
1973 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1974 var token_text
= text
.substring
(0, accept_length
)
1975 var token
= new TId.init_tk
(token_text
, location
)
1976 push_back
(accept_length
)
1981 if accept_token
== 80 then
1982 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1983 var token_text
= text
.substring
(0, accept_length
)
1984 var token
= new TAttrid.init_tk
(token_text
, location
)
1985 push_back
(accept_length
)
1990 if accept_token
== 81 then
1991 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1992 var token_text
= text
.substring
(0, accept_length
)
1993 var token
= new TNumber.init_tk
(token_text
, location
)
1994 push_back
(accept_length
)
1999 if accept_token
== 82 then
2000 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2001 var token_text
= text
.substring
(0, accept_length
)
2002 var token
= new TFloat.init_tk
(token_text
, location
)
2003 push_back
(accept_length
)
2008 if accept_token
== 83 then
2009 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2010 var token_text
= text
.substring
(0, accept_length
)
2011 var token
= new TChar.init_tk
(token_text
, location
)
2012 push_back
(accept_length
)
2017 if accept_token
== 84 then
2018 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2019 var token_text
= text
.substring
(0, accept_length
)
2020 var token
= new TString.init_tk
(token_text
, location
)
2021 push_back
(accept_length
)
2026 if accept_token
== 85 then
2027 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2028 var token_text
= text
.substring
(0, accept_length
)
2029 var token
= new TStartString.init_tk
(token_text
, location
)
2030 push_back
(accept_length
)
2035 if accept_token
== 86 then
2036 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2037 var token_text
= text
.substring
(0, accept_length
)
2038 var token
= new TMidString.init_tk
(token_text
, location
)
2039 push_back
(accept_length
)
2044 if accept_token
== 87 then
2045 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2046 var token_text
= text
.substring
(0, accept_length
)
2047 var token
= new TEndString.init_tk
(token_text
, location
)
2048 push_back
(accept_length
)
2054 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2055 if text
.length
> 0 then
2056 var token
= new AError.init_error
("Unknown token: {text}", location
)
2059 var token
= new EOF(location
)
2068 # Read the next character.
2069 # The character is read from the stream of from the pushback buffer.
2070 private fun get_char
: Int
2078 var sp
= _stream_pos
2080 var res
= _stream_buf
[_stream_pos
]
2081 _stream_pos
= sp
- 1
2084 result
= _stream
.read_char
2087 if result
== -1 then
2094 # Unread some characters.
2095 # Unread characters are stored in the pushback buffer.
2096 private fun push_back
(accept_length
: Int)
2098 var length
= _text
.length
2100 while i
>= accept_length
do
2102 _stream_pos
= _stream_pos
+ 1
2103 _stream_buf
[_stream_pos
] = _text
[i
]
2108 var _goto_table
: Array[Array[Array[Array[Int]]]]
2109 private fun build_goto_table
2111 _goto_table
= once
[
3343 private fun nil_array
: Array[Array[Int]]
3345 return once
new Array[Array[Int]]
3348 var _accept_table
: Array[Array[Int]]
3349 private fun build_accept_table
do
3350 _accept_table
= once
[
3352 -1,0,1,1,0,-1,-1,-1,70,-1,53,54,68,66,57,67,65,69,81,58,73,60,75,78,55,56,-1,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,-1,1,72,-1,84,-1,85,-1,2,2,-1,83,61,62,64,82,-1,59,74,71,76,78,78,78,78,80,79,79,79,79,79,79,48,79,79,79,79,17,79,79,79,79,79,79,26,79,31,16,79,79,79,79,79,79,33,79,79,79,79,79,79,79,79,79,79,79,79,79,79,-1,87,-1,86,-1,2,63,77,80,80,80,80,79,79,32,79,79,79,79,79,79,10,79,79,30,11,79,79,79,41,79,79,79,40,34,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,20,79,79,79,-1,79,79,79,13,79,79,79,28,79,79,79,14,79,79,79,79,11,47,42,79,79,79,79,79,79,44,79,79,27,45,12,79,79,49,79,38,79,79,37,5,79,79,46,79,79,79,51,52,79,79,79,79,79,15,79,79,43,79,29,79,79,39,79,22,4,79,21,79,79,79,79,79,79,35,79,79,79,79,79,79,25,79,3,24,79,79,9,79,79,6,36,79,50,79,18,79,19,7,23,8