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;
285 /* If first line starts with '#!', ignore the line
288 if (p
[0] == '#' && p
[1] =='!')
292 { unsigned char c
= *p
;
311 { unsigned u
= decodeUTF();
312 if (u
== PS
|| u
== LS
)
325 void Lexer::error(const char *format
, ...)
327 if (mod
&& !global
.gag
)
329 char *p
= loc
.toChars();
331 fprintf(stdmsg
, "%s: ", p
);
335 va_start(ap
, format
);
336 vfprintf(stdmsg
, format
, ap
);
339 fprintf(stdmsg
, "\n");
342 if (global
.errors
>= 20) // moderate blizzard of cascading messages
348 void Lexer::error(Loc loc
, const char *format
, ...)
350 if (mod
&& !global
.gag
)
352 char *p
= loc
.toChars();
354 fprintf(stdmsg
, "%s: ", p
);
358 va_start(ap
, format
);
359 vfprintf(stdmsg
, format
, ap
);
362 fprintf(stdmsg
, "\n");
365 if (global
.errors
>= 20) // moderate blizzard of cascading messages
371 TOK
Lexer::nextToken()
377 memcpy(&token
,t
,sizeof(Token
));
389 Token
*Lexer::peek(Token
*ct
)
404 /*********************************
405 * tk is on the opening (.
406 * Look ahead and return token that is past the closing ).
409 Token
*Lexer::peekPastParen(Token
*tk
)
411 //printf("peekPastParen()\n");
436 if (--curlynest
>= 0)
455 /**********************************
456 * Determine if string is a valid Identifier.
457 * Placed here because of commonality with Lexer functionality.
462 int Lexer::isValidIdentifier(char *p
)
470 if (*p
>= '0' && *p
<= '9') // beware of isdigit() on signed chars
478 char *q
= utf_decodeChar((unsigned char *)p
, len
, &idx
, &dc
);
482 if (!((dc
>= 0x80 && isUniAlpha(dc
)) || isalnum(dc
) || dc
== '_'))
491 /****************************
492 * Turn next token in buffer into a token.
495 void Lexer::scan(Token
*t
)
497 unsigned lastLine
= loc
.linnum
;
500 t
->blockComment
= NULL
;
501 t
->lineComment
= NULL
;
506 if (dltSyntax
&& atStartOfLine
) {
509 for (i
= 0; p
[i
] == '\t'; i
++) {
512 error("Whitespace error: use tabs to indent!");
517 } else if (p
[i
] != '\n') {
519 i
= 0; // End-of-file always has no indent
521 error("Unexpected indentation");
522 } else if (i
< indent
) {
524 t
->value
= TOKrcurly
;
528 } /* else ignore blank line */
531 //printf("p = %p, *p = '%c'\n",p,*p);
536 t
->value
= TOKeof
; // end of file
544 continue; // skip white space
547 if (*p
== '\n') { // if CRLF
555 if (dltSyntax
&& !nesting
) {
557 t
->value
= TOKendline
;
560 continue; // Ignore newlines inside brackets
561 case '0': case '1': case '2': case '3': case '4':
562 case '5': case '6': case '7': case '8': case '9':
563 t
->value
= number(t
);
568 t
->value
= charConstant(t
, 0);
572 t
->value
= stringConstant(t
,0);
580 t
->value
= charConstant(t
, 1);
583 else if (p
[1] == '"')
586 t
->value
= stringConstant(t
, 1);
591 t
->value
= charConstant(t
,0);
599 t
->value
= wysiwygStringConstant(t
, *p
);
606 t
->value
= hexStringConstant(t
);
614 t
->value
= delimitedStringConstant(t
);
617 else if (p
[1] == '{')
620 t
->value
= tokenStringConstant(t
);
628 t
->value
= escapeStringConstant(t
,0);
631 case '\\': // escaped string literal
634 stringbuffer
.reset();
643 c
= escapeSequence();
644 stringbuffer
.writeUTF8(c
);
648 c
= escapeSequence();
649 stringbuffer
.writeByte(c
);
652 } while (*p
== '\\');
653 t
->len
= stringbuffer
.offset
;
654 stringbuffer
.writeByte(0);
655 t
->ustring
= (unsigned char *)mem
.malloc(stringbuffer
.offset
);
656 memcpy(t
->ustring
, stringbuffer
.data
, stringbuffer
.offset
);
658 t
->value
= TOKstring
;
665 case 'a': case 'b': case 'c': case 'd': case 'e':
666 case 'f': case 'g': case 'h': case 'i': case 'j':
667 case 'k': case 'm': case 'n': case 'o':
669 case 'p': /*case 'q': case 'r':*/ case 's': case 't':
671 case 'p': case 'q': /*case 'r':*/ case 's': case 't':
673 case 'u': case 'v': case 'w': /*case 'x':*/ case 'y':
675 case 'A': case 'B': case 'C': case 'D': case 'E':
676 case 'F': case 'G': case 'H': case 'I': case 'J':
677 case 'K': case 'M': case 'N': case 'O':
678 case 'P': case 'Q': case 'R': case 'S': case 'T':
679 case 'U': case 'V': case 'W': case 'X': case 'Y':
690 } while (isidchar(c
) || (c
& 0x80 && isUniAlpha(decodeUTF())));
691 sv
= stringtable
.update((char *)t
->ptr
, p
- t
->ptr
);
692 id
= (Identifier
*) sv
->ptrvalue
;
694 { id
= new Identifier(sv
->lstring
.string
,TOKidentifier
);
698 t
->value
= (enum TOK
) id
->value
;
700 if (*t
->ptr
== '_') // if special identifier token
702 static char date
[11+1];
703 static char time
[8+1];
704 static char timestamp
[24+1];
706 if (!date
[0]) // lazy evaluation
713 sprintf(date
, "%.6s %.4s", p
+ 4, p
+ 20);
714 sprintf(time
, "%.8s", p
+ 11);
715 sprintf(timestamp
, "%.24s", p
);
718 if (mod
&& id
== Id::FILE)
720 t
->ustring
= (unsigned char *)(loc
.filename
? loc
.filename
: mod
->ident
->toChars());
723 else if (mod
&& id
== Id::LINE
)
725 t
->value
= TOKint64v
;
726 t
->uns64value
= loc
.linnum
;
728 else if (id
== Id::DATE
)
730 t
->ustring
= (unsigned char *)date
;
733 else if (id
== Id::TIME
)
735 t
->ustring
= (unsigned char *)time
;
738 else if (id
== Id::VENDOR
)
741 t
->ustring
= (unsigned char *)"GDC";
743 t
->ustring
= (unsigned char *)"Digital Mars D";
747 else if (id
== Id::TIMESTAMP
)
749 t
->ustring
= (unsigned char *)timestamp
;
751 t
->value
= TOKstring
;
754 t
->len
= strlen((char *)t
->ustring
);
756 else if (id
== Id::VERSIONX
)
757 { unsigned major
= 0;
760 for (char *p
= global
.version
+ 1; 1; p
++)
764 minor
= minor
* 10 + c
- '0';
772 t
->value
= TOKint64v
;
773 t
->uns64value
= major
* 1000 + minor
;
776 else if (id
== Id::EOFX
)
779 // Advance scanner to end of file
780 while (!(*p
== 0 || *p
== 0x1A))
785 //printf("t->value = %d\n",t->value);
795 t
->value
= TOKdivass
;
804 { unsigned char c
= *p
;
823 error("unterminated /* */ comment");
830 { unsigned u
= decodeUTF();
831 if (u
== PS
|| u
== LS
)
840 if (p
[-2] == '*' && p
- 3 != t
->ptr
)
845 t
->value
= TOKcomment
;
848 else if (doDocComment
&& t
->ptr
[2] == '*' && p
- 4 != t
->ptr
)
849 { // if /** but not /**/
850 getDocComment(t
, lastLine
== linnum
);
854 case '/': // do // style comments
857 { unsigned char c
= *++p
;
873 t
->value
= TOKcomment
;
876 if (doDocComment
&& t
->ptr
[2] == '/')
877 getDocComment(t
, lastLine
== linnum
);
884 { unsigned u
= decodeUTF();
885 if (u
== PS
|| u
== LS
)
897 t
->value
= TOKcomment
;
900 if (doDocComment
&& t
->ptr
[2] == '/')
901 getDocComment(t
, lastLine
== linnum
);
914 { unsigned char c
= *p
;
949 error("unterminated /+ +/ comment");
956 { unsigned u
= decodeUTF();
957 if (u
== PS
|| u
== LS
)
967 t
->value
= TOKcomment
;
970 if (doDocComment
&& t
->ptr
[2] == '+' && p
- 4 != t
->ptr
)
971 { // if /++ but not /++/
972 getDocComment(t
, lastLine
== linnum
);
983 { /* Note that we don't allow ._1 and ._ as being
984 * valid floating point numbers.
987 t
->value
= inreal(t
);
989 else if (p
[0] == '.')
993 t
->value
= TOKdotdotdot
;
1008 t
->value
= TOKandass
;
1012 t
->value
= TOKandand
;
1022 t
->value
= TOKorass
;
1036 t
->value
= TOKminass
;
1041 t
->value
= TOKarrow
;
1046 t
->value
= TOKminusminus
;
1056 t
->value
= TOKaddass
;
1060 t
->value
= TOKplusplus
;
1070 t
->value
= TOKle
; // <=
1076 t
->value
= TOKshlass
; // <<=
1079 t
->value
= TOKshl
; // <<
1085 t
->value
= TOKleg
; // <>=
1088 t
->value
= TOKlg
; // <>
1091 t
->value
= TOKlt
; // <
1098 t
->value
= TOKge
; // >=
1104 t
->value
= TOKshrass
; // >>=
1110 t
->value
= TOKushrass
; // >>>=
1113 t
->value
= TOKushr
; // >>>
1116 t
->value
= TOKshr
; // >>
1119 t
->value
= TOKgt
; // >
1126 if (*p
== '=' && global
.params
.Dversion
== 1)
1128 t
->value
= TOKnotidentity
; // !==
1131 t
->value
= TOKnotequal
; // !=
1139 t
->value
= TOKunord
; // !<>=
1142 t
->value
= TOKue
; // !<>
1146 t
->value
= TOKug
; // !<=
1149 t
->value
= TOKuge
; // !<
1155 t
->value
= TOKul
; // !>=
1158 t
->value
= TOKule
; // !>
1161 t
->value
= TOKnot
; // !
1168 if (*p
== '=' && global
.params
.Dversion
== 1)
1170 t
->value
= TOKidentity
; // ===
1173 t
->value
= TOKequal
; // ==
1176 t
->value
= TOKassign
; // =
1183 t
->value
= TOKcatass
; // ~=
1186 t
->value
= TOKtilde
; // ~
1189 #define NESTED(cin,tokin,cout,tokout) \
1190 case cin: nesting++; p++; t->value = tokin; return;\
1191 case cout: if (nesting == 0) {error("Unexpected '%c'", cout);} else {nesting--;} p++; t->value = tokout; return;
1193 NESTED('(', TOKlparen
, ')', TOKrparen
)
1194 NESTED('[', TOKlbracket
, ']', TOKrbracket
)
1195 NESTED('{', TOKlcurly
, '}', TOKrcurly
)
1198 #define SINGLE(c,tok) case c: p++; t->value = tok; return;
1199 SINGLE('?', TOKquestion
)
1200 SINGLE(',', TOKcomma
)
1201 SINGLE(';', TOKsemicolon
)
1202 SINGLE('$', TOKdollar
)
1211 t
->value
= TOKcolon
;
1214 #define DOUBLE(c1,tok1,c2,tok2) \
1225 DOUBLE('*', TOKmul
, '=', TOKmulass
)
1226 DOUBLE('%', TOKmod
, '=', TOKmodass
)
1227 DOUBLE('^', TOKxor
, '=', TOKxorass
)
1231 case '#': // do # style comments and pragmas
1237 { unsigned char c
= *p
;
1240 { unsigned u
= decodeUTF();
1242 // Check for start of unicode identifier
1246 if (u
== PS
|| u
== LS
)
1254 error("unsupported char '%c'", c
);
1256 error("unsupported char 0x%02x", c
);
1264 /*******************************************
1265 * Parse escape sequence.
1268 unsigned Lexer::escapeSequence()
1284 case 'a': c
= 7; goto Lconsume
;
1285 case 'b': c
= 8; goto Lconsume
;
1286 case 'f': c
= 12; goto Lconsume
;
1287 case 'n': c
= 10; goto Lconsume
;
1288 case 'r': c
= 13; goto Lconsume
;
1289 case 't': c
= 9; goto Lconsume
;
1290 case 'v': c
= 11; goto Lconsume
;
1312 else if (islower(c
))
1321 { error("escape hex sequence has %d hex digits instead of %d", n
, ndigits
);
1325 if (ndigits
!= 2 && !utf_isValidDchar(v
))
1326 error("invalid UTF character \\U%08x", v
);
1330 error("undefined escape hex sequence \\%c\n",c
);
1333 case '&': // named character entity
1334 for (unsigned char *idstart
= ++p
; 1; p
++)
1339 c
= HtmlNamedEntity(idstart
, p
- idstart
);
1341 { error("unnamed character entity &%.*s;", (int)(p
- idstart
), idstart
);
1349 (p
!= idstart
+ 1 && isdigit(*p
)))
1351 error("unterminated named entity");
1359 case 0x1A: // end of file
1371 v
= v
* 8 + (c
- '0');
1373 } while (++n
< 3 && isoctal(c
));
1376 error("0%03o is larger than a byte", c
);
1379 error("undefined escape sequence \\%c\n",c
);
1385 /**************************************
1388 TOK
Lexer::wysiwygStringConstant(Token
*t
, int tc
)
1393 stringbuffer
.reset();
1406 c
= '\n'; // treat EndOfLine as \n character
1412 error("unterminated string constant starting at %s", start
.toChars());
1413 t
->ustring
= (unsigned char *)"";
1422 t
->len
= stringbuffer
.offset
;
1423 stringbuffer
.writeByte(0);
1424 t
->ustring
= (unsigned char *)mem
.malloc(stringbuffer
.offset
);
1425 memcpy(t
->ustring
, stringbuffer
.data
, stringbuffer
.offset
);
1434 unsigned u
= decodeUTF();
1436 if (u
== PS
|| u
== LS
)
1438 stringbuffer
.writeUTF8(u
);
1443 stringbuffer
.writeByte(c
);
1447 /**************************************
1452 TOK
Lexer::hexStringConstant(Token
*t
)
1459 stringbuffer
.reset();
1469 continue; // skip white space
1474 // Treat isolated '\r' as if it were a '\n'
1481 error("unterminated string constant starting at %s", start
.toChars());
1482 t
->ustring
= (unsigned char *)"";
1489 { error("odd number (%d) of hex characters in hex string", n
);
1490 stringbuffer
.writeByte(v
);
1492 t
->len
= stringbuffer
.offset
;
1493 stringbuffer
.writeByte(0);
1494 t
->ustring
= (unsigned char *)mem
.malloc(stringbuffer
.offset
);
1495 memcpy(t
->ustring
, stringbuffer
.data
, stringbuffer
.offset
);
1500 if (c
>= '0' && c
<= '9')
1502 else if (c
>= 'a' && c
<= 'f')
1504 else if (c
>= 'A' && c
<= 'F')
1508 unsigned u
= decodeUTF();
1510 if (u
== PS
|| u
== LS
)
1513 error("non-hex character \\u%x", u
);
1516 error("non-hex character '%c'", c
);
1519 stringbuffer
.writeByte(v
);
1531 /**************************************
1532 * Lex delimited strings:
1533 * q"(foo(xxx))" // "foo(xxx)"
1534 * q"[foo(]" // "foo("
1535 * q"/foo]/" // "foo]"
1543 TOK
Lexer::delimitedStringConstant(Token
*t
)
1546 unsigned delimleft
= 0;
1547 unsigned delimright
= 0;
1550 Identifier
*hereid
= NULL
;
1551 unsigned blankrol
= 0;
1552 unsigned startline
= 0;
1555 stringbuffer
.reset();
1559 //printf("c = '%c'\n", c);
1572 stringbuffer
.writeUTF8(c
);
1580 c
= '\n'; // treat EndOfLine as \n character
1592 if (c
== PS
|| c
== LS
)
1609 else if (isalpha(c
) || c
== '_' || (c
>= 0x80 && isUniAlpha(c
)))
1610 { // Start of identifier; must be a heredoc
1613 scan(&t
); // read in heredoc identifier
1614 if (t
.value
!= TOKidentifier
)
1615 { error("identifier expected for heredoc, not %s", t
.toChars());
1620 //printf("hereid = '%s'\n", hereid->toChars());
1633 { error("heredoc rest of line should be blank");
1641 else if (c
== delimright
)
1647 else if (c
== delimright
)
1649 if (startline
&& isalpha(c
))
1651 unsigned char *psave
= p
;
1653 scan(&t
); // read in possible heredoc identifier
1654 //printf("endid = '%s'\n", t.ident->toChars());
1655 if (t
.value
== TOKidentifier
&& t
.ident
->equals(hereid
))
1656 { /* should check that rest of line is blank
1662 stringbuffer
.writeUTF8(c
);
1671 error("delimited string must end in %c\"", delimright
);
1672 t
->len
= stringbuffer
.offset
;
1673 stringbuffer
.writeByte(0);
1674 t
->ustring
= (unsigned char *)mem
.malloc(stringbuffer
.offset
);
1675 memcpy(t
->ustring
, stringbuffer
.data
, stringbuffer
.offset
);
1680 error("unterminated string constant starting at %s", start
.toChars());
1681 t
->ustring
= (unsigned char *)"";
1687 /**************************************
1688 * Lex delimited strings:
1689 * q{ foo(xxx) } // " foo(xxx) "
1691 * q{{foo}"}"} // "{foo}"}""
1696 TOK
Lexer::tokenStringConstant(Token
*t
)
1700 unsigned char *pstart
= ++p
;
1726 t
->len
= p
- 1 - pstart
;
1727 t
->ustring
= (unsigned char *)mem
.malloc(t
->len
+ 1);
1728 memcpy(t
->ustring
, pstart
, t
->len
);
1729 t
->ustring
[t
->len
] = 0;
1734 error("unterminated token string constant starting at %s", start
.toChars());
1735 t
->ustring
= (unsigned char *)"";
1744 /**************************************
1747 TOK
Lexer::escapeStringConstant(Token
*t
, int wide
)
1752 stringbuffer
.reset();
1764 c
= escapeSequence();
1765 stringbuffer
.writeUTF8(c
);
1769 c
= escapeSequence();
1781 c
= '\n'; // treat EndOfLine as \n character
1786 t
->len
= stringbuffer
.offset
;
1787 stringbuffer
.writeByte(0);
1788 t
->ustring
= (unsigned char *)mem
.malloc(stringbuffer
.offset
);
1789 memcpy(t
->ustring
, stringbuffer
.data
, stringbuffer
.offset
);
1796 error("unterminated string constant starting at %s", start
.toChars());
1797 t
->ustring
= (unsigned char *)"";
1807 if (c
== LS
|| c
== PS
)
1812 stringbuffer
.writeUTF8(c
);
1817 stringbuffer
.writeByte(c
);
1821 /**************************************
1824 TOK
Lexer::charConstant(Token
*t
, int wide
)
1829 //printf("Lexer::charConstant\n");
1838 t
->uns64value
= escapeSequence();
1844 t
->uns64value
= escapeSequence();
1849 t
->uns64value
= escapeSequence();
1861 error("unterminated character constant");
1870 if (c
== LS
|| c
== PS
)
1872 if (c
< 0xD800 || (c
>= 0xE000 && c
< 0xFFFE))
1882 { error("unterminated character constant");
1889 /***************************************
1890 * Get postfix of string literal.
1893 void Lexer::stringPostfix(Token
*t
)
1910 /***************************************
1911 * Read \u or \U unicode sequence
1917 unsigned Lexer::wchar(unsigned u
)
1924 nchars
= (u
== 'U') ? 8 : 4;
1933 { error("\\%c sequence must be followed by %d hex characters", u
, nchars
);
1938 else if (islower(c
))
1949 /**************************************
1951 * If it's an integer, store it in tok.TKutok.Vlong.
1952 * integers can be decimal, octal or hex
1953 * Handle the suffixes U, UL, LU, L, etc.
1954 * If it's double, store it in tok.TKutok.Vdouble.
1960 TOK
Lexer::number(Token
*t
)
1962 // We use a state machine to collect numbers
1963 enum STATE
{ STATE_initial
, STATE_0
, STATE_decimal
, STATE_octal
, STATE_octale
,
1964 STATE_hex
, STATE_binary
, STATE_hex0
, STATE_binary0
,
1965 STATE_hexh
, STATE_error
};
1969 { FLAGS_decimal
= 1, // decimal
1970 FLAGS_unsigned
= 2, // u or U suffix
1971 FLAGS_long
= 4, // l or L suffix
1973 enum FLAGS flags
= FLAGS_decimal
;
1978 unsigned char *start
;
1981 //printf("Lexer::number()\n");
1982 state
= STATE_initial
;
1984 stringbuffer
.reset();
1991 case STATE_initial
: // opening state
1995 state
= STATE_decimal
;
1999 flags
= (FLAGS
) (flags
& ~FLAGS_decimal
);
2013 if (p
[1] == '.') // .. is a separate token
2026 state
= STATE_binary0
;
2029 case '0': case '1': case '2': case '3':
2030 case '4': case '5': case '6': case '7':
2031 state
= STATE_octal
;
2035 case '8': case '9': case 'A':
2036 case 'C': case 'D': case 'F':
2037 case 'a': case 'c': case 'd': case 'f':
2043 state
= STATE_octal
;
2057 case STATE_decimal
: // reading decimal number
2062 || c
== 'H' || c
== 'h'
2066 if (c
== '_') // ignore embedded _
2070 if (c
== '.' && p
[1] != '.')
2072 else if (c
== 'i' || c
== 'f' || c
== 'F' ||
2073 c
== 'e' || c
== 'E')
2075 real
: // It's a real number. Back up and rescan as a real
2079 else if (c
== 'L' && p
[1] == 'i')
2085 case STATE_hex0
: // reading hex number
2089 if (c
== '_') // ignore embedded _
2093 if (c
== '.' && p
[1] != '.')
2095 if (c
== 'P' || c
== 'p' || c
== 'i')
2097 if (state
== STATE_hex0
)
2098 error("Hex digit expected, not '%c'", c
);
2107 case STATE_hexh
: // parse numbers like 0FFh
2110 if (c
== 'H' || c
== 'h')
2118 // Check for something like 1E3 or 0E24
2119 if (memchr((char *)stringbuffer
.data
, 'E', stringbuffer
.offset
) ||
2120 memchr((char *)stringbuffer
.data
, 'e', stringbuffer
.offset
))
2122 error("Hex digit expected, not '%c'", c
);
2129 case STATE_octal
: // reading octal number
2130 case STATE_octale
: // reading octal number with non-octal digits
2135 || c
== 'H' || c
== 'h'
2139 if (c
== '_') // ignore embedded _
2143 if (c
== '.' && p
[1] != '.')
2149 state
= STATE_octale
;
2156 case STATE_binary0
: // starting binary number
2157 case STATE_binary
: // reading binary number
2158 if (c
!= '0' && c
!= '1')
2162 || c
== 'H' || c
== 'h'
2166 if (c
== '_') // ignore embedded _
2170 if (state
== STATE_binary0
)
2171 { error("binary digit expected");
2172 state
= STATE_error
;
2178 state
= STATE_binary
;
2181 case STATE_error
: // for error recovery
2182 if (!isdigit(c
)) // scan until non-digit
2189 stringbuffer
.writeByte(c
);
2193 stringbuffer
.writeByte(0); // terminate string
2194 if (state
== STATE_octale
)
2195 error("Octal digit expected");
2197 uinteger_t n
; // unsigned >=64 bit integer type
2199 if (stringbuffer
.offset
== 2 && (state
== STATE_decimal
|| state
== STATE_0
))
2200 n
= stringbuffer
.data
[0] - '0';
2203 // Convert string to integer
2206 n
= strtoull((char *)stringbuffer
.data
,NULL
,base
);
2207 if (errno
== ERANGE
)
2208 error("integer overflow");
2210 // Not everybody implements strtoull()
2211 char *p
= (char *)stringbuffer
.data
;
2216 if (p
[1] == 'x' || p
[1] == 'X')
2218 else if (p
[1] == 'b' || p
[1] == 'B')
2220 else if (isdigit(p
[1]))
2227 if (*p
>= '0' && *p
<= '9')
2229 else if (*p
>= 'a' && *p
<= 'z')
2231 else if (*p
>= 'A' && *p
<= 'Z')
2237 if (n
&& n
* r
+ d
<= n
)
2239 error ("integer overflow");
2247 if (sizeof(n
) > 8 &&
2248 n
> 0xFFFFFFFFFFFFFFFFULL
) // if n needs more than 64 bits
2249 error("integer overflow");
2252 // Parse trailing 'u', 'U', 'l' or 'L' in any combination
2263 if (1 || !global
.params
.useDeprecated
)
2264 error("'l' suffix is deprecated, use 'L' instead");
2270 error("unrecognized token");
2271 flags
= (FLAGS
) (flags
| f
);
2282 /* Octal or Hexadecimal constant.
2283 * First that fits: int, uint, long, ulong
2285 if (n
& 0x8000000000000000LL
)
2287 else if (n
& 0xFFFFFFFF00000000LL
)
2289 else if (n
& 0x80000000)
2296 /* First that fits: int, long, long long
2298 if (n
& 0x8000000000000000LL
)
2299 { error("signed integer overflow");
2302 else if (n
& 0xFFFFFFFF80000000LL
)
2308 case FLAGS_unsigned
:
2309 case FLAGS_decimal
| FLAGS_unsigned
:
2310 /* First that fits: uint, ulong
2312 if (n
& 0xFFFFFFFF00000000LL
)
2318 case FLAGS_decimal
| FLAGS_long
:
2319 if (n
& 0x8000000000000000LL
)
2320 { error("signed integer overflow");
2328 if (n
& 0x8000000000000000LL
)
2334 case FLAGS_unsigned
| FLAGS_long
:
2335 case FLAGS_decimal
| FLAGS_unsigned
| FLAGS_long
:
2341 printf("%x\n",flags
);
2349 /**************************************
2350 * Read in characters, converting them to real.
2352 * Exponent overflow not detected.
2353 * Too much requested precision is not detected.
2356 TOK
Lexer::inreal(Token
*t
)
2360 assert(*p
== '.' || isdigit(*p
));
2369 case TOKimaginary32v
:
2370 case TOKimaginary64v
:
2371 case TOKimaginary80v
:
2379 #endif /* __DMC__ */
2382 char hex
; // is this a hexadecimal-floating-constant?
2385 //printf("Lexer::inreal()\n");
2386 stringbuffer
.reset();
2392 // Get next char from input
2394 //printf("dblstate = %d, c = '%c'\n", dblstate, c);
2399 case 0: // opening state
2410 if (c
== 'X' || c
== 'x')
2414 case 1: // digits to left of .
2415 case 3: // digits to right of .
2416 case 7: // continuing exponent digits
2417 if (!isdigit(c
) && !(hex
&& isxdigit(c
)))
2420 goto Lnext
; // ignore embedded '_'
2426 case 2: // no more digits to left of .
2431 case 4: // no more digits to right of .
2432 if ((c
== 'E' || c
== 'e') ||
2433 hex
&& (c
== 'P' || c
== 'p'))
2435 hex
= 0; // exponent is always decimal
2439 error("binary-exponent-part required");
2442 case 5: // looking immediately to right of E
2444 if (c
== '-' || c
== '+')
2446 case 6: // 1st exponent digit expected
2448 error("exponent expected");
2452 case 8: // past end of exponent digits
2457 stringbuffer
.writeByte(c
);
2462 stringbuffer
.writeByte(0);
2464 #if _WIN32 && __DMC__
2465 char *save
= __locale_decpoint
;
2466 __locale_decpoint
= ".";
2469 t
->float80value
= real_t::parse((char *)stringbuffer
.data
, real_t::LongDouble
);
2471 t
->float80value
= strtold((char *)stringbuffer
.data
, NULL
);
2479 real_t::parse((char *)stringbuffer
.data
, real_t::Float
);
2481 strtof((char *)stringbuffer
.data
, NULL
);
2483 result
= TOKfloat32v
;
2489 real_t::parse((char *)stringbuffer
.data
, real_t::Double
);
2491 strtod((char *)stringbuffer
.data
, NULL
);
2493 result
= TOKfloat64v
;
2497 if (!global
.params
.useDeprecated
)
2498 error("'l' suffix is deprecated, use 'L' instead");
2500 result
= TOKfloat80v
;
2504 if (*p
== 'i' || *p
== 'I')
2506 if (!global
.params
.useDeprecated
&& *p
== 'I')
2507 error("'I' suffix is deprecated, use 'i' instead");
2512 result
= TOKimaginary32v
;
2515 result
= TOKimaginary64v
;
2518 result
= TOKimaginary80v
;
2522 #if _WIN32 && __DMC__
2523 __locale_decpoint
= save
;
2525 if (errno
== ERANGE
)
2526 error("number is not representable");
2530 /*********************************************
2532 * Currently, the only pragma supported is:
2533 * #line linnum [filespec]
2536 void Lexer::pragma()
2540 char *filespec
= NULL
;
2541 Loc loc
= this->loc
;
2543 while (isblank(*p
)) p
++;
2548 if (tok
.value
!= TOKidentifier
|| tok
.ident
!= Id::line
)
2552 if (tok
.value
== TOKint32v
|| tok
.value
== TOKint64v
)
2553 linnum
= tok
.uns64value
- 1;
2565 this->loc
.linnum
= linnum
;
2567 this->loc
.filename
= filespec
;
2583 continue; // skip white space
2586 if (mod
&& memcmp(p
, "__FILE__", 8) == 0)
2589 filespec
= mem
.strdup(loc
.filename
? loc
.filename
: mod
->ident
->toChars());
2596 stringbuffer
.reset();
2611 stringbuffer
.writeByte(0);
2612 filespec
= mem
.strdup((char *)stringbuffer
.data
);
2618 { unsigned u
= decodeUTF();
2619 if (u
== PS
|| u
== LS
)
2622 stringbuffer
.writeByte(c
);
2632 { unsigned u
= decodeUTF();
2633 if (u
== PS
|| u
== LS
)
2641 // No problem: this is just a comment line
2645 // error(loc, "#line integer [\"filespec\"]\\n expected");
2649 /********************************************
2650 * Decode UTF character.
2651 * Issue error messages for invalid sequences.
2652 * Return decoded character, advance p to last character in UTF sequence.
2655 unsigned Lexer::decodeUTF()
2659 unsigned char *s
= p
;
2667 // Check length of remaining string up to 6 UTF-8 characters
2668 for (len
= 1; len
< 6 && s
[len
]; len
++)
2672 msg
= utf_decodeChar(s
, len
, &idx
, &u
);
2682 /***************************************************
2683 * Parse doc comment embedded between t->ptr and p.
2684 * Remove trailing blanks and tabs from lines.
2685 * Replace all newlines with \n.
2686 * Remove leading comment character from each line.
2687 * Decide if it's a lineComment or a blockComment.
2688 * Append to previous one for this token.
2691 void Lexer::getDocComment(Token
*t
, unsigned lineComment
)
2694 unsigned char ct
= t
->ptr
[2];
2695 unsigned char *q
= t
->ptr
+ 3; // start of comment text
2698 unsigned char *qend
= p
;
2699 if (ct
== '*' || ct
== '+')
2702 /* Scan over initial row of ****'s or ++++'s or ////'s
2704 for (; q
< qend
; q
++)
2710 /* Remove trailing row of ****'s or ++++'s
2714 for (; q
< qend
; qend
--)
2721 for (; q
< qend
; q
++)
2723 unsigned char c
= *q
;
2729 if (linestart
&& c
== ct
)
2731 /* Trim preceding whitespace up to preceding \n
2733 while (buf
.offset
&& (buf
.data
[buf
.offset
- 1] == ' ' || buf
.data
[buf
.offset
- 1] == '\t'))
2745 continue; // skip the \r
2753 (q
[2] == 168 || q
[2] == 169))
2763 c
= '\n'; // replace all newlines with \n
2767 /* Trim trailing whitespace
2769 while (buf
.offset
&& (buf
.data
[buf
.offset
- 1] == ' ' || buf
.data
[buf
.offset
- 1] == '\t'))
2777 // Always end with a newline
2778 if (!buf
.offset
|| buf
.data
[buf
.offset
- 1] != '\n')
2779 buf
.writeByte('\n');
2783 // It's a line comment if the start of the doc comment comes
2784 // after other non-whitespace on the same line.
2785 unsigned char** dc
= (lineComment
&& anyToken
)
2789 // Combine with previous doc comment, if any
2791 *dc
= combineComments(*dc
, (unsigned char *)buf
.data
);
2793 *dc
= (unsigned char *)buf
.extractData();
2796 /********************************************
2797 * Combine two document comments into one.
2800 unsigned char *Lexer::combineComments(unsigned char *c1
, unsigned char *c2
)
2802 unsigned char *c
= c2
;
2807 { size_t len1
= strlen((char *)c1
);
2808 size_t len2
= strlen((char *)c2
);
2810 c
= (unsigned char *)mem
.malloc(len1
+ 1 + len2
+ 1);
2811 memcpy(c
, c1
, len1
);
2813 memcpy(c
+ len1
+ 1, c2
, len2
);
2814 c
[len1
+ 1 + len2
] = 0;
2820 /********************************************
2821 * Create an identifier in the string table.
2824 Identifier
*Lexer::idPool(const char *s
)
2826 size_t len
= strlen(s
);
2827 StringValue
*sv
= stringtable
.update(s
, len
);
2828 Identifier
*id
= (Identifier
*) sv
->ptrvalue
;
2831 id
= new Identifier(sv
->lstring
.string
, TOKidentifier
);
2837 /*********************************************
2838 * Create a unique identifier using the prefix s.
2841 Identifier
*Lexer::uniqueId(const char *s
, int num
)
2843 size_t slen
= strlen(s
);
2845 assert(slen
+ sizeof(num
) * 3 + 1 <= sizeof(buffer
));
2846 sprintf(buffer
, "%s%d", s
, num
);
2847 return idPool(buffer
);
2850 Identifier
*Lexer::uniqueId(const char *s
)
2853 return uniqueId(s
, ++num
);
2856 /****************************************
2864 static Keyword keywords
[] =
2868 { "this", TOKthis
},
2869 { "super", TOKsuper
},
2870 { "assert", TOKassert
},
2871 { "null", TOKnull
},
2872 { "true", TOKtrue
},
2873 { "false", TOKfalse
},
2874 { "cast", TOKcast
},
2876 { "delete", TOKdelete
},
2877 { "throw", TOKthrow
},
2878 { "module", TOKmodule
},
2879 { "pragma", TOKpragma
},
2880 { "typeof", TOKtypeof
},
2881 { "typeid", TOKtypeid
},
2883 { "template", TOKtemplate
},
2885 { "void", TOKvoid
},
2886 { "byte", TOKint8
},
2887 { "ubyte", TOKuns8
},
2888 { "short", TOKint16
},
2889 { "ushort", TOKuns16
},
2890 { "int", TOKint32
},
2891 { "uint", TOKuns32
},
2892 { "long", TOKint64
},
2893 { "ulong", TOKuns64
},
2894 { "cent", TOKcent
, },
2895 { "ucent", TOKucent
, },
2896 { "float", TOKfloat32
},
2897 { "double", TOKfloat64
},
2898 { "real", TOKfloat80
},
2900 { "bool", TOKbool
},
2901 { "char", TOKchar
},
2902 { "wchar", TOKwchar
},
2903 { "dchar", TOKdchar
},
2905 { "ifloat", TOKimaginary32
},
2906 { "idouble", TOKimaginary64
},
2907 { "ireal", TOKimaginary80
},
2909 { "cfloat", TOKcomplex32
},
2910 { "cdouble", TOKcomplex64
},
2911 { "creal", TOKcomplex80
},
2913 { "delegate", TOKdelegate
},
2914 { "function", TOKfunction
},
2918 { "else", TOKelse
},
2919 { "while", TOKwhile
},
2922 { "switch", TOKswitch
},
2923 { "case", TOKcase
},
2924 { "default", TOKdefault
},
2925 { "break", TOKbreak
},
2926 { "continue", TOKcontinue
},
2927 { "synchronized", TOKsynchronized
},
2928 { "return", TOKreturn
},
2929 { "goto", TOKgoto
},
2931 { "catch", TOKcatch
},
2932 { "finally", TOKfinally
},
2933 { "with", TOKwith
},
2935 { "foreach", TOKforeach
},
2936 { "foreach_reverse", TOKforeach_reverse
},
2937 { "reversed", TOKreversed
},
2938 { "scope", TOKscope
},
2940 { "struct", TOKstruct
},
2941 { "class", TOKclass
},
2942 { "interface", TOKinterface
},
2943 { "union", TOKunion
},
2944 { "enum", TOKenum
},
2945 { "import", TOKimport
},
2946 { "mixin", TOKmixin
},
2947 { "static", TOKstatic
},
2948 { "final", TOKfinal
},
2949 { "const", TOKconst
},
2950 { "typedef", TOKtypedef
},
2951 { "alias", TOKalias
},
2952 { "override", TOKoverride
},
2953 { "abstract", TOKabstract
},
2954 { "volatile", TOKvolatile
},
2955 { "debug", TOKdebug
},
2956 { "deprecated", TOKdeprecated
},
2959 { "inout", TOKinout
},
2960 { "lazy", TOKlazy
},
2961 { "auto", TOKauto
},
2963 { "align", TOKalign
},
2964 { "extern", TOKextern
},
2965 { "private", TOKprivate
},
2966 { "package", TOKpackage
},
2967 { "protected", TOKprotected
},
2968 { "public", TOKpublic
},
2969 { "export", TOKexport
},
2971 { "body", TOKbody
},
2972 { "invariant", TOKinvariant
},
2973 { "unittest", TOKunittest
},
2974 { "version", TOKversion
},
2975 //{ "manifest", TOKmanifest },
2979 { "macro", TOKmacro
},
2983 { "and", TOKandand
},
2986 { "extends", TOKextends
},
2987 { "log_error", TOKlog_error
},
2988 { "log_warning", TOKlog_warning
},
2989 { "log_info", TOKlog_info
},
2990 { "log_trace", TOKlog_trace
},
2992 { "pure", TOKpure
},
2993 { "nothrow", TOKnothrow
},
2994 { "__traits", TOKtraits
},
2995 { "__overloadset", TOKoverloadset
},
2999 int Token::isKeyword()
3001 for (unsigned u
= 0; u
< sizeof(keywords
) / sizeof(keywords
[0]); u
++)
3003 if (keywords
[u
].value
== value
)
3009 void Lexer::initKeywords()
3013 unsigned nkeywords
= sizeof(keywords
) / sizeof(keywords
[0]);
3015 if (global
.params
.Dversion
== 1)
3020 for (u
= 0; u
< nkeywords
; u
++)
3023 //printf("keyword[%d] = '%s'\n",u, keywords[u].name);
3024 s
= keywords
[u
].name
;
3025 v
= keywords
[u
].value
;
3026 sv
= stringtable
.insert(s
, strlen(s
));
3027 sv
->ptrvalue
= (void *) new Identifier(sv
->lstring
.string
,v
);
3029 //printf("tochars[%d] = '%s'\n",v, s);
3030 Token::tochars
[v
] = s
;
3033 Token::tochars
[TOKeof
] = "EOF";
3034 Token::tochars
[TOKlcurly
] = "{";
3035 Token::tochars
[TOKrcurly
] = "}";
3036 Token::tochars
[TOKlparen
] = "(";
3037 Token::tochars
[TOKrparen
] = ")";
3038 Token::tochars
[TOKlbracket
] = "[";
3039 Token::tochars
[TOKrbracket
] = "]";
3040 Token::tochars
[TOKsemicolon
] = ";";
3041 Token::tochars
[TOKcolon
] = ":";
3042 Token::tochars
[TOKcomma
] = ",";
3043 Token::tochars
[TOKdot
] = ".";
3044 Token::tochars
[TOKxor
] = "^";
3045 Token::tochars
[TOKxorass
] = "^=";
3046 Token::tochars
[TOKassign
] = "=";
3047 Token::tochars
[TOKconstruct
] = "=";
3049 Token::tochars
[TOKblit
] = "=";
3051 Token::tochars
[TOKlt
] = "<";
3052 Token::tochars
[TOKgt
] = ">";
3053 Token::tochars
[TOKle
] = "<=";
3054 Token::tochars
[TOKge
] = ">=";
3055 Token::tochars
[TOKequal
] = "==";
3056 Token::tochars
[TOKnotequal
] = "!=";
3057 Token::tochars
[TOKnotidentity
] = "!is";
3058 Token::tochars
[TOKtobool
] = "!!";
3059 Token::tochars
[TOKat
] = "@";
3061 Token::tochars
[TOKunord
] = "!<>=";
3062 Token::tochars
[TOKue
] = "!<>";
3063 Token::tochars
[TOKlg
] = "<>";
3064 Token::tochars
[TOKleg
] = "<>=";
3065 Token::tochars
[TOKule
] = "!>";
3066 Token::tochars
[TOKul
] = "!>=";
3067 Token::tochars
[TOKuge
] = "!<";
3068 Token::tochars
[TOKug
] = "!<=";
3070 Token::tochars
[TOKnot
] = "!";
3071 Token::tochars
[TOKtobool
] = "!!";
3072 Token::tochars
[TOKshl
] = "<<";
3073 Token::tochars
[TOKshr
] = ">>";
3074 Token::tochars
[TOKushr
] = ">>>";
3075 Token::tochars
[TOKadd
] = "+";
3076 Token::tochars
[TOKmin
] = "-";
3077 Token::tochars
[TOKmul
] = "*";
3078 Token::tochars
[TOKdiv
] = "/";
3079 Token::tochars
[TOKmod
] = "%";
3080 Token::tochars
[TOKslice
] = "..";
3081 Token::tochars
[TOKdotdotdot
] = "...";
3082 Token::tochars
[TOKand
] = "&";
3083 Token::tochars
[TOKandand
] = "&&";
3084 Token::tochars
[TOKor
] = "|";
3085 Token::tochars
[TOKoror
] = "||";
3086 Token::tochars
[TOKarray
] = "[]";
3087 Token::tochars
[TOKindex
] = "[i]";
3088 Token::tochars
[TOKaddress
] = "&";
3089 Token::tochars
[TOKstar
] = "*";
3090 Token::tochars
[TOKtilde
] = "~";
3091 Token::tochars
[TOKdollar
] = "$";
3092 Token::tochars
[TOKcast
] = "cast";
3093 Token::tochars
[TOKplusplus
] = "++";
3094 Token::tochars
[TOKminusminus
] = "--";
3095 Token::tochars
[TOKtype
] = "type";
3096 Token::tochars
[TOKquestion
] = "?";
3097 Token::tochars
[TOKneg
] = "-";
3098 Token::tochars
[TOKuadd
] = "+";
3099 Token::tochars
[TOKvar
] = "var";
3100 Token::tochars
[TOKaddass
] = "+=";
3101 Token::tochars
[TOKminass
] = "-=";
3102 Token::tochars
[TOKmulass
] = "*=";
3103 Token::tochars
[TOKdivass
] = "/=";
3104 Token::tochars
[TOKmodass
] = "%=";
3105 Token::tochars
[TOKshlass
] = "<<=";
3106 Token::tochars
[TOKshrass
] = ">>=";
3107 Token::tochars
[TOKushrass
] = ">>>=";
3108 Token::tochars
[TOKandass
] = "&=";
3109 Token::tochars
[TOKorass
] = "|=";
3110 Token::tochars
[TOKcatass
] = "~=";
3111 Token::tochars
[TOKcat
] = "~";
3112 Token::tochars
[TOKcall
] = "call";
3113 Token::tochars
[TOKidentity
] = "is";
3114 Token::tochars
[TOKnotidentity
] = "!is";
3115 Token::tochars
[TOKendline
] = "\\n";
3117 Token::tochars
[TOKorass
] = "|=";
3118 Token::tochars
[TOKidentifier
] = "identifier";
3121 Token::tochars
[TOKdotexp
] = "dotexp";
3122 Token::tochars
[TOKdotti
] = "dotti";
3123 Token::tochars
[TOKdotvar
] = "dotvar";
3124 Token::tochars
[TOKdottype
] = "dottype";
3125 Token::tochars
[TOKsymoff
] = "symoff";
3126 Token::tochars
[TOKtypedot
] = "typedot";
3127 Token::tochars
[TOKarraylength
] = "arraylength";
3128 Token::tochars
[TOKarrayliteral
] = "arrayliteral";
3129 Token::tochars
[TOKassocarrayliteral
] = "assocarrayliteral";
3130 Token::tochars
[TOKstructliteral
] = "structliteral";
3131 Token::tochars
[TOKstring
] = "string";
3132 Token::tochars
[TOKdsymbol
] = "symbol";
3133 Token::tochars
[TOKtuple
] = "tuple";
3134 Token::tochars
[TOKdeclaration
] = "declaration";
3135 Token::tochars
[TOKdottd
] = "dottd";
3136 Token::tochars
[TOKlogger
] = "logger";
3137 Token::tochars
[TOKon_scope_exit
] = "scope(exit)";