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)
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)
641 redef class TKwnullable
642 redef fun parser_index
: Int
647 init init_tk
(loc
: Location)
649 _text
= once
"nullable"
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)
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)
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
= new TKwmeth.init_tk
(location
)
1429 push_back
(accept_length
)
1434 if accept_token
== 12 then
1435 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1436 var token
= new TKwtype.init_tk
(location
)
1437 push_back
(accept_length
)
1442 if accept_token
== 13 then
1443 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1444 var token
= new TKwinit.init_tk
(location
)
1445 push_back
(accept_length
)
1450 if accept_token
== 14 then
1451 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1452 var token
= new TKwredef.init_tk
(location
)
1453 push_back
(accept_length
)
1458 if accept_token
== 15 then
1459 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1460 var token
= new TKwis.init_tk
(location
)
1461 push_back
(accept_length
)
1466 if accept_token
== 16 then
1467 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1468 var token
= new TKwdo.init_tk
(location
)
1469 push_back
(accept_length
)
1474 if accept_token
== 17 then
1475 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1476 var token
= new TKwreadable.init_tk
(location
)
1477 push_back
(accept_length
)
1482 if accept_token
== 18 then
1483 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1484 var token
= new TKwwritable.init_tk
(location
)
1485 push_back
(accept_length
)
1490 if accept_token
== 19 then
1491 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1492 var token
= new TKwvar.init_tk
(location
)
1493 push_back
(accept_length
)
1498 if accept_token
== 20 then
1499 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1500 var token
= new TKwintern.init_tk
(location
)
1501 push_back
(accept_length
)
1506 if accept_token
== 21 then
1507 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1508 var token
= new TKwextern.init_tk
(location
)
1509 push_back
(accept_length
)
1514 if accept_token
== 22 then
1515 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1516 var token
= new TKwprotected.init_tk
(location
)
1517 push_back
(accept_length
)
1522 if accept_token
== 23 then
1523 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1524 var token
= new TKwprivate.init_tk
(location
)
1525 push_back
(accept_length
)
1530 if accept_token
== 24 then
1531 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1532 var token
= new TKwintrude.init_tk
(location
)
1533 push_back
(accept_length
)
1538 if accept_token
== 25 then
1539 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1540 var token
= new TKwif.init_tk
(location
)
1541 push_back
(accept_length
)
1546 if accept_token
== 26 then
1547 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1548 var token
= new TKwthen.init_tk
(location
)
1549 push_back
(accept_length
)
1554 if accept_token
== 27 then
1555 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1556 var token
= new TKwelse.init_tk
(location
)
1557 push_back
(accept_length
)
1562 if accept_token
== 28 then
1563 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1564 var token
= new TKwwhile.init_tk
(location
)
1565 push_back
(accept_length
)
1570 if accept_token
== 29 then
1571 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1572 var token
= new TKwloop.init_tk
(location
)
1573 push_back
(accept_length
)
1578 if accept_token
== 30 then
1579 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1580 var token
= new TKwfor.init_tk
(location
)
1581 push_back
(accept_length
)
1586 if accept_token
== 31 then
1587 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1588 var token
= new TKwin.init_tk
(location
)
1589 push_back
(accept_length
)
1594 if accept_token
== 32 then
1595 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1596 var token
= new TKwand.init_tk
(location
)
1597 push_back
(accept_length
)
1602 if accept_token
== 33 then
1603 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1604 var token
= new TKwor.init_tk
(location
)
1605 push_back
(accept_length
)
1610 if accept_token
== 34 then
1611 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1612 var token
= new TKwnot.init_tk
(location
)
1613 push_back
(accept_length
)
1618 if accept_token
== 35 then
1619 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1620 var token
= new TKwreturn.init_tk
(location
)
1621 push_back
(accept_length
)
1626 if accept_token
== 36 then
1627 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1628 var token
= new TKwcontinue.init_tk
(location
)
1629 push_back
(accept_length
)
1634 if accept_token
== 37 then
1635 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1636 var token
= new TKwbreak.init_tk
(location
)
1637 push_back
(accept_length
)
1642 if accept_token
== 38 then
1643 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1644 var token
= new TKwabort.init_tk
(location
)
1645 push_back
(accept_length
)
1650 if accept_token
== 39 then
1651 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1652 var token
= new TKwassert.init_tk
(location
)
1653 push_back
(accept_length
)
1658 if accept_token
== 40 then
1659 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1660 var token
= new TKwnew.init_tk
(location
)
1661 push_back
(accept_length
)
1666 if accept_token
== 41 then
1667 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1668 var token
= new TKwisa.init_tk
(location
)
1669 push_back
(accept_length
)
1674 if accept_token
== 42 then
1675 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1676 var token
= new TKwonce.init_tk
(location
)
1677 push_back
(accept_length
)
1682 if accept_token
== 43 then
1683 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1684 var token
= new TKwsuper.init_tk
(location
)
1685 push_back
(accept_length
)
1690 if accept_token
== 44 then
1691 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1692 var token
= new TKwself.init_tk
(location
)
1693 push_back
(accept_length
)
1698 if accept_token
== 45 then
1699 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1700 var token
= new TKwtrue.init_tk
(location
)
1701 push_back
(accept_length
)
1706 if accept_token
== 46 then
1707 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1708 var token
= new TKwfalse.init_tk
(location
)
1709 push_back
(accept_length
)
1714 if accept_token
== 47 then
1715 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1716 var token
= new TKwnull.init_tk
(location
)
1717 push_back
(accept_length
)
1722 if accept_token
== 48 then
1723 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1724 var token
= new TKwas.init_tk
(location
)
1725 push_back
(accept_length
)
1730 if accept_token
== 49 then
1731 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1732 var token
= new TKwnullable.init_tk
(location
)
1733 push_back
(accept_length
)
1738 if accept_token
== 50 then
1739 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1740 var token
= new TKwisset.init_tk
(location
)
1741 push_back
(accept_length
)
1746 if accept_token
== 51 then
1747 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1748 var token
= new TKwlabel.init_tk
(location
)
1749 push_back
(accept_length
)
1754 if accept_token
== 52 then
1755 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1756 var token
= new TOpar.init_tk
(location
)
1757 push_back
(accept_length
)
1762 if accept_token
== 53 then
1763 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1764 var token
= new TCpar.init_tk
(location
)
1765 push_back
(accept_length
)
1770 if accept_token
== 54 then
1771 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1772 var token
= new TObra.init_tk
(location
)
1773 push_back
(accept_length
)
1778 if accept_token
== 55 then
1779 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1780 var token
= new TCbra.init_tk
(location
)
1781 push_back
(accept_length
)
1786 if accept_token
== 56 then
1787 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1788 var token
= new TComma.init_tk
(location
)
1789 push_back
(accept_length
)
1794 if accept_token
== 57 then
1795 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1796 var token
= new TColumn.init_tk
(location
)
1797 push_back
(accept_length
)
1802 if accept_token
== 58 then
1803 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1804 var token
= new TQuad.init_tk
(location
)
1805 push_back
(accept_length
)
1810 if accept_token
== 59 then
1811 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1812 var token
= new TAssign.init_tk
(location
)
1813 push_back
(accept_length
)
1818 if accept_token
== 60 then
1819 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1820 var token
= new TPluseq.init_tk
(location
)
1821 push_back
(accept_length
)
1826 if accept_token
== 61 then
1827 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1828 var token
= new TMinuseq.init_tk
(location
)
1829 push_back
(accept_length
)
1834 if accept_token
== 62 then
1835 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1836 var token
= new TDotdotdot.init_tk
(location
)
1837 push_back
(accept_length
)
1842 if accept_token
== 63 then
1843 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1844 var token
= new TDotdot.init_tk
(location
)
1845 push_back
(accept_length
)
1850 if accept_token
== 64 then
1851 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1852 var token
= new TDot.init_tk
(location
)
1853 push_back
(accept_length
)
1858 if accept_token
== 65 then
1859 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1860 var token
= new TPlus.init_tk
(location
)
1861 push_back
(accept_length
)
1866 if accept_token
== 66 then
1867 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1868 var token
= new TMinus.init_tk
(location
)
1869 push_back
(accept_length
)
1874 if accept_token
== 67 then
1875 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1876 var token
= new TStar.init_tk
(location
)
1877 push_back
(accept_length
)
1882 if accept_token
== 68 then
1883 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1884 var token
= new TSlash.init_tk
(location
)
1885 push_back
(accept_length
)
1890 if accept_token
== 69 then
1891 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1892 var token
= new TPercent.init_tk
(location
)
1893 push_back
(accept_length
)
1898 if accept_token
== 70 then
1899 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1900 var token
= new TEq.init_tk
(location
)
1901 push_back
(accept_length
)
1906 if accept_token
== 71 then
1907 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1908 var token
= new TNe.init_tk
(location
)
1909 push_back
(accept_length
)
1914 if accept_token
== 72 then
1915 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1916 var token
= new TLt.init_tk
(location
)
1917 push_back
(accept_length
)
1922 if accept_token
== 73 then
1923 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1924 var token
= new TLe.init_tk
(location
)
1925 push_back
(accept_length
)
1930 if accept_token
== 74 then
1931 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1932 var token
= new TGt.init_tk
(location
)
1933 push_back
(accept_length
)
1938 if accept_token
== 75 then
1939 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1940 var token
= new TGe.init_tk
(location
)
1941 push_back
(accept_length
)
1946 if accept_token
== 76 then
1947 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1948 var token
= new TStarship.init_tk
(location
)
1949 push_back
(accept_length
)
1954 if accept_token
== 77 then
1955 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1956 var token
= new TBang.init_tk
(location
)
1957 push_back
(accept_length
)
1962 if accept_token
== 78 then
1963 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1964 var token_text
= text
.substring
(0, accept_length
)
1965 var token
= new TClassid.init_tk
(token_text
, location
)
1966 push_back
(accept_length
)
1971 if accept_token
== 79 then
1972 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1973 var token_text
= text
.substring
(0, accept_length
)
1974 var token
= new TId.init_tk
(token_text
, location
)
1975 push_back
(accept_length
)
1980 if accept_token
== 80 then
1981 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1982 var token_text
= text
.substring
(0, accept_length
)
1983 var token
= new TAttrid.init_tk
(token_text
, location
)
1984 push_back
(accept_length
)
1989 if accept_token
== 81 then
1990 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1991 var token_text
= text
.substring
(0, accept_length
)
1992 var token
= new TNumber.init_tk
(token_text
, location
)
1993 push_back
(accept_length
)
1998 if accept_token
== 82 then
1999 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2000 var token_text
= text
.substring
(0, accept_length
)
2001 var token
= new TFloat.init_tk
(token_text
, location
)
2002 push_back
(accept_length
)
2007 if accept_token
== 83 then
2008 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2009 var token_text
= text
.substring
(0, accept_length
)
2010 var token
= new TChar.init_tk
(token_text
, location
)
2011 push_back
(accept_length
)
2016 if accept_token
== 84 then
2017 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2018 var token_text
= text
.substring
(0, accept_length
)
2019 var token
= new TString.init_tk
(token_text
, location
)
2020 push_back
(accept_length
)
2025 if accept_token
== 85 then
2026 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2027 var token_text
= text
.substring
(0, accept_length
)
2028 var token
= new TStartString.init_tk
(token_text
, location
)
2029 push_back
(accept_length
)
2034 if accept_token
== 86 then
2035 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2036 var token_text
= text
.substring
(0, accept_length
)
2037 var token
= new TMidString.init_tk
(token_text
, location
)
2038 push_back
(accept_length
)
2043 if accept_token
== 87 then
2044 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2045 var token_text
= text
.substring
(0, accept_length
)
2046 var token
= new TEndString.init_tk
(token_text
, location
)
2047 push_back
(accept_length
)
2053 var location
= new Location(_filename
, start_line
+ 1, start_line
+ 1, start_pos
+ 1, start_pos
+ 1)
2054 if text
.length
> 0 then
2055 var token
= new AError.init_error
("Syntax error: unknown token {text}.", location
)
2058 var token
= new EOF(location
)
2067 # Read the next character.
2068 # The character is read from the stream of from the pushback buffer.
2069 private fun get_char
: Int
2077 var sp
= _stream_pos
2079 var res
= _stream_buf
[_stream_pos
]
2080 _stream_pos
= sp
- 1
2083 result
= _stream
.read_char
2086 if result
== -1 then
2093 # Unread some characters.
2094 # Unread characters are stored in the pushback buffer.
2095 private fun push_back
(accept_length
: Int)
2097 var length
= _text
.length
2099 while i
>= accept_length
do
2101 _stream_pos
= _stream_pos
+ 1
2102 _stream_buf
[_stream_pos
] = _text
[i
]
2107 var _goto_table
: Array[Array[Array[Array[Int]]]]
2108 private fun build_goto_table
2110 _goto_table
= once
[
3311 private fun nil_array
: Array[Array[Int]]
3313 return once
new Array[Array[Int]]
3316 var _accept_table
: Array[Array[Int]]
3317 private fun build_accept_table
do
3318 _accept_table
= once
[
3320 -1,0,1,1,0,77,-1,-1,69,-1,52,53,67,65,56,66,64,68,81,57,72,59,74,78,54,55,-1,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,-1,1,71,-1,84,-1,85,-1,2,2,-1,83,60,61,63,82,-1,58,73,70,75,78,78,78,78,80,79,79,79,79,79,79,48,79,79,79,16,79,79,79,79,79,79,25,79,31,15,79,79,79,79,79,79,33,79,79,79,79,79,79,79,79,79,79,79,79,79,-1,87,-1,86,-1,2,62,76,80,80,80,80,79,79,32,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,19,79,79,-1,79,79,79,79,79,79,27,79,79,79,13,79,79,79,79,29,47,42,79,79,79,79,79,79,44,79,79,26,45,12,79,79,79,38,79,79,37,5,79,79,46,79,79,79,50,51,79,79,79,79,79,14,79,79,43,79,28,79,79,39,79,21,4,79,20,79,79,79,79,79,79,35,79,79,79,79,79,79,24,79,3,23,79,79,9,79,79,6,36,79,49,79,17,79,18,7,22,8