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
);
738 if (mod
&& id
== Id::FILE)
740 t
->ustring
= (unsigned char *)(loc
.filename
? loc
.filename
: mod
->ident
->toChars());
743 else if (mod
&& id
== Id::LINE
)
745 t
->value
= TOKint64v
;
746 t
->uns64value
= loc
.linnum
;
748 else if (id
== Id::DATE
)
750 t
->ustring
= (unsigned char *)date
;
753 else if (id
== Id::TIME
)
755 t
->ustring
= (unsigned char *)time
;
758 else if (id
== Id::VENDOR
)
761 t
->ustring
= (unsigned char *)"GDC";
763 t
->ustring
= (unsigned char *)"Digital Mars D";
767 else if (id
== Id::TIMESTAMP
)
769 t
->ustring
= (unsigned char *)timestamp
;
771 t
->value
= TOKstring
;
774 t
->len
= strlen((char *)t
->ustring
);
776 else if (id
== Id::VERSIONX
)
777 { unsigned major
= 0;
780 for (char *p
= global
.version
+ 1; 1; p
++)
784 minor
= minor
* 10 + c
- '0';
792 t
->value
= TOKint64v
;
793 t
->uns64value
= major
* 1000 + minor
;
796 else if (id
== Id::EOFX
)
799 // Advance scanner to end of file
800 while (!(*p
== 0 || *p
== 0x1A))
805 //printf("t->value = %d\n",t->value);
815 t
->value
= TOKdivass
;
824 { unsigned char c
= *p
;
843 error("unterminated /* */ comment");
850 { unsigned u
= decodeUTF();
851 if (u
== PS
|| u
== LS
)
860 if (p
[-2] == '*' && p
- 3 != t
->ptr
)
865 t
->value
= TOKcomment
;
868 else if (doDocComment
&& t
->ptr
[2] == '*' && p
- 4 != t
->ptr
)
869 { // if /** but not /**/
870 getDocComment(t
, lastLine
== linnum
);
874 case '/': // do // style comments
877 { unsigned char c
= *++p
;
893 t
->value
= TOKcomment
;
896 if (doDocComment
&& t
->ptr
[2] == '/')
897 getDocComment(t
, lastLine
== linnum
);
904 { unsigned u
= decodeUTF();
905 if (u
== PS
|| u
== LS
)
917 t
->value
= TOKcomment
;
920 if (doDocComment
&& t
->ptr
[2] == '/')
921 getDocComment(t
, lastLine
== linnum
);
934 { unsigned char c
= *p
;
969 error("unterminated /+ +/ comment");
976 { unsigned u
= decodeUTF();
977 if (u
== PS
|| u
== LS
)
987 t
->value
= TOKcomment
;
990 if (doDocComment
&& t
->ptr
[2] == '+' && p
- 4 != t
->ptr
)
991 { // if /++ but not /++/
992 getDocComment(t
, lastLine
== linnum
);
1003 { /* Note that we don't allow ._1 and ._ as being
1004 * valid floating point numbers.
1007 t
->value
= inreal(t
);
1009 else if (p
[0] == '.')
1013 t
->value
= TOKdotdotdot
;
1017 t
->value
= TOKslice
;
1028 t
->value
= TOKandass
;
1032 t
->value
= TOKandand
;
1034 error("Use 'and' instead of '&&'");
1044 t
->value
= TOKorass
;
1050 error("Use 'or' instead of '||'");
1060 t
->value
= TOKminass
;
1065 t
->value
= TOKarrow
;
1070 t
->value
= TOKminusminus
;
1080 t
->value
= TOKaddass
;
1084 t
->value
= TOKplusplus
;
1094 t
->value
= TOKle
; // <=
1100 t
->value
= TOKshlass
; // <<=
1103 t
->value
= TOKshl
; // <<
1109 t
->value
= TOKleg
; // <>=
1112 t
->value
= TOKlg
; // <>
1115 t
->value
= TOKlt
; // <
1122 t
->value
= TOKge
; // >=
1128 t
->value
= TOKshrass
; // >>=
1134 t
->value
= TOKushrass
; // >>>=
1137 t
->value
= TOKushr
; // >>>
1140 t
->value
= TOKshr
; // >>
1143 t
->value
= TOKgt
; // >
1150 if (*p
== '=' && global
.params
.Dversion
== 1)
1152 t
->value
= TOKnotidentity
; // !==
1155 t
->value
= TOKnotequal
; // !=
1163 t
->value
= TOKunord
; // !<>=
1166 t
->value
= TOKue
; // !<>
1170 t
->value
= TOKug
; // !<=
1173 t
->value
= TOKuge
; // !<
1179 t
->value
= TOKul
; // !>=
1182 t
->value
= TOKule
; // !>
1185 t
->value
= TOKnot
; // !
1192 if (*p
== '=' && global
.params
.Dversion
== 1)
1194 t
->value
= TOKidentity
; // ===
1197 t
->value
= TOKequal
; // ==
1200 t
->value
= TOKassign
; // =
1207 t
->value
= TOKcatass
; // ~=
1210 t
->value
= TOKtilde
; // ~
1213 #define NESTED(cin,tokin,cout,tokout) \
1214 case cin: nesting++; p++; t->value = tokin; return;\
1215 case cout: if (nesting == 0) {error("Unexpected '%c'", cout);} else {nesting--;} p++; t->value = tokout; return;
1217 NESTED('(', TOKlparen
, ')', TOKrparen
)
1218 NESTED('[', TOKlbracket
, ']', TOKrbracket
)
1219 NESTED('{', TOKlcurly
, '}', TOKrcurly
)
1222 #define SINGLE(c,tok) case c: p++; t->value = tok; return;
1223 SINGLE('?', TOKquestion
)
1224 SINGLE(',', TOKcomma
)
1225 SINGLE(';', TOKsemicolon
)
1226 SINGLE('$', TOKdollar
)
1235 t
->value
= TOKcolon
;
1238 #define DOUBLE(c1,tok1,c2,tok2) \
1249 DOUBLE('*', TOKmul
, '=', TOKmulass
)
1250 DOUBLE('%', TOKmod
, '=', TOKmodass
)
1251 DOUBLE('^', TOKxor
, '=', TOKxorass
)
1255 case '#': // do # style comments and pragmas
1258 do { p
++; } while (*p
!= '\n');
1268 { unsigned char c
= *p
;
1271 { unsigned u
= decodeUTF();
1273 // Check for start of unicode identifier
1277 if (u
== PS
|| u
== LS
)
1285 error("unsupported char '%c'", c
);
1287 error("unsupported char 0x%02x", c
);
1295 /*******************************************
1296 * Parse escape sequence.
1299 unsigned Lexer::escapeSequence()
1315 case 'a': c
= 7; goto Lconsume
;
1316 case 'b': c
= 8; goto Lconsume
;
1317 case 'f': c
= 12; goto Lconsume
;
1318 case 'n': c
= 10; goto Lconsume
;
1319 case 'r': c
= 13; goto Lconsume
;
1320 case 't': c
= 9; goto Lconsume
;
1321 case 'v': c
= 11; goto Lconsume
;
1343 else if (islower(c
))
1352 { error("escape hex sequence has %d hex digits instead of %d", n
, ndigits
);
1356 if (ndigits
!= 2 && !utf_isValidDchar(v
))
1357 error("invalid UTF character \\U%08x", v
);
1361 error("undefined escape hex sequence \\%c\n",c
);
1364 case '&': // named character entity
1365 for (unsigned char *idstart
= ++p
; 1; p
++)
1370 c
= HtmlNamedEntity(idstart
, p
- idstart
);
1372 { error("unnamed character entity &%.*s;", (int)(p
- idstart
), idstart
);
1380 (p
!= idstart
+ 1 && isdigit(*p
)))
1382 error("unterminated named entity");
1390 case 0x1A: // end of file
1402 v
= v
* 8 + (c
- '0');
1404 } while (++n
< 3 && isoctal(c
));
1407 error("0%03o is larger than a byte", c
);
1410 error("undefined escape sequence \\%c\n",c
);
1416 /**************************************
1419 TOK
Lexer::wysiwygStringConstant(Token
*t
, int tc
)
1424 stringbuffer
.reset();
1437 c
= '\n'; // treat EndOfLine as \n character
1443 error("unterminated string constant starting at %s", start
.toChars());
1444 t
->ustring
= (unsigned char *)"";
1453 t
->len
= stringbuffer
.offset
;
1454 stringbuffer
.writeByte(0);
1455 t
->ustring
= (unsigned char *)mem
.malloc(stringbuffer
.offset
);
1456 memcpy(t
->ustring
, stringbuffer
.data
, stringbuffer
.offset
);
1465 unsigned u
= decodeUTF();
1467 if (u
== PS
|| u
== LS
)
1469 stringbuffer
.writeUTF8(u
);
1474 stringbuffer
.writeByte(c
);
1478 /**************************************
1483 TOK
Lexer::hexStringConstant(Token
*t
)
1490 stringbuffer
.reset();
1500 continue; // skip white space
1505 // Treat isolated '\r' as if it were a '\n'
1512 error("unterminated string constant starting at %s", start
.toChars());
1513 t
->ustring
= (unsigned char *)"";
1520 { error("odd number (%d) of hex characters in hex string", n
);
1521 stringbuffer
.writeByte(v
);
1523 t
->len
= stringbuffer
.offset
;
1524 stringbuffer
.writeByte(0);
1525 t
->ustring
= (unsigned char *)mem
.malloc(stringbuffer
.offset
);
1526 memcpy(t
->ustring
, stringbuffer
.data
, stringbuffer
.offset
);
1531 if (c
>= '0' && c
<= '9')
1533 else if (c
>= 'a' && c
<= 'f')
1535 else if (c
>= 'A' && c
<= 'F')
1539 unsigned u
= decodeUTF();
1541 if (u
== PS
|| u
== LS
)
1544 error("non-hex character \\u%x", u
);
1547 error("non-hex character '%c'", c
);
1550 stringbuffer
.writeByte(v
);
1562 /**************************************
1563 * Lex delimited strings:
1564 * q"(foo(xxx))" // "foo(xxx)"
1565 * q"[foo(]" // "foo("
1566 * q"/foo]/" // "foo]"
1574 TOK
Lexer::delimitedStringConstant(Token
*t
)
1577 unsigned delimleft
= 0;
1578 unsigned delimright
= 0;
1581 Identifier
*hereid
= NULL
;
1582 unsigned blankrol
= 0;
1583 unsigned startline
= 0;
1586 stringbuffer
.reset();
1590 //printf("c = '%c'\n", c);
1603 stringbuffer
.writeUTF8(c
);
1611 c
= '\n'; // treat EndOfLine as \n character
1623 if (c
== PS
|| c
== LS
)
1640 else if (isalpha(c
) || c
== '_' || (c
>= 0x80 && isUniAlpha(c
)))
1641 { // Start of identifier; must be a heredoc
1644 scan(&t
); // read in heredoc identifier
1645 if (t
.value
!= TOKidentifier
)
1646 { error("identifier expected for heredoc, not %s", t
.toChars());
1651 //printf("hereid = '%s'\n", hereid->toChars());
1664 { error("heredoc rest of line should be blank");
1672 else if (c
== delimright
)
1678 else if (c
== delimright
)
1680 if (startline
&& isalpha(c
))
1682 unsigned char *psave
= p
;
1684 scan(&t
); // read in possible heredoc identifier
1685 //printf("endid = '%s'\n", t.ident->toChars());
1686 if (t
.value
== TOKidentifier
&& t
.ident
->equals(hereid
))
1687 { /* should check that rest of line is blank
1693 stringbuffer
.writeUTF8(c
);
1702 error("delimited string must end in %c\"", delimright
);
1703 t
->len
= stringbuffer
.offset
;
1704 stringbuffer
.writeByte(0);
1705 t
->ustring
= (unsigned char *)mem
.malloc(stringbuffer
.offset
);
1706 memcpy(t
->ustring
, stringbuffer
.data
, stringbuffer
.offset
);
1711 error("unterminated string constant starting at %s", start
.toChars());
1712 t
->ustring
= (unsigned char *)"";
1718 /**************************************
1719 * Lex delimited strings:
1720 * q{ foo(xxx) } // " foo(xxx) "
1722 * q{{foo}"}"} // "{foo}"}""
1727 TOK
Lexer::tokenStringConstant(Token
*t
)
1731 unsigned char *pstart
= ++p
;
1757 t
->len
= p
- 1 - pstart
;
1758 t
->ustring
= (unsigned char *)mem
.malloc(t
->len
+ 1);
1759 memcpy(t
->ustring
, pstart
, t
->len
);
1760 t
->ustring
[t
->len
] = 0;
1765 error("unterminated token string constant starting at %s", start
.toChars());
1766 t
->ustring
= (unsigned char *)"";
1775 /**************************************
1778 TOK
Lexer::escapeStringConstant(Token
*t
, int wide
)
1783 stringbuffer
.reset();
1795 c
= escapeSequence();
1796 stringbuffer
.writeUTF8(c
);
1800 c
= escapeSequence();
1812 c
= '\n'; // treat EndOfLine as \n character
1817 t
->len
= stringbuffer
.offset
;
1818 stringbuffer
.writeByte(0);
1819 t
->ustring
= (unsigned char *)mem
.malloc(stringbuffer
.offset
);
1820 memcpy(t
->ustring
, stringbuffer
.data
, stringbuffer
.offset
);
1827 error("unterminated string constant starting at %s", start
.toChars());
1828 t
->ustring
= (unsigned char *)"";
1838 if (c
== LS
|| c
== PS
)
1843 stringbuffer
.writeUTF8(c
);
1848 stringbuffer
.writeByte(c
);
1852 /**************************************
1855 TOK
Lexer::charConstant(Token
*t
, int wide
)
1860 //printf("Lexer::charConstant\n");
1869 t
->uns64value
= escapeSequence();
1875 t
->uns64value
= escapeSequence();
1880 t
->uns64value
= escapeSequence();
1892 error("unterminated character constant");
1901 if (c
== LS
|| c
== PS
)
1903 if (c
< 0xD800 || (c
>= 0xE000 && c
< 0xFFFE))
1913 { error("unterminated character constant");
1920 /***************************************
1921 * Get postfix of string literal.
1924 void Lexer::stringPostfix(Token
*t
)
1941 /***************************************
1942 * Read \u or \U unicode sequence
1948 unsigned Lexer::wchar(unsigned u
)
1955 nchars
= (u
== 'U') ? 8 : 4;
1964 { error("\\%c sequence must be followed by %d hex characters", u
, nchars
);
1969 else if (islower(c
))
1980 /**************************************
1982 * If it's an integer, store it in tok.TKutok.Vlong.
1983 * integers can be decimal, octal or hex
1984 * Handle the suffixes U, UL, LU, L, etc.
1985 * If it's double, store it in tok.TKutok.Vdouble.
1991 TOK
Lexer::number(Token
*t
)
1993 // We use a state machine to collect numbers
1994 enum STATE
{ STATE_initial
, STATE_0
, STATE_decimal
, STATE_octal
, STATE_octale
,
1995 STATE_hex
, STATE_binary
, STATE_hex0
, STATE_binary0
,
1996 STATE_hexh
, STATE_error
};
2000 { FLAGS_decimal
= 1, // decimal
2001 FLAGS_unsigned
= 2, // u or U suffix
2002 FLAGS_long
= 4, // l or L suffix
2004 enum FLAGS flags
= FLAGS_decimal
;
2009 unsigned char *start
;
2012 //printf("Lexer::number()\n");
2013 state
= STATE_initial
;
2015 stringbuffer
.reset();
2022 case STATE_initial
: // opening state
2026 state
= STATE_decimal
;
2030 flags
= (FLAGS
) (flags
& ~FLAGS_decimal
);
2044 if (p
[1] == '.') // .. is a separate token
2057 state
= STATE_binary0
;
2060 case '0': case '1': case '2': case '3':
2061 case '4': case '5': case '6': case '7':
2062 state
= STATE_octal
;
2066 case '8': case '9': case 'A':
2067 case 'C': case 'D': case 'F':
2068 case 'a': case 'c': case 'd': case 'f':
2074 state
= STATE_octal
;
2088 case STATE_decimal
: // reading decimal number
2093 || c
== 'H' || c
== 'h'
2097 if (c
== '_') // ignore embedded _
2101 if (c
== '.' && p
[1] != '.')
2103 else if (c
== 'i' || c
== 'f' || c
== 'F' ||
2104 c
== 'e' || c
== 'E')
2106 real
: // It's a real number. Back up and rescan as a real
2110 else if (c
== 'L' && p
[1] == 'i')
2116 case STATE_hex0
: // reading hex number
2120 if (c
== '_') // ignore embedded _
2124 if (c
== '.' && p
[1] != '.')
2126 if (c
== 'P' || c
== 'p' || c
== 'i')
2128 if (state
== STATE_hex0
)
2129 error("Hex digit expected, not '%c'", c
);
2138 case STATE_hexh
: // parse numbers like 0FFh
2141 if (c
== 'H' || c
== 'h')
2149 // Check for something like 1E3 or 0E24
2150 if (memchr((char *)stringbuffer
.data
, 'E', stringbuffer
.offset
) ||
2151 memchr((char *)stringbuffer
.data
, 'e', stringbuffer
.offset
))
2153 error("Hex digit expected, not '%c'", c
);
2160 case STATE_octal
: // reading octal number
2161 case STATE_octale
: // reading octal number with non-octal digits
2166 || c
== 'H' || c
== 'h'
2170 if (c
== '_') // ignore embedded _
2174 if (c
== '.' && p
[1] != '.')
2180 state
= STATE_octale
;
2187 case STATE_binary0
: // starting binary number
2188 case STATE_binary
: // reading binary number
2189 if (c
!= '0' && c
!= '1')
2193 || c
== 'H' || c
== 'h'
2197 if (c
== '_') // ignore embedded _
2201 if (state
== STATE_binary0
)
2202 { error("binary digit expected");
2203 state
= STATE_error
;
2209 state
= STATE_binary
;
2212 case STATE_error
: // for error recovery
2213 if (!isdigit(c
)) // scan until non-digit
2220 stringbuffer
.writeByte(c
);
2224 stringbuffer
.writeByte(0); // terminate string
2225 if (state
== STATE_octale
)
2226 error("Octal digit expected");
2228 uinteger_t n
; // unsigned >=64 bit integer type
2230 if (stringbuffer
.offset
== 2 && (state
== STATE_decimal
|| state
== STATE_0
))
2231 n
= stringbuffer
.data
[0] - '0';
2234 // Convert string to integer
2237 n
= strtoull((char *)stringbuffer
.data
,NULL
,base
);
2238 if (errno
== ERANGE
)
2239 error("integer overflow");
2241 // Not everybody implements strtoull()
2242 char *p
= (char *)stringbuffer
.data
;
2247 if (p
[1] == 'x' || p
[1] == 'X')
2249 else if (p
[1] == 'b' || p
[1] == 'B')
2251 else if (isdigit(p
[1]))
2258 if (*p
>= '0' && *p
<= '9')
2260 else if (*p
>= 'a' && *p
<= 'z')
2262 else if (*p
>= 'A' && *p
<= 'Z')
2268 if (n
&& n
* r
+ d
<= n
)
2270 error ("integer overflow");
2278 if (sizeof(n
) > 8 &&
2279 n
> 0xFFFFFFFFFFFFFFFFULL
) // if n needs more than 64 bits
2280 error("integer overflow");
2283 // Parse trailing 'u', 'U', 'l' or 'L' in any combination
2294 if (1 || !global
.params
.useDeprecated
)
2295 error("'l' suffix is deprecated, use 'L' instead");
2301 error("unrecognized token");
2302 flags
= (FLAGS
) (flags
| f
);
2313 /* Octal or Hexadecimal constant.
2314 * First that fits: int, uint, long, ulong
2316 if (n
& 0x8000000000000000LL
)
2318 else if (n
& 0xFFFFFFFF00000000LL
)
2320 else if (n
& 0x80000000)
2327 /* First that fits: int, long, long long
2329 if (n
& 0x8000000000000000LL
)
2330 { error("signed integer overflow");
2333 else if (n
& 0xFFFFFFFF80000000LL
)
2339 case FLAGS_unsigned
:
2340 case FLAGS_decimal
| FLAGS_unsigned
:
2341 /* First that fits: uint, ulong
2343 if (n
& 0xFFFFFFFF00000000LL
)
2349 case FLAGS_decimal
| FLAGS_long
:
2350 if (n
& 0x8000000000000000LL
)
2351 { error("signed integer overflow");
2359 if (n
& 0x8000000000000000LL
)
2365 case FLAGS_unsigned
| FLAGS_long
:
2366 case FLAGS_decimal
| FLAGS_unsigned
| FLAGS_long
:
2372 printf("%x\n",flags
);
2380 /**************************************
2381 * Read in characters, converting them to real.
2383 * Exponent overflow not detected.
2384 * Too much requested precision is not detected.
2387 TOK
Lexer::inreal(Token
*t
)
2391 assert(*p
== '.' || isdigit(*p
));
2400 case TOKimaginary32v
:
2401 case TOKimaginary64v
:
2402 case TOKimaginary80v
:
2410 #endif /* __DMC__ */
2413 char hex
; // is this a hexadecimal-floating-constant?
2416 //printf("Lexer::inreal()\n");
2417 stringbuffer
.reset();
2423 // Get next char from input
2425 //printf("dblstate = %d, c = '%c'\n", dblstate, c);
2430 case 0: // opening state
2441 if (c
== 'X' || c
== 'x')
2445 case 1: // digits to left of .
2446 case 3: // digits to right of .
2447 case 7: // continuing exponent digits
2448 if (!isdigit(c
) && !(hex
&& isxdigit(c
)))
2451 goto Lnext
; // ignore embedded '_'
2457 case 2: // no more digits to left of .
2462 case 4: // no more digits to right of .
2463 if ((c
== 'E' || c
== 'e') ||
2464 hex
&& (c
== 'P' || c
== 'p'))
2466 hex
= 0; // exponent is always decimal
2470 error("binary-exponent-part required");
2473 case 5: // looking immediately to right of E
2475 if (c
== '-' || c
== '+')
2477 case 6: // 1st exponent digit expected
2479 error("exponent expected");
2483 case 8: // past end of exponent digits
2488 stringbuffer
.writeByte(c
);
2493 stringbuffer
.writeByte(0);
2495 #if _WIN32 && __DMC__
2496 char *save
= __locale_decpoint
;
2497 __locale_decpoint
= ".";
2500 t
->float80value
= real_t::parse((char *)stringbuffer
.data
, real_t::LongDouble
);
2502 t
->float80value
= strtold((char *)stringbuffer
.data
, NULL
);
2510 real_t::parse((char *)stringbuffer
.data
, real_t::Float
);
2512 strtof((char *)stringbuffer
.data
, NULL
);
2514 result
= TOKfloat32v
;
2520 real_t::parse((char *)stringbuffer
.data
, real_t::Double
);
2522 strtod((char *)stringbuffer
.data
, NULL
);
2524 result
= TOKfloat64v
;
2528 if (!global
.params
.useDeprecated
)
2529 error("'l' suffix is deprecated, use 'L' instead");
2531 result
= TOKfloat80v
;
2535 if (*p
== 'i' || *p
== 'I')
2537 if (!global
.params
.useDeprecated
&& *p
== 'I')
2538 error("'I' suffix is deprecated, use 'i' instead");
2543 result
= TOKimaginary32v
;
2546 result
= TOKimaginary64v
;
2549 result
= TOKimaginary80v
;
2553 #if _WIN32 && __DMC__
2554 __locale_decpoint
= save
;
2556 if (errno
== ERANGE
)
2557 error("number is not representable");
2561 /*********************************************
2563 * Currently, the only pragma supported is:
2564 * #line linnum [filespec]
2567 void Lexer::pragma()
2571 char *filespec
= NULL
;
2572 Loc loc
= this->loc
;
2574 while (isblank(*p
)) p
++;
2579 if (tok
.value
!= TOKidentifier
|| tok
.ident
!= Id::line
)
2583 if (tok
.value
== TOKint32v
|| tok
.value
== TOKint64v
)
2584 linnum
= tok
.uns64value
- 1;
2596 this->loc
.linnum
= linnum
;
2598 this->loc
.filename
= filespec
;
2614 continue; // skip white space
2617 if (mod
&& memcmp(p
, "__FILE__", 8) == 0)
2620 filespec
= mem
.strdup(loc
.filename
? loc
.filename
: mod
->ident
->toChars());
2627 stringbuffer
.reset();
2642 stringbuffer
.writeByte(0);
2643 filespec
= mem
.strdup((char *)stringbuffer
.data
);
2649 { unsigned u
= decodeUTF();
2650 if (u
== PS
|| u
== LS
)
2653 stringbuffer
.writeByte(c
);
2663 { unsigned u
= decodeUTF();
2664 if (u
== PS
|| u
== LS
)
2672 error(loc
, "#line integer [\"filespec\"]\\n expected");
2676 /********************************************
2677 * Decode UTF character.
2678 * Issue error messages for invalid sequences.
2679 * Return decoded character, advance p to last character in UTF sequence.
2682 unsigned Lexer::decodeUTF()
2686 unsigned char *s
= p
;
2694 // Check length of remaining string up to 6 UTF-8 characters
2695 for (len
= 1; len
< 6 && s
[len
]; len
++)
2699 msg
= utf_decodeChar(s
, len
, &idx
, &u
);
2709 /***************************************************
2710 * Parse doc comment embedded between t->ptr and p.
2711 * Remove trailing blanks and tabs from lines.
2712 * Replace all newlines with \n.
2713 * Remove leading comment character from each line.
2714 * Decide if it's a lineComment or a blockComment.
2715 * Append to previous one for this token.
2718 void Lexer::getDocComment(Token
*t
, unsigned lineComment
)
2721 unsigned char ct
= t
->ptr
[2];
2722 unsigned char *q
= t
->ptr
+ 3; // start of comment text
2725 unsigned char *qend
= p
;
2726 if (ct
== '*' || ct
== '+')
2729 /* Scan over initial row of ****'s or ++++'s or ////'s
2731 for (; q
< qend
; q
++)
2737 /* Remove trailing row of ****'s or ++++'s
2741 for (; q
< qend
; qend
--)
2748 for (; q
< qend
; q
++)
2750 unsigned char c
= *q
;
2756 if (linestart
&& c
== ct
)
2758 /* Trim preceding whitespace up to preceding \n
2760 while (buf
.offset
&& (buf
.data
[buf
.offset
- 1] == ' ' || buf
.data
[buf
.offset
- 1] == '\t'))
2772 continue; // skip the \r
2780 (q
[2] == 168 || q
[2] == 169))
2790 c
= '\n'; // replace all newlines with \n
2794 /* Trim trailing whitespace
2796 while (buf
.offset
&& (buf
.data
[buf
.offset
- 1] == ' ' || buf
.data
[buf
.offset
- 1] == '\t'))
2804 // Always end with a newline
2805 if (!buf
.offset
|| buf
.data
[buf
.offset
- 1] != '\n')
2806 buf
.writeByte('\n');
2810 // It's a line comment if the start of the doc comment comes
2811 // after other non-whitespace on the same line.
2812 unsigned char** dc
= (lineComment
&& anyToken
)
2816 // Combine with previous doc comment, if any
2818 *dc
= combineComments(*dc
, (unsigned char *)buf
.data
);
2820 *dc
= (unsigned char *)buf
.extractData();
2823 /********************************************
2824 * Combine two document comments into one.
2827 unsigned char *Lexer::combineComments(unsigned char *c1
, unsigned char *c2
)
2829 unsigned char *c
= c2
;
2834 { size_t len1
= strlen((char *)c1
);
2835 size_t len2
= strlen((char *)c2
);
2837 c
= (unsigned char *)mem
.malloc(len1
+ 1 + len2
+ 1);
2838 memcpy(c
, c1
, len1
);
2840 memcpy(c
+ len1
+ 1, c2
, len2
);
2841 c
[len1
+ 1 + len2
] = 0;
2847 /********************************************
2848 * Create an identifier in the string table.
2851 Identifier
*Lexer::idPool(const char *s
)
2853 size_t len
= strlen(s
);
2854 StringValue
*sv
= stringtable
.update(s
, len
);
2855 Identifier
*id
= (Identifier
*) sv
->ptrvalue
;
2858 id
= new Identifier(sv
->lstring
.string
, TOKidentifier
);
2864 /*********************************************
2865 * Create a unique identifier using the prefix s.
2868 Identifier
*Lexer::uniqueId(const char *s
, int num
)
2870 size_t slen
= strlen(s
);
2872 assert(slen
+ sizeof(num
) * 3 + 1 <= sizeof(buffer
));
2873 sprintf(buffer
, "%s%d", s
, num
);
2874 return idPool(buffer
);
2877 Identifier
*Lexer::uniqueId(const char *s
)
2880 return uniqueId(s
, ++num
);
2883 /****************************************
2891 static Keyword keywords
[] =
2895 { "this", TOKthis
},
2896 { "super", TOKsuper
},
2897 { "assert", TOKassert
},
2898 { "null", TOKnull
},
2899 { "true", TOKtrue
},
2900 { "false", TOKfalse
},
2901 { "cast", TOKcast
},
2903 { "delete", TOKdelete
},
2904 { "throw", TOKthrow
},
2905 { "module", TOKmodule
},
2906 { "pragma", TOKpragma
},
2907 { "typeof", TOKtypeof
},
2908 { "typeid", TOKtypeid
},
2910 { "template", TOKtemplate
},
2912 { "void", TOKvoid
},
2913 { "byte", TOKint8
},
2914 { "ubyte", TOKuns8
},
2915 { "short", TOKint16
},
2916 { "ushort", TOKuns16
},
2917 { "int", TOKint32
},
2918 { "uint", TOKuns32
},
2919 { "long", TOKint64
},
2920 { "ulong", TOKuns64
},
2921 { "cent", TOKcent
, },
2922 { "ucent", TOKucent
, },
2923 { "float", TOKfloat32
},
2924 { "double", TOKfloat64
},
2925 { "real", TOKfloat80
},
2927 { "bool", TOKbool
},
2928 { "char", TOKchar
},
2929 { "wchar", TOKwchar
},
2930 { "dchar", TOKdchar
},
2932 { "ifloat", TOKimaginary32
},
2933 { "idouble", TOKimaginary64
},
2934 { "ireal", TOKimaginary80
},
2936 { "cfloat", TOKcomplex32
},
2937 { "cdouble", TOKcomplex64
},
2938 { "creal", TOKcomplex80
},
2940 { "delegate", TOKdelegate
},
2941 { "function", TOKfunction
},
2945 { "else", TOKelse
},
2946 { "while", TOKwhile
},
2949 { "switch", TOKswitch
},
2950 { "case", TOKcase
},
2951 { "default", TOKdefault
},
2952 { "break", TOKbreak
},
2953 { "continue", TOKcontinue
},
2954 { "synchronized", TOKsynchronized
},
2955 { "return", TOKreturn
},
2956 { "goto", TOKgoto
},
2958 { "catch", TOKcatch
},
2959 { "finally", TOKfinally
},
2960 { "with", TOKwith
},
2962 { "foreach", TOKforeach
},
2963 { "foreach_reverse", TOKforeach_reverse
},
2964 { "reversed", TOKreversed
},
2965 { "scope", TOKscope
},
2967 { "struct", TOKstruct
},
2968 { "class", TOKclass
},
2969 { "interface", TOKinterface
},
2970 { "union", TOKunion
},
2971 { "enum", TOKenum
},
2972 { "import", TOKimport
},
2973 { "mixin", TOKmixin
},
2974 { "static", TOKstatic
},
2975 { "final", TOKfinal
},
2976 { "const", TOKconst
},
2977 { "typedef", TOKtypedef
},
2978 { "alias", TOKalias
},
2979 { "override", TOKoverride
},
2980 { "abstract", TOKabstract
},
2981 { "volatile", TOKvolatile
},
2982 { "debug", TOKdebug
},
2983 { "deprecated", TOKdeprecated
},
2986 { "inout", TOKinout
},
2987 { "lazy", TOKlazy
},
2988 { "auto", TOKauto
},
2990 { "align", TOKalign
},
2991 { "extern", TOKextern
},
2992 { "private", TOKprivate
},
2993 { "package", TOKpackage
},
2994 { "protected", TOKprotected
},
2995 { "public", TOKpublic
},
2996 { "export", TOKexport
},
2998 { "body", TOKbody
},
2999 { "invariant", TOKinvariant
},
3000 { "unittest", TOKunittest
},
3001 { "version", TOKversion
},
3002 //{ "manifest", TOKmanifest },
3006 { "macro", TOKmacro
},
3010 { "and", TOKandand
},
3013 { "extends", TOKextends
},
3014 { "implements", TOKimplements
},
3015 { "log_error", TOKlog_error
},
3016 { "log_warning", TOKlog_warning
},
3017 { "log_info", TOKlog_info
},
3018 { "log_trace", TOKlog_trace
},
3020 { "pure", TOKpure
},
3021 { "nothrow", TOKnothrow
},
3022 { "__traits", TOKtraits
},
3023 { "__overloadset", TOKoverloadset
},
3027 int Token::isKeyword()
3029 for (unsigned u
= 0; u
< sizeof(keywords
) / sizeof(keywords
[0]); u
++)
3031 if (keywords
[u
].value
== value
)
3037 void Lexer::initKeywords()
3041 unsigned nkeywords
= sizeof(keywords
) / sizeof(keywords
[0]);
3043 if (global
.params
.Dversion
== 1)
3048 for (u
= 0; u
< nkeywords
; u
++)
3051 //printf("keyword[%d] = '%s'\n",u, keywords[u].name);
3052 s
= keywords
[u
].name
;
3053 v
= keywords
[u
].value
;
3054 sv
= stringtable
.insert(s
, strlen(s
));
3055 sv
->ptrvalue
= (void *) new Identifier(sv
->lstring
.string
,v
);
3057 //printf("tochars[%d] = '%s'\n",v, s);
3058 Token::tochars
[v
] = s
;
3061 Token::tochars
[TOKeof
] = "EOF";
3062 Token::tochars
[TOKlcurly
] = "{";
3063 Token::tochars
[TOKrcurly
] = "}";
3064 Token::tochars
[TOKlparen
] = "(";
3065 Token::tochars
[TOKrparen
] = ")";
3066 Token::tochars
[TOKlbracket
] = "[";
3067 Token::tochars
[TOKrbracket
] = "]";
3068 Token::tochars
[TOKsemicolon
] = ";";
3069 Token::tochars
[TOKcolon
] = ":";
3070 Token::tochars
[TOKcomma
] = ",";
3071 Token::tochars
[TOKdot
] = ".";
3072 Token::tochars
[TOKxor
] = "^";
3073 Token::tochars
[TOKxorass
] = "^=";
3074 Token::tochars
[TOKassign
] = "=";
3075 Token::tochars
[TOKconstruct
] = "=";
3077 Token::tochars
[TOKblit
] = "=";
3079 Token::tochars
[TOKlt
] = "<";
3080 Token::tochars
[TOKgt
] = ">";
3081 Token::tochars
[TOKle
] = "<=";
3082 Token::tochars
[TOKge
] = ">=";
3083 Token::tochars
[TOKequal
] = "==";
3084 Token::tochars
[TOKnotequal
] = "!=";
3085 Token::tochars
[TOKnotidentity
] = "!is";
3086 Token::tochars
[TOKtobool
] = "!!";
3087 Token::tochars
[TOKat
] = "@";
3089 Token::tochars
[TOKunord
] = "!<>=";
3090 Token::tochars
[TOKue
] = "!<>";
3091 Token::tochars
[TOKlg
] = "<>";
3092 Token::tochars
[TOKleg
] = "<>=";
3093 Token::tochars
[TOKule
] = "!>";
3094 Token::tochars
[TOKul
] = "!>=";
3095 Token::tochars
[TOKuge
] = "!<";
3096 Token::tochars
[TOKug
] = "!<=";
3098 Token::tochars
[TOKnot
] = "!";
3099 Token::tochars
[TOKtobool
] = "!!";
3100 Token::tochars
[TOKshl
] = "<<";
3101 Token::tochars
[TOKshr
] = ">>";
3102 Token::tochars
[TOKushr
] = ">>>";
3103 Token::tochars
[TOKadd
] = "+";
3104 Token::tochars
[TOKmin
] = "-";
3105 Token::tochars
[TOKmul
] = "*";
3106 Token::tochars
[TOKdiv
] = "/";
3107 Token::tochars
[TOKmod
] = "%";
3108 Token::tochars
[TOKslice
] = "..";
3109 Token::tochars
[TOKdotdotdot
] = "...";
3110 Token::tochars
[TOKand
] = "&";
3111 Token::tochars
[TOKandand
] = "&&";
3112 Token::tochars
[TOKor
] = "|";
3113 Token::tochars
[TOKoror
] = "||";
3114 Token::tochars
[TOKarray
] = "[]";
3115 Token::tochars
[TOKindex
] = "[i]";
3116 Token::tochars
[TOKaddress
] = "&";
3117 Token::tochars
[TOKstar
] = "*";
3118 Token::tochars
[TOKtilde
] = "~";
3119 Token::tochars
[TOKdollar
] = "$";
3120 Token::tochars
[TOKcast
] = "cast";
3121 Token::tochars
[TOKplusplus
] = "++";
3122 Token::tochars
[TOKminusminus
] = "--";
3123 Token::tochars
[TOKtype
] = "type";
3124 Token::tochars
[TOKquestion
] = "?";
3125 Token::tochars
[TOKneg
] = "-";
3126 Token::tochars
[TOKuadd
] = "+";
3127 Token::tochars
[TOKvar
] = "var";
3128 Token::tochars
[TOKaddass
] = "+=";
3129 Token::tochars
[TOKminass
] = "-=";
3130 Token::tochars
[TOKmulass
] = "*=";
3131 Token::tochars
[TOKdivass
] = "/=";
3132 Token::tochars
[TOKmodass
] = "%=";
3133 Token::tochars
[TOKshlass
] = "<<=";
3134 Token::tochars
[TOKshrass
] = ">>=";
3135 Token::tochars
[TOKushrass
] = ">>>=";
3136 Token::tochars
[TOKandass
] = "&=";
3137 Token::tochars
[TOKorass
] = "|=";
3138 Token::tochars
[TOKcatass
] = "~=";
3139 Token::tochars
[TOKcat
] = "~";
3140 Token::tochars
[TOKcall
] = "call";
3141 Token::tochars
[TOKidentity
] = "is";
3142 Token::tochars
[TOKnotidentity
] = "!is";
3143 Token::tochars
[TOKendline
] = "\\n";
3145 Token::tochars
[TOKorass
] = "|=";
3146 Token::tochars
[TOKidentifier
] = "identifier";
3149 Token::tochars
[TOKdotexp
] = "dotexp";
3150 Token::tochars
[TOKdotti
] = "dotti";
3151 Token::tochars
[TOKdotvar
] = "dotvar";
3152 Token::tochars
[TOKdottype
] = "dottype";
3153 Token::tochars
[TOKsymoff
] = "symoff";
3154 Token::tochars
[TOKtypedot
] = "typedot";
3155 Token::tochars
[TOKarraylength
] = "arraylength";
3156 Token::tochars
[TOKarrayliteral
] = "arrayliteral";
3157 Token::tochars
[TOKassocarrayliteral
] = "assocarrayliteral";
3158 Token::tochars
[TOKstructliteral
] = "structliteral";
3159 Token::tochars
[TOKstring
] = "string";
3160 Token::tochars
[TOKdsymbol
] = "symbol";
3161 Token::tochars
[TOKtuple
] = "tuple";
3162 Token::tochars
[TOKdeclaration
] = "declaration";
3163 Token::tochars
[TOKdottd
] = "dottd";
3164 Token::tochars
[TOKlogger
] = "logger";
3165 Token::tochars
[TOKon_scope_exit
] = "scope(exit)";