1 # Lexer and its tokens.
2 # This file was generated by SableCC (http://www.sablecc.org/).
5 intrude import parser_nodes
8 readable 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 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
1289 var old_state
= dfa_state
1290 if dfa_state
< -1 then
1291 old_state
= -2 - dfa_state
1296 var tmp0
= goto_table
[old_state
]
1298 var high
= tmp0
.length
- 1
1301 var tmp1
= tmp0
.intern_items
1302 while low
<= high
do
1303 var middle
= (low
+ high
) / 2
1304 var tmp2
= tmp1
[middle
].intern_items
1308 else if c
> tmp2
[1] then
1316 if dfa_state
> -2 then break
1326 if dfa_state
>= 0 then
1327 if accept
[dfa_state
] != -1 then
1328 accept_state
= dfa_state
1329 accept_token
= accept
[dfa_state
]
1330 accept_length
= text
.length
1335 if accept_state
!= -1 then
1336 if accept_token
== 0 then
1337 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1338 push_back
(accept_length
)
1343 if accept_token
== 1 then
1344 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1345 var token_text
= text
.substring
(0, accept_length
)
1346 var token
= new TEol.init_tk
(token_text
, location
)
1347 push_back
(accept_length
)
1352 if accept_token
== 2 then
1353 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1354 var token_text
= text
.substring
(0, accept_length
)
1355 var token
= new TComment.init_tk
(token_text
, location
)
1356 push_back
(accept_length
)
1361 if accept_token
== 3 then
1362 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1363 var token
= new TKwpackage.init_tk
(location
)
1364 push_back
(accept_length
)
1369 if accept_token
== 4 then
1370 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1371 var token
= new TKwimport.init_tk
(location
)
1372 push_back
(accept_length
)
1377 if accept_token
== 5 then
1378 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1379 var token
= new TKwclass.init_tk
(location
)
1380 push_back
(accept_length
)
1385 if accept_token
== 6 then
1386 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1387 var token
= new TKwabstract.init_tk
(location
)
1388 push_back
(accept_length
)
1393 if accept_token
== 7 then
1394 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1395 var token
= new TKwinterface.init_tk
(location
)
1396 push_back
(accept_length
)
1401 if accept_token
== 8 then
1402 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1403 var token
= new TKwuniversal.init_tk
(location
)
1404 push_back
(accept_length
)
1409 if accept_token
== 9 then
1410 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1411 var token
= new TKwspecial.init_tk
(location
)
1412 push_back
(accept_length
)
1417 if accept_token
== 10 then
1418 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1419 var token
= new TKwend.init_tk
(location
)
1420 push_back
(accept_length
)
1425 if accept_token
== 11 then
1426 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1427 var token
= new TKwmeth.init_tk
(location
)
1428 push_back
(accept_length
)
1433 if accept_token
== 12 then
1434 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1435 var token
= new TKwtype.init_tk
(location
)
1436 push_back
(accept_length
)
1441 if accept_token
== 13 then
1442 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1443 var token
= new TKwinit.init_tk
(location
)
1444 push_back
(accept_length
)
1449 if accept_token
== 14 then
1450 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1451 var token
= new TKwredef.init_tk
(location
)
1452 push_back
(accept_length
)
1457 if accept_token
== 15 then
1458 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1459 var token
= new TKwis.init_tk
(location
)
1460 push_back
(accept_length
)
1465 if accept_token
== 16 then
1466 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1467 var token
= new TKwdo.init_tk
(location
)
1468 push_back
(accept_length
)
1473 if accept_token
== 17 then
1474 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1475 var token
= new TKwreadable.init_tk
(location
)
1476 push_back
(accept_length
)
1481 if accept_token
== 18 then
1482 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1483 var token
= new TKwwritable.init_tk
(location
)
1484 push_back
(accept_length
)
1489 if accept_token
== 19 then
1490 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1491 var token
= new TKwvar.init_tk
(location
)
1492 push_back
(accept_length
)
1497 if accept_token
== 20 then
1498 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1499 var token
= new TKwintern.init_tk
(location
)
1500 push_back
(accept_length
)
1505 if accept_token
== 21 then
1506 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1507 var token
= new TKwextern.init_tk
(location
)
1508 push_back
(accept_length
)
1513 if accept_token
== 22 then
1514 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1515 var token
= new TKwprotected.init_tk
(location
)
1516 push_back
(accept_length
)
1521 if accept_token
== 23 then
1522 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1523 var token
= new TKwprivate.init_tk
(location
)
1524 push_back
(accept_length
)
1529 if accept_token
== 24 then
1530 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1531 var token
= new TKwintrude.init_tk
(location
)
1532 push_back
(accept_length
)
1537 if accept_token
== 25 then
1538 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1539 var token
= new TKwif.init_tk
(location
)
1540 push_back
(accept_length
)
1545 if accept_token
== 26 then
1546 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1547 var token
= new TKwthen.init_tk
(location
)
1548 push_back
(accept_length
)
1553 if accept_token
== 27 then
1554 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1555 var token
= new TKwelse.init_tk
(location
)
1556 push_back
(accept_length
)
1561 if accept_token
== 28 then
1562 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1563 var token
= new TKwwhile.init_tk
(location
)
1564 push_back
(accept_length
)
1569 if accept_token
== 29 then
1570 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1571 var token
= new TKwloop.init_tk
(location
)
1572 push_back
(accept_length
)
1577 if accept_token
== 30 then
1578 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1579 var token
= new TKwfor.init_tk
(location
)
1580 push_back
(accept_length
)
1585 if accept_token
== 31 then
1586 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1587 var token
= new TKwin.init_tk
(location
)
1588 push_back
(accept_length
)
1593 if accept_token
== 32 then
1594 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1595 var token
= new TKwand.init_tk
(location
)
1596 push_back
(accept_length
)
1601 if accept_token
== 33 then
1602 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1603 var token
= new TKwor.init_tk
(location
)
1604 push_back
(accept_length
)
1609 if accept_token
== 34 then
1610 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1611 var token
= new TKwnot.init_tk
(location
)
1612 push_back
(accept_length
)
1617 if accept_token
== 35 then
1618 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1619 var token
= new TKwreturn.init_tk
(location
)
1620 push_back
(accept_length
)
1625 if accept_token
== 36 then
1626 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1627 var token
= new TKwcontinue.init_tk
(location
)
1628 push_back
(accept_length
)
1633 if accept_token
== 37 then
1634 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1635 var token
= new TKwbreak.init_tk
(location
)
1636 push_back
(accept_length
)
1641 if accept_token
== 38 then
1642 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1643 var token
= new TKwabort.init_tk
(location
)
1644 push_back
(accept_length
)
1649 if accept_token
== 39 then
1650 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1651 var token
= new TKwassert.init_tk
(location
)
1652 push_back
(accept_length
)
1657 if accept_token
== 40 then
1658 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1659 var token
= new TKwnew.init_tk
(location
)
1660 push_back
(accept_length
)
1665 if accept_token
== 41 then
1666 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1667 var token
= new TKwisa.init_tk
(location
)
1668 push_back
(accept_length
)
1673 if accept_token
== 42 then
1674 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1675 var token
= new TKwonce.init_tk
(location
)
1676 push_back
(accept_length
)
1681 if accept_token
== 43 then
1682 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1683 var token
= new TKwsuper.init_tk
(location
)
1684 push_back
(accept_length
)
1689 if accept_token
== 44 then
1690 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1691 var token
= new TKwself.init_tk
(location
)
1692 push_back
(accept_length
)
1697 if accept_token
== 45 then
1698 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1699 var token
= new TKwtrue.init_tk
(location
)
1700 push_back
(accept_length
)
1705 if accept_token
== 46 then
1706 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1707 var token
= new TKwfalse.init_tk
(location
)
1708 push_back
(accept_length
)
1713 if accept_token
== 47 then
1714 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1715 var token
= new TKwnull.init_tk
(location
)
1716 push_back
(accept_length
)
1721 if accept_token
== 48 then
1722 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1723 var token
= new TKwas.init_tk
(location
)
1724 push_back
(accept_length
)
1729 if accept_token
== 49 then
1730 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1731 var token
= new TKwnullable.init_tk
(location
)
1732 push_back
(accept_length
)
1737 if accept_token
== 50 then
1738 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1739 var token
= new TKwisset.init_tk
(location
)
1740 push_back
(accept_length
)
1745 if accept_token
== 51 then
1746 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1747 var token
= new TKwlabel.init_tk
(location
)
1748 push_back
(accept_length
)
1753 if accept_token
== 52 then
1754 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1755 var token
= new TOpar.init_tk
(location
)
1756 push_back
(accept_length
)
1761 if accept_token
== 53 then
1762 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1763 var token
= new TCpar.init_tk
(location
)
1764 push_back
(accept_length
)
1769 if accept_token
== 54 then
1770 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1771 var token
= new TObra.init_tk
(location
)
1772 push_back
(accept_length
)
1777 if accept_token
== 55 then
1778 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1779 var token
= new TCbra.init_tk
(location
)
1780 push_back
(accept_length
)
1785 if accept_token
== 56 then
1786 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1787 var token
= new TComma.init_tk
(location
)
1788 push_back
(accept_length
)
1793 if accept_token
== 57 then
1794 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1795 var token
= new TColumn.init_tk
(location
)
1796 push_back
(accept_length
)
1801 if accept_token
== 58 then
1802 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1803 var token
= new TQuad.init_tk
(location
)
1804 push_back
(accept_length
)
1809 if accept_token
== 59 then
1810 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1811 var token
= new TAssign.init_tk
(location
)
1812 push_back
(accept_length
)
1817 if accept_token
== 60 then
1818 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1819 var token
= new TPluseq.init_tk
(location
)
1820 push_back
(accept_length
)
1825 if accept_token
== 61 then
1826 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1827 var token
= new TMinuseq.init_tk
(location
)
1828 push_back
(accept_length
)
1833 if accept_token
== 62 then
1834 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1835 var token
= new TDotdotdot.init_tk
(location
)
1836 push_back
(accept_length
)
1841 if accept_token
== 63 then
1842 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1843 var token
= new TDotdot.init_tk
(location
)
1844 push_back
(accept_length
)
1849 if accept_token
== 64 then
1850 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1851 var token
= new TDot.init_tk
(location
)
1852 push_back
(accept_length
)
1857 if accept_token
== 65 then
1858 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1859 var token
= new TPlus.init_tk
(location
)
1860 push_back
(accept_length
)
1865 if accept_token
== 66 then
1866 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1867 var token
= new TMinus.init_tk
(location
)
1868 push_back
(accept_length
)
1873 if accept_token
== 67 then
1874 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1875 var token
= new TStar.init_tk
(location
)
1876 push_back
(accept_length
)
1881 if accept_token
== 68 then
1882 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1883 var token
= new TSlash.init_tk
(location
)
1884 push_back
(accept_length
)
1889 if accept_token
== 69 then
1890 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1891 var token
= new TPercent.init_tk
(location
)
1892 push_back
(accept_length
)
1897 if accept_token
== 70 then
1898 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1899 var token
= new TEq.init_tk
(location
)
1900 push_back
(accept_length
)
1905 if accept_token
== 71 then
1906 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1907 var token
= new TNe.init_tk
(location
)
1908 push_back
(accept_length
)
1913 if accept_token
== 72 then
1914 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1915 var token
= new TLt.init_tk
(location
)
1916 push_back
(accept_length
)
1921 if accept_token
== 73 then
1922 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1923 var token
= new TLe.init_tk
(location
)
1924 push_back
(accept_length
)
1929 if accept_token
== 74 then
1930 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1931 var token
= new TGt.init_tk
(location
)
1932 push_back
(accept_length
)
1937 if accept_token
== 75 then
1938 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1939 var token
= new TGe.init_tk
(location
)
1940 push_back
(accept_length
)
1945 if accept_token
== 76 then
1946 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1947 var token
= new TStarship.init_tk
(location
)
1948 push_back
(accept_length
)
1953 if accept_token
== 77 then
1954 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1955 var token
= new TBang.init_tk
(location
)
1956 push_back
(accept_length
)
1961 if accept_token
== 78 then
1962 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1963 var token_text
= text
.substring
(0, accept_length
)
1964 var token
= new TClassid.init_tk
(token_text
, location
)
1965 push_back
(accept_length
)
1970 if accept_token
== 79 then
1971 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1972 var token_text
= text
.substring
(0, accept_length
)
1973 var token
= new TId.init_tk
(token_text
, location
)
1974 push_back
(accept_length
)
1979 if accept_token
== 80 then
1980 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1981 var token_text
= text
.substring
(0, accept_length
)
1982 var token
= new TAttrid.init_tk
(token_text
, location
)
1983 push_back
(accept_length
)
1988 if accept_token
== 81 then
1989 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1990 var token_text
= text
.substring
(0, accept_length
)
1991 var token
= new TNumber.init_tk
(token_text
, location
)
1992 push_back
(accept_length
)
1997 if accept_token
== 82 then
1998 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
1999 var token_text
= text
.substring
(0, accept_length
)
2000 var token
= new TFloat.init_tk
(token_text
, location
)
2001 push_back
(accept_length
)
2006 if accept_token
== 83 then
2007 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2008 var token_text
= text
.substring
(0, accept_length
)
2009 var token
= new TChar.init_tk
(token_text
, location
)
2010 push_back
(accept_length
)
2015 if accept_token
== 84 then
2016 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2017 var token_text
= text
.substring
(0, accept_length
)
2018 var token
= new TString.init_tk
(token_text
, location
)
2019 push_back
(accept_length
)
2024 if accept_token
== 85 then
2025 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2026 var token_text
= text
.substring
(0, accept_length
)
2027 var token
= new TStartString.init_tk
(token_text
, location
)
2028 push_back
(accept_length
)
2033 if accept_token
== 86 then
2034 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2035 var token_text
= text
.substring
(0, accept_length
)
2036 var token
= new TMidString.init_tk
(token_text
, location
)
2037 push_back
(accept_length
)
2042 if accept_token
== 87 then
2043 var location
= new Location(_filename
, start_line
+ 1, accept_line
+ 1, start_pos
+ 1, accept_pos
)
2044 var token_text
= text
.substring
(0, accept_length
)
2045 var token
= new TEndString.init_tk
(token_text
, location
)
2046 push_back
(accept_length
)
2052 var location
= new Location(_filename
, start_line
+ 1, start_line
+ 1, start_pos
+ 1, start_pos
+ 1)
2053 if text
.length
> 0 then
2054 var token
= new AError.init_error
("Syntax error: unknown token {text}.", location
)
2057 var token
= new EOF(location
)
2062 if false then break # FIXME remove once unreach loop exits are in c_src
2064 return null # FIXME remove once unreach loop exits are in c_src
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