2 // Compiler implementation of the D programming language
3 // Copyright (c) 1999-2008 by Digital Mars
5 // written by Walter Bright
6 // http://www.digitalmars.com
7 // License for redistribution is by either the Artistic License
8 // in artistic.txt, or the GNU General Public License in gnu.txt.
9 // See the included readme.txt for details.
11 /* NOTE: This file has been patched from the original DMD distribution to
12 work with the GDC compiler.
14 Modified by David Friedman, December 2006
17 /* Lexical Analyzer */
41 #include "..\root\mem.h"
43 #include "../root/mem.h"
47 #include "stringtable.h"
51 #include "identifier.h"
56 // from \dm\src\include\setlocal.h
57 extern "C" char * __cdecl __locale_decpoint
;
60 extern int HtmlNamedEntity(unsigned char *p
, int length
);
62 #define LS 0x2028 // UTF line separator
63 #define PS 0x2029 // UTF paragraph separator
65 /********************************************
66 * Do our own char maps
69 static unsigned char cmtable
[256];
71 const int CMoctal
= 0x1;
72 const int CMhex
= 0x2;
73 const int CMidchar
= 0x4;
75 inline unsigned char isoctal (unsigned char c
) { return cmtable
[c
] & CMoctal
; }
76 inline unsigned char ishex (unsigned char c
) { return cmtable
[c
] & CMhex
; }
77 inline unsigned char isidchar(unsigned char c
) { return cmtable
[c
] & CMidchar
; }
79 static void cmtable_init()
81 for (unsigned c
= 0; c
< sizeof(cmtable
) / sizeof(cmtable
[0]); c
++)
83 if ('0' <= c
&& c
<= '7')
84 cmtable
[c
] |= CMoctal
;
85 if (isdigit(c
) || ('a' <= c
&& c
<= 'f') || ('A' <= c
&& c
<= 'F'))
87 if (isalnum(c
) || c
== '_')
88 cmtable
[c
] |= CMidchar
;
93 /************************* Token **********************************************/
95 char *Token::tochars
[TOKMAX
];
97 void *Token::operator new(size_t size
)
103 Lexer::freelist
= t
->next
;
107 return ::operator new(size
);
113 fprintf(stdmsg
, "%s\n", toChars());
117 char *Token::toChars()
119 static char buffer
[3 + 3 * sizeof(value
) + 1];
126 sprintf(buffer
,"%d",(d_int32
)int64value
);
128 sprintf(buffer
,"%d",int32value
);
137 sprintf(buffer
,"%uU",(d_uns32
)uns64value
);
139 sprintf(buffer
,"%uU",uns32value
);
144 sprintf(buffer
,"%"PRIdMAX
"L",int64value
);
148 sprintf(buffer
,"%"PRIuMAX
"UL",uns64value
);
155 float80value
.format(buffer
, sizeof(buffer
));
157 case TOKimaginary32v
:
158 case TOKimaginary64v
:
159 case TOKimaginary80v
:
160 float80value
.format(buffer
, sizeof(buffer
));
166 sprintf(buffer
,"%Lgf", float80value
);
170 sprintf(buffer
,"%Lg", float80value
);
174 sprintf(buffer
,"%LgL", float80value
);
177 case TOKimaginary32v
:
178 sprintf(buffer
,"%Lgfi", float80value
);
181 case TOKimaginary64v
:
182 sprintf(buffer
,"%Lgi", float80value
);
185 case TOKimaginary80v
:
186 sprintf(buffer
,"%LgLi", float80value
);
198 for (size_t i
= 0; i
< len
; )
201 utf_decodeChar((unsigned char *)ustring
, len
, &i
, &c
);
214 buf
.printf("\\x%02x", c
);
215 else if (c
<= 0xFFFF)
216 buf
.printf("\\u%04x", c
);
218 buf
.printf("\\U%08x", c
);
227 p
= (char *)buf
.extractData();
237 p
= ident
->toChars();
247 char *Token::toChars(enum TOK value
)
249 static char buffer
[3 + 3 * sizeof(value
) + 1];
253 { sprintf(buffer
,"TOK%d",value
);
259 /*************************** Lexer ********************************************/
261 Token
*Lexer::freelist
= NULL
;
262 StringTable
Lexer::stringtable
;
263 OutBuffer
Lexer::stringbuffer
;
265 Lexer::Lexer(Module
*mod
,
266 unsigned char *base
, unsigned begoffset
, unsigned endoffset
,
267 int doDocComment
, int commentToken
, bool dltSyntax
)
268 : loc(mod
, 1), dltSyntax(dltSyntax
)
270 //printf("Lexer::Lexer(%p,%d)\n",base,length);
271 //printf("lexer.mod = %p, %p\n", mod, this->loc.mod);
272 memset(&token
,0,sizeof(token
));
274 this->end
= base
+ endoffset
;
275 p
= base
+ begoffset
;
277 this->doDocComment
= doDocComment
;
279 this->commentToken
= commentToken
;
282 this->atStartOfLine
= 1;
286 /* If first line starts with '#!', ignore the line
289 if (p
[0] == '#' && p
[1] =='!')
293 { unsigned char c
= *p
;
312 { unsigned u
= decodeUTF();
313 if (u
== PS
|| u
== LS
)
326 void Lexer::error(const char *format
, ...)
328 if (mod
&& !global
.gag
)
330 char *p
= loc
.toChars();
332 fprintf(stdmsg
, "%s: ", p
);
336 va_start(ap
, format
);
337 vfprintf(stdmsg
, format
, ap
);
340 fprintf(stdmsg
, "\n");
343 if (global
.errors
>= 20) // moderate blizzard of cascading messages
349 void Lexer::error(Loc loc
, const char *format
, ...)
351 if (mod
&& !global
.gag
)
353 char *p
= loc
.toChars();
355 fprintf(stdmsg
, "%s: ", p
);
359 va_start(ap
, format
);
360 vfprintf(stdmsg
, format
, ap
);
363 fprintf(stdmsg
, "\n");
366 if (global
.errors
>= 20) // moderate blizzard of cascading messages
372 TOK
Lexer::nextToken()
378 memcpy(&token
,t
,sizeof(Token
));
390 Token
*Lexer::peek(Token
*ct
)
405 /*********************************
406 * tk is on the opening (.
407 * Look ahead and return token that is past the closing ).
410 Token
*Lexer::peekPastParen(Token
*tk
)
412 //printf("peekPastParen()\n");
437 if (--curlynest
>= 0)
456 /**********************************
457 * Determine if string is a valid Identifier.
458 * Placed here because of commonality with Lexer functionality.
463 int Lexer::isValidIdentifier(char *p
)
471 if (*p
>= '0' && *p
<= '9') // beware of isdigit() on signed chars
479 char *q
= utf_decodeChar((unsigned char *)p
, len
, &idx
, &dc
);
483 if (!((dc
>= 0x80 && isUniAlpha(dc
)) || isalnum(dc
) || dc
== '_'))
492 /****************************
493 * Turn next token in buffer into a token.
496 void Lexer::scan(Token
*t
)
498 unsigned lastLine
= loc
.linnum
;
501 // Delayed line-number updating
504 assert(incLineno
== 1);
509 t
->blockComment
= NULL
;
510 t
->lineComment
= NULL
;
515 if (dltSyntax
&& atStartOfLine
) {
518 for (i
= 0; p
[i
] == '\t'; i
++) {
521 error("Whitespace error: use tabs to indent!");
526 } else if (p
[i
] != '\n' && p
[i
] != '\r') {
528 i
= 0; // End-of-file always has no indent
530 error("unexpected indentation (expected %d tabs, not %d)",
532 } else if (i
< indent
) {
534 t
->value
= TOKrcurly
;
538 } /* else ignore blank line */
541 //printf("p = %p, *p = '%c'\n",p,*p);
546 t
->value
= TOKeof
; // end of file
554 continue; // skip white space
557 if (p
[1] == '\n') { // if CRLF
566 // Delay incrementing the line number until after sending
567 // the TOKendline, for better error messages
574 t
->value
= TOKendline
;
580 continue; // Ignore newlines inside brackets
581 case '0': case '1': case '2': case '3': case '4':
582 case '5': case '6': case '7': case '8': case '9':
583 t
->value
= number(t
);
588 t
->value
= charConstant(t
, 0);
592 t
->value
= stringConstant(t
,0);
600 t
->value
= charConstant(t
, 1);
603 else if (p
[1] == '"')
606 t
->value
= stringConstant(t
, 1);
611 t
->value
= charConstant(t
,0);
619 t
->value
= wysiwygStringConstant(t
, *p
);
626 t
->value
= hexStringConstant(t
);
634 t
->value
= delimitedStringConstant(t
);
637 else if (p
[1] == '{')
640 t
->value
= tokenStringConstant(t
);
648 t
->value
= escapeStringConstant(t
,0);
651 case '\\': // escaped string literal
654 stringbuffer
.reset();
663 c
= escapeSequence();
664 stringbuffer
.writeUTF8(c
);
668 c
= escapeSequence();
669 stringbuffer
.writeByte(c
);
672 } while (*p
== '\\');
673 t
->len
= stringbuffer
.offset
;
674 stringbuffer
.writeByte(0);
675 t
->ustring
= (unsigned char *)mem
.malloc(stringbuffer
.offset
);
676 memcpy(t
->ustring
, stringbuffer
.data
, stringbuffer
.offset
);
678 t
->value
= TOKstring
;
685 case 'a': case 'b': case 'c': case 'd': case 'e':
686 case 'f': case 'g': case 'h': case 'i': case 'j':
687 case 'k': case 'm': case 'n': case 'o':
689 case 'p': /*case 'q': case 'r':*/ case 's': case 't':
691 case 'p': case 'q': /*case 'r':*/ case 's': case 't':
693 case 'u': case 'v': case 'w': /*case 'x':*/ case 'y':
695 case 'A': case 'B': case 'C': case 'D': case 'E':
696 case 'F': case 'G': case 'H': case 'I': case 'J':
697 case 'K': case 'M': case 'N': case 'O':
698 case 'P': case 'Q': case 'R': case 'S': case 'T':
699 case 'U': case 'V': case 'W': case 'X': case 'Y':
710 } while (isidchar(c
) || (c
& 0x80 && isUniAlpha(decodeUTF())));
711 sv
= stringtable
.update((char *)t
->ptr
, p
- t
->ptr
);
712 id
= (Identifier
*) sv
->ptrvalue
;
714 { id
= new Identifier(sv
->lstring
.string
,TOKidentifier
);
718 t
->value
= (enum TOK
) id
->value
;
720 if (*t
->ptr
== '_') // if special identifier token
722 static char date
[11+1];
723 static char time
[8+1];
724 static char timestamp
[24+1];
726 if (!date
[0]) // lazy evaluation
733 sprintf(date
, "%.6s %.4s", p
+ 4, p
+ 20);
734 sprintf(time
, "%.8s", p
+ 11);
735 sprintf(timestamp
, "%.24s", p
);
739 if (mod
&& id
== Id::FILE)
741 t
->ustring
= (unsigned char *)(loc
.filename
? loc
.filename
: mod
->ident
->toChars());
744 else if (mod
&& id
== Id::LINE
)
746 t
->value
= TOKint64v
;
747 t
->uns64value
= loc
.linnum
;
753 t
->ustring
= (unsigned char *)date
;
756 else if (id
== Id::TIME
)
758 t
->ustring
= (unsigned char *)time
;
761 else if (id
== Id::VENDOR
)
764 t
->ustring
= (unsigned char *)"GDC";
766 t
->ustring
= (unsigned char *)"Digital Mars D";
770 else if (id
== Id::TIMESTAMP
)
772 t
->ustring
= (unsigned char *)timestamp
;
774 t
->value
= TOKstring
;
777 t
->len
= strlen((char *)t
->ustring
);
779 else if (id
== Id::VERSIONX
)
780 { unsigned major
= 0;
783 for (char *p
= global
.version
+ 1; 1; p
++)
787 minor
= minor
* 10 + c
- '0';
795 t
->value
= TOKint64v
;
796 t
->uns64value
= major
* 1000 + minor
;
799 else if (id
== Id::EOFX
)
802 // Advance scanner to end of file
803 while (!(*p
== 0 || *p
== 0x1A))
808 //printf("t->value = %d\n",t->value);
818 t
->value
= TOKdivass
;
827 { unsigned char c
= *p
;
846 error("unterminated /* */ comment");
853 { unsigned u
= decodeUTF();
854 if (u
== PS
|| u
== LS
)
863 if (p
[-2] == '*' && p
- 3 != t
->ptr
)
868 t
->value
= TOKcomment
;
871 else if (doDocComment
&& t
->ptr
[2] == '*' && p
- 4 != t
->ptr
)
872 { // if /** but not /**/
873 getDocComment(t
, lastLine
== linnum
);
877 case '/': // do // style comments
880 { unsigned char c
= *++p
;
896 t
->value
= TOKcomment
;
899 if (doDocComment
&& t
->ptr
[2] == '/')
900 getDocComment(t
, lastLine
== linnum
);
907 { unsigned u
= decodeUTF();
908 if (u
== PS
|| u
== LS
)
920 t
->value
= TOKcomment
;
923 if (doDocComment
&& t
->ptr
[2] == '/')
924 getDocComment(t
, lastLine
== linnum
);
937 { unsigned char c
= *p
;
972 error("unterminated /+ +/ comment");
979 { unsigned u
= decodeUTF();
980 if (u
== PS
|| u
== LS
)
990 t
->value
= TOKcomment
;
993 if (doDocComment
&& t
->ptr
[2] == '+' && p
- 4 != t
->ptr
)
994 { // if /++ but not /++/
995 getDocComment(t
, lastLine
== linnum
);
1006 { /* Note that we don't allow ._1 and ._ as being
1007 * valid floating point numbers.
1010 t
->value
= inreal(t
);
1012 else if (p
[0] == '.')
1016 t
->value
= TOKdotdotdot
;
1020 t
->value
= TOKslice
;
1031 t
->value
= TOKandass
;
1035 t
->value
= TOKandand
;
1037 error("Use 'and' instead of '&&'");
1047 t
->value
= TOKorass
;
1053 error("Use 'or' instead of '||'");
1063 t
->value
= TOKminass
;
1068 t
->value
= TOKarrow
;
1073 t
->value
= TOKminusminus
;
1083 t
->value
= TOKaddass
;
1087 t
->value
= TOKplusplus
;
1097 t
->value
= TOKle
; // <=
1103 t
->value
= TOKshlass
; // <<=
1106 t
->value
= TOKshl
; // <<
1112 t
->value
= TOKleg
; // <>=
1115 t
->value
= TOKlg
; // <>
1118 t
->value
= TOKlt
; // <
1125 t
->value
= TOKge
; // >=
1131 t
->value
= TOKshrass
; // >>=
1137 t
->value
= TOKushrass
; // >>>=
1140 t
->value
= TOKushr
; // >>>
1143 t
->value
= TOKshr
; // >>
1146 t
->value
= TOKgt
; // >
1153 if (*p
== '=' && global
.params
.Dversion
== 1)
1155 t
->value
= TOKnotidentity
; // !==
1158 t
->value
= TOKnotequal
; // !=
1166 t
->value
= TOKunord
; // !<>=
1169 t
->value
= TOKue
; // !<>
1173 t
->value
= TOKug
; // !<=
1176 t
->value
= TOKuge
; // !<
1182 t
->value
= TOKul
; // !>=
1185 t
->value
= TOKule
; // !>
1188 t
->value
= TOKnot
; // !
1195 if (*p
== '=' && global
.params
.Dversion
== 1)
1197 t
->value
= TOKidentity
; // ===
1200 t
->value
= TOKequal
; // ==
1203 t
->value
= TOKassign
; // =
1210 t
->value
= TOKcatass
; // ~=
1213 t
->value
= TOKtilde
; // ~
1216 #define NESTED(cin,tokin,cout,tokout) \
1217 case cin: nesting++; p++; t->value = tokin; return;\
1218 case cout: if (nesting == 0) {error("Unexpected '%c'", cout);} else {nesting--;} p++; t->value = tokout; return;
1220 NESTED('(', TOKlparen
, ')', TOKrparen
)
1221 NESTED('[', TOKlbracket
, ']', TOKrbracket
)
1222 NESTED('{', TOKlcurly
, '}', TOKrcurly
)
1225 #define SINGLE(c,tok) case c: p++; t->value = tok; return;
1226 SINGLE('?', TOKquestion
)
1227 SINGLE(',', TOKcomma
)
1228 SINGLE(';', TOKsemicolon
)
1229 SINGLE('$', TOKdollar
)
1238 t
->value
= TOKcolon
;
1241 #define DOUBLE(c1,tok1,c2,tok2) \
1252 DOUBLE('*', TOKmul
, '=', TOKmulass
)
1253 DOUBLE('%', TOKmod
, '=', TOKmodass
)
1254 DOUBLE('^', TOKxor
, '=', TOKxorass
)
1258 case '#': // do # style comments and pragmas
1261 do { p
++; } while (*p
!= '\n');
1271 { unsigned char c
= *p
;
1274 { unsigned u
= decodeUTF();
1276 // Check for start of unicode identifier
1280 if (u
== PS
|| u
== LS
)
1288 error("unsupported char '%c'", c
);
1290 error("unsupported char 0x%02x", c
);
1298 /*******************************************
1299 * Parse escape sequence.
1302 unsigned Lexer::escapeSequence()
1318 case 'a': c
= 7; goto Lconsume
;
1319 case 'b': c
= 8; goto Lconsume
;
1320 case 'f': c
= 12; goto Lconsume
;
1321 case 'n': c
= 10; goto Lconsume
;
1322 case 'r': c
= 13; goto Lconsume
;
1323 case 't': c
= 9; goto Lconsume
;
1324 case 'v': c
= 11; goto Lconsume
;
1346 else if (islower(c
))
1355 { error("escape hex sequence has %d hex digits instead of %d", n
, ndigits
);
1359 if (ndigits
!= 2 && !utf_isValidDchar(v
))
1360 error("invalid UTF character \\U%08x", v
);
1364 error("undefined escape hex sequence \\%c\n",c
);
1367 case '&': // named character entity
1368 for (unsigned char *idstart
= ++p
; 1; p
++)
1373 c
= HtmlNamedEntity(idstart
, p
- idstart
);
1375 { error("unnamed character entity &%.*s;", (int)(p
- idstart
), idstart
);
1383 (p
!= idstart
+ 1 && isdigit(*p
)))
1385 error("unterminated named entity");
1393 case 0x1A: // end of file
1405 v
= v
* 8 + (c
- '0');
1407 } while (++n
< 3 && isoctal(c
));
1410 error("0%03o is larger than a byte", c
);
1413 error("undefined escape sequence \\%c\n",c
);
1419 /**************************************
1422 TOK
Lexer::wysiwygStringConstant(Token
*t
, int tc
)
1427 stringbuffer
.reset();
1440 c
= '\n'; // treat EndOfLine as \n character
1446 error("unterminated string constant starting at %s", start
.toChars());
1447 t
->ustring
= (unsigned char *)"";
1456 t
->len
= stringbuffer
.offset
;
1457 stringbuffer
.writeByte(0);
1458 t
->ustring
= (unsigned char *)mem
.malloc(stringbuffer
.offset
);
1459 memcpy(t
->ustring
, stringbuffer
.data
, stringbuffer
.offset
);
1468 unsigned u
= decodeUTF();
1470 if (u
== PS
|| u
== LS
)
1472 stringbuffer
.writeUTF8(u
);
1477 stringbuffer
.writeByte(c
);
1481 /**************************************
1486 TOK
Lexer::hexStringConstant(Token
*t
)
1493 stringbuffer
.reset();
1503 continue; // skip white space
1508 // Treat isolated '\r' as if it were a '\n'
1515 error("unterminated string constant starting at %s", start
.toChars());
1516 t
->ustring
= (unsigned char *)"";
1523 { error("odd number (%d) of hex characters in hex string", n
);
1524 stringbuffer
.writeByte(v
);
1526 t
->len
= stringbuffer
.offset
;
1527 stringbuffer
.writeByte(0);
1528 t
->ustring
= (unsigned char *)mem
.malloc(stringbuffer
.offset
);
1529 memcpy(t
->ustring
, stringbuffer
.data
, stringbuffer
.offset
);
1534 if (c
>= '0' && c
<= '9')
1536 else if (c
>= 'a' && c
<= 'f')
1538 else if (c
>= 'A' && c
<= 'F')
1542 unsigned u
= decodeUTF();
1544 if (u
== PS
|| u
== LS
)
1547 error("non-hex character \\u%x", u
);
1550 error("non-hex character '%c'", c
);
1553 stringbuffer
.writeByte(v
);
1565 /**************************************
1566 * Lex delimited strings:
1567 * q"(foo(xxx))" // "foo(xxx)"
1568 * q"[foo(]" // "foo("
1569 * q"/foo]/" // "foo]"
1577 TOK
Lexer::delimitedStringConstant(Token
*t
)
1580 unsigned delimleft
= 0;
1581 unsigned delimright
= 0;
1584 Identifier
*hereid
= NULL
;
1585 unsigned blankrol
= 0;
1586 unsigned startline
= 0;
1589 stringbuffer
.reset();
1593 //printf("c = '%c'\n", c);
1606 stringbuffer
.writeUTF8(c
);
1614 c
= '\n'; // treat EndOfLine as \n character
1626 if (c
== PS
|| c
== LS
)
1643 else if (isalpha(c
) || c
== '_' || (c
>= 0x80 && isUniAlpha(c
)))
1644 { // Start of identifier; must be a heredoc
1647 scan(&t
); // read in heredoc identifier
1648 if (t
.value
!= TOKidentifier
)
1649 { error("identifier expected for heredoc, not %s", t
.toChars());
1654 //printf("hereid = '%s'\n", hereid->toChars());
1667 { error("heredoc rest of line should be blank");
1675 else if (c
== delimright
)
1681 else if (c
== delimright
)
1683 if (startline
&& isalpha(c
))
1685 unsigned char *psave
= p
;
1687 scan(&t
); // read in possible heredoc identifier
1688 //printf("endid = '%s'\n", t.ident->toChars());
1689 if (t
.value
== TOKidentifier
&& t
.ident
->equals(hereid
))
1690 { /* should check that rest of line is blank
1696 stringbuffer
.writeUTF8(c
);
1705 error("delimited string must end in %c\"", delimright
);
1706 t
->len
= stringbuffer
.offset
;
1707 stringbuffer
.writeByte(0);
1708 t
->ustring
= (unsigned char *)mem
.malloc(stringbuffer
.offset
);
1709 memcpy(t
->ustring
, stringbuffer
.data
, stringbuffer
.offset
);
1714 error("unterminated string constant starting at %s", start
.toChars());
1715 t
->ustring
= (unsigned char *)"";
1721 /**************************************
1722 * Lex delimited strings:
1723 * q{ foo(xxx) } // " foo(xxx) "
1725 * q{{foo}"}"} // "{foo}"}""
1730 TOK
Lexer::tokenStringConstant(Token
*t
)
1734 unsigned char *pstart
= ++p
;
1760 t
->len
= p
- 1 - pstart
;
1761 t
->ustring
= (unsigned char *)mem
.malloc(t
->len
+ 1);
1762 memcpy(t
->ustring
, pstart
, t
->len
);
1763 t
->ustring
[t
->len
] = 0;
1768 error("unterminated token string constant starting at %s", start
.toChars());
1769 t
->ustring
= (unsigned char *)"";
1778 /**************************************
1781 TOK
Lexer::escapeStringConstant(Token
*t
, int wide
)
1786 stringbuffer
.reset();
1798 c
= escapeSequence();
1799 stringbuffer
.writeUTF8(c
);
1803 c
= escapeSequence();
1815 c
= '\n'; // treat EndOfLine as \n character
1820 t
->len
= stringbuffer
.offset
;
1821 stringbuffer
.writeByte(0);
1822 t
->ustring
= (unsigned char *)mem
.malloc(stringbuffer
.offset
);
1823 memcpy(t
->ustring
, stringbuffer
.data
, stringbuffer
.offset
);
1830 error("unterminated string constant starting at %s", start
.toChars());
1831 t
->ustring
= (unsigned char *)"";
1841 if (c
== LS
|| c
== PS
)
1846 stringbuffer
.writeUTF8(c
);
1851 stringbuffer
.writeByte(c
);
1855 /**************************************
1858 TOK
Lexer::charConstant(Token
*t
, int wide
)
1863 //printf("Lexer::charConstant\n");
1872 t
->uns64value
= escapeSequence();
1878 t
->uns64value
= escapeSequence();
1883 t
->uns64value
= escapeSequence();
1895 error("unterminated character constant");
1904 if (c
== LS
|| c
== PS
)
1906 if (c
< 0xD800 || (c
>= 0xE000 && c
< 0xFFFE))
1916 { error("unterminated character constant");
1923 /***************************************
1924 * Get postfix of string literal.
1927 void Lexer::stringPostfix(Token
*t
)
1944 /***************************************
1945 * Read \u or \U unicode sequence
1951 unsigned Lexer::wchar(unsigned u
)
1958 nchars
= (u
== 'U') ? 8 : 4;
1967 { error("\\%c sequence must be followed by %d hex characters", u
, nchars
);
1972 else if (islower(c
))
1983 /**************************************
1985 * If it's an integer, store it in tok.TKutok.Vlong.
1986 * integers can be decimal, octal or hex
1987 * Handle the suffixes U, UL, LU, L, etc.
1988 * If it's double, store it in tok.TKutok.Vdouble.
1994 TOK
Lexer::number(Token
*t
)
1996 // We use a state machine to collect numbers
1997 enum STATE
{ STATE_initial
, STATE_0
, STATE_decimal
, STATE_octal
, STATE_octale
,
1998 STATE_hex
, STATE_binary
, STATE_hex0
, STATE_binary0
,
1999 STATE_hexh
, STATE_error
};
2003 { FLAGS_decimal
= 1, // decimal
2004 FLAGS_unsigned
= 2, // u or U suffix
2005 FLAGS_long
= 4, // l or L suffix
2007 enum FLAGS flags
= FLAGS_decimal
;
2012 unsigned char *start
;
2015 //printf("Lexer::number()\n");
2016 state
= STATE_initial
;
2018 stringbuffer
.reset();
2025 case STATE_initial
: // opening state
2029 state
= STATE_decimal
;
2033 flags
= (FLAGS
) (flags
& ~FLAGS_decimal
);
2047 if (p
[1] == '.') // .. is a separate token
2060 state
= STATE_binary0
;
2063 case '0': case '1': case '2': case '3':
2064 case '4': case '5': case '6': case '7':
2065 state
= STATE_octal
;
2069 case '8': case '9': case 'A':
2070 case 'C': case 'D': case 'F':
2071 case 'a': case 'c': case 'd': case 'f':
2077 state
= STATE_octal
;
2091 case STATE_decimal
: // reading decimal number
2096 || c
== 'H' || c
== 'h'
2100 if (c
== '_') // ignore embedded _
2104 if (c
== '.' && p
[1] != '.')
2106 else if (c
== 'i' || c
== 'f' || c
== 'F' ||
2107 c
== 'e' || c
== 'E')
2109 real
: // It's a real number. Back up and rescan as a real
2113 else if (c
== 'L' && p
[1] == 'i')
2119 case STATE_hex0
: // reading hex number
2123 if (c
== '_') // ignore embedded _
2127 if (c
== '.' && p
[1] != '.')
2129 if (c
== 'P' || c
== 'p' || c
== 'i')
2131 if (state
== STATE_hex0
)
2132 error("Hex digit expected, not '%c'", c
);
2141 case STATE_hexh
: // parse numbers like 0FFh
2144 if (c
== 'H' || c
== 'h')
2152 // Check for something like 1E3 or 0E24
2153 if (memchr((char *)stringbuffer
.data
, 'E', stringbuffer
.offset
) ||
2154 memchr((char *)stringbuffer
.data
, 'e', stringbuffer
.offset
))
2156 error("Hex digit expected, not '%c'", c
);
2163 case STATE_octal
: // reading octal number
2164 case STATE_octale
: // reading octal number with non-octal digits
2169 || c
== 'H' || c
== 'h'
2173 if (c
== '_') // ignore embedded _
2177 if (c
== '.' && p
[1] != '.')
2183 state
= STATE_octale
;
2190 case STATE_binary0
: // starting binary number
2191 case STATE_binary
: // reading binary number
2192 if (c
!= '0' && c
!= '1')
2196 || c
== 'H' || c
== 'h'
2200 if (c
== '_') // ignore embedded _
2204 if (state
== STATE_binary0
)
2205 { error("binary digit expected");
2206 state
= STATE_error
;
2212 state
= STATE_binary
;
2215 case STATE_error
: // for error recovery
2216 if (!isdigit(c
)) // scan until non-digit
2223 stringbuffer
.writeByte(c
);
2227 stringbuffer
.writeByte(0); // terminate string
2228 if (state
== STATE_octale
)
2229 error("Octal digit expected");
2231 uinteger_t n
; // unsigned >=64 bit integer type
2233 if (stringbuffer
.offset
== 2 && (state
== STATE_decimal
|| state
== STATE_0
))
2234 n
= stringbuffer
.data
[0] - '0';
2237 // Convert string to integer
2240 n
= strtoull((char *)stringbuffer
.data
,NULL
,base
);
2241 if (errno
== ERANGE
)
2242 error("integer overflow");
2244 // Not everybody implements strtoull()
2245 char *p
= (char *)stringbuffer
.data
;
2250 if (p
[1] == 'x' || p
[1] == 'X')
2252 else if (p
[1] == 'b' || p
[1] == 'B')
2254 else if (isdigit(p
[1]))
2261 if (*p
>= '0' && *p
<= '9')
2263 else if (*p
>= 'a' && *p
<= 'z')
2265 else if (*p
>= 'A' && *p
<= 'Z')
2271 if (n
&& n
* r
+ d
<= n
)
2273 error ("integer overflow");
2281 if (sizeof(n
) > 8 &&
2282 n
> 0xFFFFFFFFFFFFFFFFULL
) // if n needs more than 64 bits
2283 error("integer overflow");
2286 // Parse trailing 'u', 'U', 'l' or 'L' in any combination
2297 if (1 || !global
.params
.useDeprecated
)
2298 error("'l' suffix is deprecated, use 'L' instead");
2304 error("unrecognized token");
2305 flags
= (FLAGS
) (flags
| f
);
2316 /* Octal or Hexadecimal constant.
2317 * First that fits: int, uint, long, ulong
2319 if (n
& 0x8000000000000000LL
)
2321 else if (n
& 0xFFFFFFFF00000000LL
)
2323 else if (n
& 0x80000000)
2330 /* First that fits: int, long, long long
2332 if (n
& 0x8000000000000000LL
)
2333 { error("signed integer overflow");
2336 else if (n
& 0xFFFFFFFF80000000LL
)
2342 case FLAGS_unsigned
:
2343 case FLAGS_decimal
| FLAGS_unsigned
:
2344 /* First that fits: uint, ulong
2346 if (n
& 0xFFFFFFFF00000000LL
)
2352 case FLAGS_decimal
| FLAGS_long
:
2353 if (n
& 0x8000000000000000LL
)
2354 { error("signed integer overflow");
2362 if (n
& 0x8000000000000000LL
)
2368 case FLAGS_unsigned
| FLAGS_long
:
2369 case FLAGS_decimal
| FLAGS_unsigned
| FLAGS_long
:
2375 printf("%x\n",flags
);
2383 /**************************************
2384 * Read in characters, converting them to real.
2386 * Exponent overflow not detected.
2387 * Too much requested precision is not detected.
2390 TOK
Lexer::inreal(Token
*t
)
2394 assert(*p
== '.' || isdigit(*p
));
2403 case TOKimaginary32v
:
2404 case TOKimaginary64v
:
2405 case TOKimaginary80v
:
2413 #endif /* __DMC__ */
2416 char hex
; // is this a hexadecimal-floating-constant?
2419 //printf("Lexer::inreal()\n");
2420 stringbuffer
.reset();
2426 // Get next char from input
2428 //printf("dblstate = %d, c = '%c'\n", dblstate, c);
2433 case 0: // opening state
2444 if (c
== 'X' || c
== 'x')
2448 case 1: // digits to left of .
2449 case 3: // digits to right of .
2450 case 7: // continuing exponent digits
2451 if (!isdigit(c
) && !(hex
&& isxdigit(c
)))
2454 goto Lnext
; // ignore embedded '_'
2460 case 2: // no more digits to left of .
2465 case 4: // no more digits to right of .
2466 if ((c
== 'E' || c
== 'e') ||
2467 hex
&& (c
== 'P' || c
== 'p'))
2469 hex
= 0; // exponent is always decimal
2473 error("binary-exponent-part required");
2476 case 5: // looking immediately to right of E
2478 if (c
== '-' || c
== '+')
2480 case 6: // 1st exponent digit expected
2482 error("exponent expected");
2486 case 8: // past end of exponent digits
2491 stringbuffer
.writeByte(c
);
2496 stringbuffer
.writeByte(0);
2498 #if _WIN32 && __DMC__
2499 char *save
= __locale_decpoint
;
2500 __locale_decpoint
= ".";
2503 t
->float80value
= real_t::parse((char *)stringbuffer
.data
, real_t::LongDouble
);
2505 t
->float80value
= strtold((char *)stringbuffer
.data
, NULL
);
2513 real_t::parse((char *)stringbuffer
.data
, real_t::Float
);
2515 strtof((char *)stringbuffer
.data
, NULL
);
2517 result
= TOKfloat32v
;
2523 real_t::parse((char *)stringbuffer
.data
, real_t::Double
);
2525 strtod((char *)stringbuffer
.data
, NULL
);
2527 result
= TOKfloat64v
;
2531 if (!global
.params
.useDeprecated
)
2532 error("'l' suffix is deprecated, use 'L' instead");
2534 result
= TOKfloat80v
;
2538 if (*p
== 'i' || *p
== 'I')
2540 if (!global
.params
.useDeprecated
&& *p
== 'I')
2541 error("'I' suffix is deprecated, use 'i' instead");
2546 result
= TOKimaginary32v
;
2549 result
= TOKimaginary64v
;
2552 result
= TOKimaginary80v
;
2556 #if _WIN32 && __DMC__
2557 __locale_decpoint
= save
;
2559 if (errno
== ERANGE
)
2560 error("number is not representable");
2564 /*********************************************
2566 * Currently, the only pragma supported is:
2567 * #line linnum [filespec]
2570 void Lexer::pragma()
2574 char *filespec
= NULL
;
2575 Loc loc
= this->loc
;
2577 while (isblank(*p
)) p
++;
2582 if (tok
.value
!= TOKidentifier
|| tok
.ident
!= Id::line
)
2586 if (tok
.value
== TOKint32v
|| tok
.value
== TOKint64v
)
2587 linnum
= tok
.uns64value
- 1;
2599 this->loc
.linnum
= linnum
;
2601 this->loc
.filename
= filespec
;
2617 continue; // skip white space
2620 if (mod
&& memcmp(p
, "__FILE__", 8) == 0)
2623 filespec
= mem
.strdup(loc
.filename
? loc
.filename
: mod
->ident
->toChars());
2630 stringbuffer
.reset();
2645 stringbuffer
.writeByte(0);
2646 filespec
= mem
.strdup((char *)stringbuffer
.data
);
2652 { unsigned u
= decodeUTF();
2653 if (u
== PS
|| u
== LS
)
2656 stringbuffer
.writeByte(c
);
2666 { unsigned u
= decodeUTF();
2667 if (u
== PS
|| u
== LS
)
2675 error(loc
, "#line integer [\"filespec\"]\\n expected");
2679 /********************************************
2680 * Decode UTF character.
2681 * Issue error messages for invalid sequences.
2682 * Return decoded character, advance p to last character in UTF sequence.
2685 unsigned Lexer::decodeUTF()
2689 unsigned char *s
= p
;
2697 // Check length of remaining string up to 6 UTF-8 characters
2698 for (len
= 1; len
< 6 && s
[len
]; len
++)
2702 msg
= utf_decodeChar(s
, len
, &idx
, &u
);
2712 /***************************************************
2713 * Parse doc comment embedded between t->ptr and p.
2714 * Remove trailing blanks and tabs from lines.
2715 * Replace all newlines with \n.
2716 * Remove leading comment character from each line.
2717 * Decide if it's a lineComment or a blockComment.
2718 * Append to previous one for this token.
2721 void Lexer::getDocComment(Token
*t
, unsigned lineComment
)
2724 unsigned char ct
= t
->ptr
[2];
2725 unsigned char *q
= t
->ptr
+ 3; // start of comment text
2728 unsigned char *qend
= p
;
2729 if (ct
== '*' || ct
== '+')
2732 /* Scan over initial row of ****'s or ++++'s or ////'s
2734 for (; q
< qend
; q
++)
2740 /* Remove trailing row of ****'s or ++++'s
2744 for (; q
< qend
; qend
--)
2751 for (; q
< qend
; q
++)
2753 unsigned char c
= *q
;
2759 if (linestart
&& c
== ct
)
2761 /* Trim preceding whitespace up to preceding \n
2763 while (buf
.offset
&& (buf
.data
[buf
.offset
- 1] == ' ' || buf
.data
[buf
.offset
- 1] == '\t'))
2775 continue; // skip the \r
2783 (q
[2] == 168 || q
[2] == 169))
2793 c
= '\n'; // replace all newlines with \n
2797 /* Trim trailing whitespace
2799 while (buf
.offset
&& (buf
.data
[buf
.offset
- 1] == ' ' || buf
.data
[buf
.offset
- 1] == '\t'))
2807 // Always end with a newline
2808 if (!buf
.offset
|| buf
.data
[buf
.offset
- 1] != '\n')
2809 buf
.writeByte('\n');
2813 // It's a line comment if the start of the doc comment comes
2814 // after other non-whitespace on the same line.
2815 unsigned char** dc
= (lineComment
&& anyToken
)
2819 // Combine with previous doc comment, if any
2821 *dc
= combineComments(*dc
, (unsigned char *)buf
.data
);
2823 *dc
= (unsigned char *)buf
.extractData();
2826 /********************************************
2827 * Combine two document comments into one.
2830 unsigned char *Lexer::combineComments(unsigned char *c1
, unsigned char *c2
)
2832 unsigned char *c
= c2
;
2837 { size_t len1
= strlen((char *)c1
);
2838 size_t len2
= strlen((char *)c2
);
2840 c
= (unsigned char *)mem
.malloc(len1
+ 1 + len2
+ 1);
2841 memcpy(c
, c1
, len1
);
2843 memcpy(c
+ len1
+ 1, c2
, len2
);
2844 c
[len1
+ 1 + len2
] = 0;
2850 /********************************************
2851 * Create an identifier in the string table.
2854 Identifier
*Lexer::idPool(const char *s
)
2856 size_t len
= strlen(s
);
2857 StringValue
*sv
= stringtable
.update(s
, len
);
2858 Identifier
*id
= (Identifier
*) sv
->ptrvalue
;
2861 id
= new Identifier(sv
->lstring
.string
, TOKidentifier
);
2867 /*********************************************
2868 * Create a unique identifier using the prefix s.
2871 Identifier
*Lexer::uniqueId(const char *s
, int num
)
2873 size_t slen
= strlen(s
);
2875 assert(slen
+ sizeof(num
) * 3 + 1 <= sizeof(buffer
));
2876 sprintf(buffer
, "%s%d", s
, num
);
2877 return idPool(buffer
);
2880 Identifier
*Lexer::uniqueId(const char *s
)
2883 return uniqueId(s
, ++num
);
2886 /****************************************
2894 static Keyword keywords
[] =
2898 { "this", TOKthis
},
2899 { "super", TOKsuper
},
2900 { "assert", TOKassert
},
2901 { "null", TOKnull
},
2902 { "true", TOKtrue
},
2903 { "false", TOKfalse
},
2904 { "cast", TOKcast
},
2906 { "delete", TOKdelete
},
2907 { "throw", TOKthrow
},
2908 { "module", TOKmodule
},
2909 { "pragma", TOKpragma
},
2910 { "typeof", TOKtypeof
},
2911 { "typeid", TOKtypeid
},
2913 { "template", TOKtemplate
},
2915 { "void", TOKvoid
},
2916 { "byte", TOKint8
},
2917 { "ubyte", TOKuns8
},
2918 { "short", TOKint16
},
2919 { "ushort", TOKuns16
},
2920 { "int", TOKint32
},
2921 { "uint", TOKuns32
},
2922 { "long", TOKint64
},
2923 { "ulong", TOKuns64
},
2924 { "cent", TOKcent
, },
2925 { "ucent", TOKucent
, },
2926 { "float", TOKfloat32
},
2927 { "double", TOKfloat64
},
2928 { "real", TOKfloat80
},
2930 { "bool", TOKbool
},
2931 { "char", TOKchar
},
2932 { "wchar", TOKwchar
},
2933 { "dchar", TOKdchar
},
2935 { "ifloat", TOKimaginary32
},
2936 { "idouble", TOKimaginary64
},
2937 { "ireal", TOKimaginary80
},
2939 { "cfloat", TOKcomplex32
},
2940 { "cdouble", TOKcomplex64
},
2941 { "creal", TOKcomplex80
},
2943 { "delegate", TOKdelegate
},
2944 { "function", TOKfunction
},
2948 { "else", TOKelse
},
2949 { "while", TOKwhile
},
2952 { "switch", TOKswitch
},
2953 { "case", TOKcase
},
2954 { "default", TOKdefault
},
2955 { "break", TOKbreak
},
2956 { "continue", TOKcontinue
},
2957 { "synchronized", TOKsynchronized
},
2958 { "return", TOKreturn
},
2959 { "goto", TOKgoto
},
2961 { "catch", TOKcatch
},
2962 { "finally", TOKfinally
},
2963 { "with", TOKwith
},
2965 { "foreach", TOKforeach
},
2966 { "foreach_reverse", TOKforeach_reverse
},
2967 { "reversed", TOKreversed
},
2968 { "scope", TOKscope
},
2970 { "struct", TOKstruct
},
2971 { "class", TOKclass
},
2972 { "interface", TOKinterface
},
2973 { "union", TOKunion
},
2974 { "enum", TOKenum
},
2975 { "import", TOKimport
},
2976 { "mixin", TOKmixin
},
2977 { "static", TOKstatic
},
2978 { "final", TOKfinal
},
2979 { "const", TOKconst
},
2980 { "typedef", TOKtypedef
},
2981 { "alias", TOKalias
},
2982 { "override", TOKoverride
},
2983 { "abstract", TOKabstract
},
2984 { "volatile", TOKvolatile
},
2985 { "debug", TOKdebug
},
2986 { "deprecated", TOKdeprecated
},
2989 { "inout", TOKinout
},
2990 { "lazy", TOKlazy
},
2991 { "auto", TOKauto
},
2993 { "align", TOKalign
},
2994 { "extern", TOKextern
},
2995 { "private", TOKprivate
},
2996 { "package", TOKpackage
},
2997 { "protected", TOKprotected
},
2998 { "public", TOKpublic
},
2999 { "export", TOKexport
},
3001 { "body", TOKbody
},
3002 { "invariant", TOKinvariant
},
3003 { "unittest", TOKunittest
},
3004 { "version", TOKversion
},
3005 //{ "manifest", TOKmanifest },
3009 { "macro", TOKmacro
},
3013 { "and", TOKandand
},
3016 { "extends", TOKextends
},
3017 { "implements", TOKimplements
},
3018 { "log_error", TOKlog_error
},
3019 { "log_warning", TOKlog_warning
},
3020 { "log_info", TOKlog_info
},
3021 { "log_trace", TOKlog_trace
},
3023 { "pure", TOKpure
},
3024 { "nothrow", TOKnothrow
},
3025 { "__thread", TOKtls
},
3026 { "__traits", TOKtraits
},
3027 { "__overloadset", TOKoverloadset
},
3028 { "__FILE__", TOKfile
},
3029 { "__LINE__", TOKline
},
3033 int Token::isKeyword()
3035 for (unsigned u
= 0; u
< sizeof(keywords
) / sizeof(keywords
[0]); u
++)
3037 if (keywords
[u
].value
== value
)
3043 void Lexer::initKeywords()
3047 unsigned nkeywords
= sizeof(keywords
) / sizeof(keywords
[0]);
3049 if (global
.params
.Dversion
== 1)
3054 for (u
= 0; u
< nkeywords
; u
++)
3057 //printf("keyword[%d] = '%s'\n",u, keywords[u].name);
3058 s
= keywords
[u
].name
;
3059 v
= keywords
[u
].value
;
3060 sv
= stringtable
.insert(s
, strlen(s
));
3061 sv
->ptrvalue
= (void *) new Identifier(sv
->lstring
.string
,v
);
3063 //printf("tochars[%d] = '%s'\n",v, s);
3064 Token::tochars
[v
] = s
;
3067 Token::tochars
[TOKeof
] = "EOF";
3068 Token::tochars
[TOKlcurly
] = "{";
3069 Token::tochars
[TOKrcurly
] = "}";
3070 Token::tochars
[TOKlparen
] = "(";
3071 Token::tochars
[TOKrparen
] = ")";
3072 Token::tochars
[TOKlbracket
] = "[";
3073 Token::tochars
[TOKrbracket
] = "]";
3074 Token::tochars
[TOKsemicolon
] = ";";
3075 Token::tochars
[TOKcolon
] = ":";
3076 Token::tochars
[TOKcomma
] = ",";
3077 Token::tochars
[TOKdot
] = ".";
3078 Token::tochars
[TOKxor
] = "^";
3079 Token::tochars
[TOKxorass
] = "^=";
3080 Token::tochars
[TOKassign
] = "=";
3081 Token::tochars
[TOKconstruct
] = "=";
3083 Token::tochars
[TOKblit
] = "=";
3085 Token::tochars
[TOKlt
] = "<";
3086 Token::tochars
[TOKgt
] = ">";
3087 Token::tochars
[TOKle
] = "<=";
3088 Token::tochars
[TOKge
] = ">=";
3089 Token::tochars
[TOKequal
] = "==";
3090 Token::tochars
[TOKnotequal
] = "!=";
3091 Token::tochars
[TOKnotidentity
] = "!is";
3092 Token::tochars
[TOKtobool
] = "!!";
3093 Token::tochars
[TOKat
] = "@";
3095 Token::tochars
[TOKunord
] = "!<>=";
3096 Token::tochars
[TOKue
] = "!<>";
3097 Token::tochars
[TOKlg
] = "<>";
3098 Token::tochars
[TOKleg
] = "<>=";
3099 Token::tochars
[TOKule
] = "!>";
3100 Token::tochars
[TOKul
] = "!>=";
3101 Token::tochars
[TOKuge
] = "!<";
3102 Token::tochars
[TOKug
] = "!<=";
3104 Token::tochars
[TOKnot
] = "!";
3105 Token::tochars
[TOKtobool
] = "!!";
3106 Token::tochars
[TOKshl
] = "<<";
3107 Token::tochars
[TOKshr
] = ">>";
3108 Token::tochars
[TOKushr
] = ">>>";
3109 Token::tochars
[TOKadd
] = "+";
3110 Token::tochars
[TOKmin
] = "-";
3111 Token::tochars
[TOKmul
] = "*";
3112 Token::tochars
[TOKdiv
] = "/";
3113 Token::tochars
[TOKmod
] = "%";
3114 Token::tochars
[TOKslice
] = "..";
3115 Token::tochars
[TOKdotdotdot
] = "...";
3116 Token::tochars
[TOKand
] = "&";
3117 Token::tochars
[TOKandand
] = "&&";
3118 Token::tochars
[TOKor
] = "|";
3119 Token::tochars
[TOKoror
] = "||";
3120 Token::tochars
[TOKarray
] = "[]";
3121 Token::tochars
[TOKindex
] = "[i]";
3122 Token::tochars
[TOKaddress
] = "&";
3123 Token::tochars
[TOKstar
] = "*";
3124 Token::tochars
[TOKtilde
] = "~";
3125 Token::tochars
[TOKdollar
] = "$";
3126 Token::tochars
[TOKcast
] = "cast";
3127 Token::tochars
[TOKplusplus
] = "++";
3128 Token::tochars
[TOKminusminus
] = "--";
3129 Token::tochars
[TOKtype
] = "type";
3130 Token::tochars
[TOKquestion
] = "?";
3131 Token::tochars
[TOKneg
] = "-";
3132 Token::tochars
[TOKuadd
] = "+";
3133 Token::tochars
[TOKvar
] = "var";
3134 Token::tochars
[TOKaddass
] = "+=";
3135 Token::tochars
[TOKminass
] = "-=";
3136 Token::tochars
[TOKmulass
] = "*=";
3137 Token::tochars
[TOKdivass
] = "/=";
3138 Token::tochars
[TOKmodass
] = "%=";
3139 Token::tochars
[TOKshlass
] = "<<=";
3140 Token::tochars
[TOKshrass
] = ">>=";
3141 Token::tochars
[TOKushrass
] = ">>>=";
3142 Token::tochars
[TOKandass
] = "&=";
3143 Token::tochars
[TOKorass
] = "|=";
3144 Token::tochars
[TOKcatass
] = "~=";
3145 Token::tochars
[TOKcat
] = "~";
3146 Token::tochars
[TOKcall
] = "call";
3147 Token::tochars
[TOKidentity
] = "is";
3148 Token::tochars
[TOKnotidentity
] = "!is";
3149 Token::tochars
[TOKendline
] = "\\n";
3151 Token::tochars
[TOKorass
] = "|=";
3152 Token::tochars
[TOKidentifier
] = "identifier";
3155 Token::tochars
[TOKdotexp
] = "dotexp";
3156 Token::tochars
[TOKdotti
] = "dotti";
3157 Token::tochars
[TOKdotvar
] = "dotvar";
3158 Token::tochars
[TOKdottype
] = "dottype";
3159 Token::tochars
[TOKsymoff
] = "symoff";
3160 Token::tochars
[TOKtypedot
] = "typedot";
3161 Token::tochars
[TOKarraylength
] = "arraylength";
3162 Token::tochars
[TOKarrayliteral
] = "arrayliteral";
3163 Token::tochars
[TOKassocarrayliteral
] = "assocarrayliteral";
3164 Token::tochars
[TOKstructliteral
] = "structliteral";
3165 Token::tochars
[TOKstring
] = "string";
3166 Token::tochars
[TOKdsymbol
] = "symbol";
3167 Token::tochars
[TOKtuple
] = "tuple";
3168 Token::tochars
[TOKdeclaration
] = "declaration";
3169 Token::tochars
[TOKdottd
] = "dottd";
3170 Token::tochars
[TOKlogger
] = "logger";
3171 Token::tochars
[TOKon_scope_exit
] = "scope(exit)";