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' && p
[i
] != '\r') {
519 i
= 0; // End-of-file always has no indent
521 error("unexpected indentation (expected %d tabs, not %d)",
523 } else if (i
< indent
) {
525 t
->value
= TOKrcurly
;
529 } /* else ignore blank line */
532 //printf("p = %p, *p = '%c'\n",p,*p);
537 t
->value
= TOKeof
; // end of file
545 continue; // skip white space
548 if (p
[1] == '\n') { // if CRLF
556 if (dltSyntax
&& !nesting
) {
558 t
->value
= TOKendline
;
561 continue; // Ignore newlines inside brackets
562 case '0': case '1': case '2': case '3': case '4':
563 case '5': case '6': case '7': case '8': case '9':
564 t
->value
= number(t
);
569 t
->value
= charConstant(t
, 0);
573 t
->value
= stringConstant(t
,0);
581 t
->value
= charConstant(t
, 1);
584 else if (p
[1] == '"')
587 t
->value
= stringConstant(t
, 1);
592 t
->value
= charConstant(t
,0);
600 t
->value
= wysiwygStringConstant(t
, *p
);
607 t
->value
= hexStringConstant(t
);
615 t
->value
= delimitedStringConstant(t
);
618 else if (p
[1] == '{')
621 t
->value
= tokenStringConstant(t
);
629 t
->value
= escapeStringConstant(t
,0);
632 case '\\': // escaped string literal
635 stringbuffer
.reset();
644 c
= escapeSequence();
645 stringbuffer
.writeUTF8(c
);
649 c
= escapeSequence();
650 stringbuffer
.writeByte(c
);
653 } while (*p
== '\\');
654 t
->len
= stringbuffer
.offset
;
655 stringbuffer
.writeByte(0);
656 t
->ustring
= (unsigned char *)mem
.malloc(stringbuffer
.offset
);
657 memcpy(t
->ustring
, stringbuffer
.data
, stringbuffer
.offset
);
659 t
->value
= TOKstring
;
666 case 'a': case 'b': case 'c': case 'd': case 'e':
667 case 'f': case 'g': case 'h': case 'i': case 'j':
668 case 'k': case 'm': case 'n': case 'o':
670 case 'p': /*case 'q': case 'r':*/ case 's': case 't':
672 case 'p': case 'q': /*case 'r':*/ case 's': case 't':
674 case 'u': case 'v': case 'w': /*case 'x':*/ case 'y':
676 case 'A': case 'B': case 'C': case 'D': case 'E':
677 case 'F': case 'G': case 'H': case 'I': case 'J':
678 case 'K': case 'M': case 'N': case 'O':
679 case 'P': case 'Q': case 'R': case 'S': case 'T':
680 case 'U': case 'V': case 'W': case 'X': case 'Y':
691 } while (isidchar(c
) || (c
& 0x80 && isUniAlpha(decodeUTF())));
692 sv
= stringtable
.update((char *)t
->ptr
, p
- t
->ptr
);
693 id
= (Identifier
*) sv
->ptrvalue
;
695 { id
= new Identifier(sv
->lstring
.string
,TOKidentifier
);
699 t
->value
= (enum TOK
) id
->value
;
701 if (*t
->ptr
== '_') // if special identifier token
703 static char date
[11+1];
704 static char time
[8+1];
705 static char timestamp
[24+1];
707 if (!date
[0]) // lazy evaluation
714 sprintf(date
, "%.6s %.4s", p
+ 4, p
+ 20);
715 sprintf(time
, "%.8s", p
+ 11);
716 sprintf(timestamp
, "%.24s", p
);
719 if (mod
&& id
== Id::FILE)
721 t
->ustring
= (unsigned char *)(loc
.filename
? loc
.filename
: mod
->ident
->toChars());
724 else if (mod
&& id
== Id::LINE
)
726 t
->value
= TOKint64v
;
727 t
->uns64value
= loc
.linnum
;
729 else if (id
== Id::DATE
)
731 t
->ustring
= (unsigned char *)date
;
734 else if (id
== Id::TIME
)
736 t
->ustring
= (unsigned char *)time
;
739 else if (id
== Id::VENDOR
)
742 t
->ustring
= (unsigned char *)"GDC";
744 t
->ustring
= (unsigned char *)"Digital Mars D";
748 else if (id
== Id::TIMESTAMP
)
750 t
->ustring
= (unsigned char *)timestamp
;
752 t
->value
= TOKstring
;
755 t
->len
= strlen((char *)t
->ustring
);
757 else if (id
== Id::VERSIONX
)
758 { unsigned major
= 0;
761 for (char *p
= global
.version
+ 1; 1; p
++)
765 minor
= minor
* 10 + c
- '0';
773 t
->value
= TOKint64v
;
774 t
->uns64value
= major
* 1000 + minor
;
777 else if (id
== Id::EOFX
)
780 // Advance scanner to end of file
781 while (!(*p
== 0 || *p
== 0x1A))
786 //printf("t->value = %d\n",t->value);
796 t
->value
= TOKdivass
;
805 { unsigned char c
= *p
;
824 error("unterminated /* */ comment");
831 { unsigned u
= decodeUTF();
832 if (u
== PS
|| u
== LS
)
841 if (p
[-2] == '*' && p
- 3 != t
->ptr
)
846 t
->value
= TOKcomment
;
849 else if (doDocComment
&& t
->ptr
[2] == '*' && p
- 4 != t
->ptr
)
850 { // if /** but not /**/
851 getDocComment(t
, lastLine
== linnum
);
855 case '/': // do // style comments
858 { unsigned char c
= *++p
;
874 t
->value
= TOKcomment
;
877 if (doDocComment
&& t
->ptr
[2] == '/')
878 getDocComment(t
, lastLine
== linnum
);
885 { unsigned u
= decodeUTF();
886 if (u
== PS
|| u
== LS
)
898 t
->value
= TOKcomment
;
901 if (doDocComment
&& t
->ptr
[2] == '/')
902 getDocComment(t
, lastLine
== linnum
);
915 { unsigned char c
= *p
;
950 error("unterminated /+ +/ comment");
957 { unsigned u
= decodeUTF();
958 if (u
== PS
|| u
== LS
)
968 t
->value
= TOKcomment
;
971 if (doDocComment
&& t
->ptr
[2] == '+' && p
- 4 != t
->ptr
)
972 { // if /++ but not /++/
973 getDocComment(t
, lastLine
== linnum
);
984 { /* Note that we don't allow ._1 and ._ as being
985 * valid floating point numbers.
988 t
->value
= inreal(t
);
990 else if (p
[0] == '.')
994 t
->value
= TOKdotdotdot
;
1009 t
->value
= TOKandass
;
1013 t
->value
= TOKandand
;
1015 error("Use 'and' instead of '&&'");
1025 t
->value
= TOKorass
;
1031 error("Use 'or' instead of '||'");
1041 t
->value
= TOKminass
;
1046 t
->value
= TOKarrow
;
1051 t
->value
= TOKminusminus
;
1061 t
->value
= TOKaddass
;
1065 t
->value
= TOKplusplus
;
1075 t
->value
= TOKle
; // <=
1081 t
->value
= TOKshlass
; // <<=
1084 t
->value
= TOKshl
; // <<
1090 t
->value
= TOKleg
; // <>=
1093 t
->value
= TOKlg
; // <>
1096 t
->value
= TOKlt
; // <
1103 t
->value
= TOKge
; // >=
1109 t
->value
= TOKshrass
; // >>=
1115 t
->value
= TOKushrass
; // >>>=
1118 t
->value
= TOKushr
; // >>>
1121 t
->value
= TOKshr
; // >>
1124 t
->value
= TOKgt
; // >
1131 if (*p
== '=' && global
.params
.Dversion
== 1)
1133 t
->value
= TOKnotidentity
; // !==
1136 t
->value
= TOKnotequal
; // !=
1144 t
->value
= TOKunord
; // !<>=
1147 t
->value
= TOKue
; // !<>
1151 t
->value
= TOKug
; // !<=
1154 t
->value
= TOKuge
; // !<
1160 t
->value
= TOKul
; // !>=
1163 t
->value
= TOKule
; // !>
1166 t
->value
= TOKnot
; // !
1173 if (*p
== '=' && global
.params
.Dversion
== 1)
1175 t
->value
= TOKidentity
; // ===
1178 t
->value
= TOKequal
; // ==
1181 t
->value
= TOKassign
; // =
1188 t
->value
= TOKcatass
; // ~=
1191 t
->value
= TOKtilde
; // ~
1194 #define NESTED(cin,tokin,cout,tokout) \
1195 case cin: nesting++; p++; t->value = tokin; return;\
1196 case cout: if (nesting == 0) {error("Unexpected '%c'", cout);} else {nesting--;} p++; t->value = tokout; return;
1198 NESTED('(', TOKlparen
, ')', TOKrparen
)
1199 NESTED('[', TOKlbracket
, ']', TOKrbracket
)
1200 NESTED('{', TOKlcurly
, '}', TOKrcurly
)
1203 #define SINGLE(c,tok) case c: p++; t->value = tok; return;
1204 SINGLE('?', TOKquestion
)
1205 SINGLE(',', TOKcomma
)
1206 SINGLE(';', TOKsemicolon
)
1207 SINGLE('$', TOKdollar
)
1216 t
->value
= TOKcolon
;
1219 #define DOUBLE(c1,tok1,c2,tok2) \
1230 DOUBLE('*', TOKmul
, '=', TOKmulass
)
1231 DOUBLE('%', TOKmod
, '=', TOKmodass
)
1232 DOUBLE('^', TOKxor
, '=', TOKxorass
)
1236 case '#': // do # style comments and pragmas
1239 do { p
++; } while (*p
!= '\n');
1249 { unsigned char c
= *p
;
1252 { unsigned u
= decodeUTF();
1254 // Check for start of unicode identifier
1258 if (u
== PS
|| u
== LS
)
1266 error("unsupported char '%c'", c
);
1268 error("unsupported char 0x%02x", c
);
1276 /*******************************************
1277 * Parse escape sequence.
1280 unsigned Lexer::escapeSequence()
1296 case 'a': c
= 7; goto Lconsume
;
1297 case 'b': c
= 8; goto Lconsume
;
1298 case 'f': c
= 12; goto Lconsume
;
1299 case 'n': c
= 10; goto Lconsume
;
1300 case 'r': c
= 13; goto Lconsume
;
1301 case 't': c
= 9; goto Lconsume
;
1302 case 'v': c
= 11; goto Lconsume
;
1324 else if (islower(c
))
1333 { error("escape hex sequence has %d hex digits instead of %d", n
, ndigits
);
1337 if (ndigits
!= 2 && !utf_isValidDchar(v
))
1338 error("invalid UTF character \\U%08x", v
);
1342 error("undefined escape hex sequence \\%c\n",c
);
1345 case '&': // named character entity
1346 for (unsigned char *idstart
= ++p
; 1; p
++)
1351 c
= HtmlNamedEntity(idstart
, p
- idstart
);
1353 { error("unnamed character entity &%.*s;", (int)(p
- idstart
), idstart
);
1361 (p
!= idstart
+ 1 && isdigit(*p
)))
1363 error("unterminated named entity");
1371 case 0x1A: // end of file
1383 v
= v
* 8 + (c
- '0');
1385 } while (++n
< 3 && isoctal(c
));
1388 error("0%03o is larger than a byte", c
);
1391 error("undefined escape sequence \\%c\n",c
);
1397 /**************************************
1400 TOK
Lexer::wysiwygStringConstant(Token
*t
, int tc
)
1405 stringbuffer
.reset();
1418 c
= '\n'; // treat EndOfLine as \n character
1424 error("unterminated string constant starting at %s", start
.toChars());
1425 t
->ustring
= (unsigned char *)"";
1434 t
->len
= stringbuffer
.offset
;
1435 stringbuffer
.writeByte(0);
1436 t
->ustring
= (unsigned char *)mem
.malloc(stringbuffer
.offset
);
1437 memcpy(t
->ustring
, stringbuffer
.data
, stringbuffer
.offset
);
1446 unsigned u
= decodeUTF();
1448 if (u
== PS
|| u
== LS
)
1450 stringbuffer
.writeUTF8(u
);
1455 stringbuffer
.writeByte(c
);
1459 /**************************************
1464 TOK
Lexer::hexStringConstant(Token
*t
)
1471 stringbuffer
.reset();
1481 continue; // skip white space
1486 // Treat isolated '\r' as if it were a '\n'
1493 error("unterminated string constant starting at %s", start
.toChars());
1494 t
->ustring
= (unsigned char *)"";
1501 { error("odd number (%d) of hex characters in hex string", n
);
1502 stringbuffer
.writeByte(v
);
1504 t
->len
= stringbuffer
.offset
;
1505 stringbuffer
.writeByte(0);
1506 t
->ustring
= (unsigned char *)mem
.malloc(stringbuffer
.offset
);
1507 memcpy(t
->ustring
, stringbuffer
.data
, stringbuffer
.offset
);
1512 if (c
>= '0' && c
<= '9')
1514 else if (c
>= 'a' && c
<= 'f')
1516 else if (c
>= 'A' && c
<= 'F')
1520 unsigned u
= decodeUTF();
1522 if (u
== PS
|| u
== LS
)
1525 error("non-hex character \\u%x", u
);
1528 error("non-hex character '%c'", c
);
1531 stringbuffer
.writeByte(v
);
1543 /**************************************
1544 * Lex delimited strings:
1545 * q"(foo(xxx))" // "foo(xxx)"
1546 * q"[foo(]" // "foo("
1547 * q"/foo]/" // "foo]"
1555 TOK
Lexer::delimitedStringConstant(Token
*t
)
1558 unsigned delimleft
= 0;
1559 unsigned delimright
= 0;
1562 Identifier
*hereid
= NULL
;
1563 unsigned blankrol
= 0;
1564 unsigned startline
= 0;
1567 stringbuffer
.reset();
1571 //printf("c = '%c'\n", c);
1584 stringbuffer
.writeUTF8(c
);
1592 c
= '\n'; // treat EndOfLine as \n character
1604 if (c
== PS
|| c
== LS
)
1621 else if (isalpha(c
) || c
== '_' || (c
>= 0x80 && isUniAlpha(c
)))
1622 { // Start of identifier; must be a heredoc
1625 scan(&t
); // read in heredoc identifier
1626 if (t
.value
!= TOKidentifier
)
1627 { error("identifier expected for heredoc, not %s", t
.toChars());
1632 //printf("hereid = '%s'\n", hereid->toChars());
1645 { error("heredoc rest of line should be blank");
1653 else if (c
== delimright
)
1659 else if (c
== delimright
)
1661 if (startline
&& isalpha(c
))
1663 unsigned char *psave
= p
;
1665 scan(&t
); // read in possible heredoc identifier
1666 //printf("endid = '%s'\n", t.ident->toChars());
1667 if (t
.value
== TOKidentifier
&& t
.ident
->equals(hereid
))
1668 { /* should check that rest of line is blank
1674 stringbuffer
.writeUTF8(c
);
1683 error("delimited string must end in %c\"", delimright
);
1684 t
->len
= stringbuffer
.offset
;
1685 stringbuffer
.writeByte(0);
1686 t
->ustring
= (unsigned char *)mem
.malloc(stringbuffer
.offset
);
1687 memcpy(t
->ustring
, stringbuffer
.data
, stringbuffer
.offset
);
1692 error("unterminated string constant starting at %s", start
.toChars());
1693 t
->ustring
= (unsigned char *)"";
1699 /**************************************
1700 * Lex delimited strings:
1701 * q{ foo(xxx) } // " foo(xxx) "
1703 * q{{foo}"}"} // "{foo}"}""
1708 TOK
Lexer::tokenStringConstant(Token
*t
)
1712 unsigned char *pstart
= ++p
;
1738 t
->len
= p
- 1 - pstart
;
1739 t
->ustring
= (unsigned char *)mem
.malloc(t
->len
+ 1);
1740 memcpy(t
->ustring
, pstart
, t
->len
);
1741 t
->ustring
[t
->len
] = 0;
1746 error("unterminated token string constant starting at %s", start
.toChars());
1747 t
->ustring
= (unsigned char *)"";
1756 /**************************************
1759 TOK
Lexer::escapeStringConstant(Token
*t
, int wide
)
1764 stringbuffer
.reset();
1776 c
= escapeSequence();
1777 stringbuffer
.writeUTF8(c
);
1781 c
= escapeSequence();
1793 c
= '\n'; // treat EndOfLine as \n character
1798 t
->len
= stringbuffer
.offset
;
1799 stringbuffer
.writeByte(0);
1800 t
->ustring
= (unsigned char *)mem
.malloc(stringbuffer
.offset
);
1801 memcpy(t
->ustring
, stringbuffer
.data
, stringbuffer
.offset
);
1808 error("unterminated string constant starting at %s", start
.toChars());
1809 t
->ustring
= (unsigned char *)"";
1819 if (c
== LS
|| c
== PS
)
1824 stringbuffer
.writeUTF8(c
);
1829 stringbuffer
.writeByte(c
);
1833 /**************************************
1836 TOK
Lexer::charConstant(Token
*t
, int wide
)
1841 //printf("Lexer::charConstant\n");
1850 t
->uns64value
= escapeSequence();
1856 t
->uns64value
= escapeSequence();
1861 t
->uns64value
= escapeSequence();
1873 error("unterminated character constant");
1882 if (c
== LS
|| c
== PS
)
1884 if (c
< 0xD800 || (c
>= 0xE000 && c
< 0xFFFE))
1894 { error("unterminated character constant");
1901 /***************************************
1902 * Get postfix of string literal.
1905 void Lexer::stringPostfix(Token
*t
)
1922 /***************************************
1923 * Read \u or \U unicode sequence
1929 unsigned Lexer::wchar(unsigned u
)
1936 nchars
= (u
== 'U') ? 8 : 4;
1945 { error("\\%c sequence must be followed by %d hex characters", u
, nchars
);
1950 else if (islower(c
))
1961 /**************************************
1963 * If it's an integer, store it in tok.TKutok.Vlong.
1964 * integers can be decimal, octal or hex
1965 * Handle the suffixes U, UL, LU, L, etc.
1966 * If it's double, store it in tok.TKutok.Vdouble.
1972 TOK
Lexer::number(Token
*t
)
1974 // We use a state machine to collect numbers
1975 enum STATE
{ STATE_initial
, STATE_0
, STATE_decimal
, STATE_octal
, STATE_octale
,
1976 STATE_hex
, STATE_binary
, STATE_hex0
, STATE_binary0
,
1977 STATE_hexh
, STATE_error
};
1981 { FLAGS_decimal
= 1, // decimal
1982 FLAGS_unsigned
= 2, // u or U suffix
1983 FLAGS_long
= 4, // l or L suffix
1985 enum FLAGS flags
= FLAGS_decimal
;
1990 unsigned char *start
;
1993 //printf("Lexer::number()\n");
1994 state
= STATE_initial
;
1996 stringbuffer
.reset();
2003 case STATE_initial
: // opening state
2007 state
= STATE_decimal
;
2011 flags
= (FLAGS
) (flags
& ~FLAGS_decimal
);
2025 if (p
[1] == '.') // .. is a separate token
2038 state
= STATE_binary0
;
2041 case '0': case '1': case '2': case '3':
2042 case '4': case '5': case '6': case '7':
2043 state
= STATE_octal
;
2047 case '8': case '9': case 'A':
2048 case 'C': case 'D': case 'F':
2049 case 'a': case 'c': case 'd': case 'f':
2055 state
= STATE_octal
;
2069 case STATE_decimal
: // reading decimal number
2074 || c
== 'H' || c
== 'h'
2078 if (c
== '_') // ignore embedded _
2082 if (c
== '.' && p
[1] != '.')
2084 else if (c
== 'i' || c
== 'f' || c
== 'F' ||
2085 c
== 'e' || c
== 'E')
2087 real
: // It's a real number. Back up and rescan as a real
2091 else if (c
== 'L' && p
[1] == 'i')
2097 case STATE_hex0
: // reading hex number
2101 if (c
== '_') // ignore embedded _
2105 if (c
== '.' && p
[1] != '.')
2107 if (c
== 'P' || c
== 'p' || c
== 'i')
2109 if (state
== STATE_hex0
)
2110 error("Hex digit expected, not '%c'", c
);
2119 case STATE_hexh
: // parse numbers like 0FFh
2122 if (c
== 'H' || c
== 'h')
2130 // Check for something like 1E3 or 0E24
2131 if (memchr((char *)stringbuffer
.data
, 'E', stringbuffer
.offset
) ||
2132 memchr((char *)stringbuffer
.data
, 'e', stringbuffer
.offset
))
2134 error("Hex digit expected, not '%c'", c
);
2141 case STATE_octal
: // reading octal number
2142 case STATE_octale
: // reading octal number with non-octal digits
2147 || c
== 'H' || c
== 'h'
2151 if (c
== '_') // ignore embedded _
2155 if (c
== '.' && p
[1] != '.')
2161 state
= STATE_octale
;
2168 case STATE_binary0
: // starting binary number
2169 case STATE_binary
: // reading binary number
2170 if (c
!= '0' && c
!= '1')
2174 || c
== 'H' || c
== 'h'
2178 if (c
== '_') // ignore embedded _
2182 if (state
== STATE_binary0
)
2183 { error("binary digit expected");
2184 state
= STATE_error
;
2190 state
= STATE_binary
;
2193 case STATE_error
: // for error recovery
2194 if (!isdigit(c
)) // scan until non-digit
2201 stringbuffer
.writeByte(c
);
2205 stringbuffer
.writeByte(0); // terminate string
2206 if (state
== STATE_octale
)
2207 error("Octal digit expected");
2209 uinteger_t n
; // unsigned >=64 bit integer type
2211 if (stringbuffer
.offset
== 2 && (state
== STATE_decimal
|| state
== STATE_0
))
2212 n
= stringbuffer
.data
[0] - '0';
2215 // Convert string to integer
2218 n
= strtoull((char *)stringbuffer
.data
,NULL
,base
);
2219 if (errno
== ERANGE
)
2220 error("integer overflow");
2222 // Not everybody implements strtoull()
2223 char *p
= (char *)stringbuffer
.data
;
2228 if (p
[1] == 'x' || p
[1] == 'X')
2230 else if (p
[1] == 'b' || p
[1] == 'B')
2232 else if (isdigit(p
[1]))
2239 if (*p
>= '0' && *p
<= '9')
2241 else if (*p
>= 'a' && *p
<= 'z')
2243 else if (*p
>= 'A' && *p
<= 'Z')
2249 if (n
&& n
* r
+ d
<= n
)
2251 error ("integer overflow");
2259 if (sizeof(n
) > 8 &&
2260 n
> 0xFFFFFFFFFFFFFFFFULL
) // if n needs more than 64 bits
2261 error("integer overflow");
2264 // Parse trailing 'u', 'U', 'l' or 'L' in any combination
2275 if (1 || !global
.params
.useDeprecated
)
2276 error("'l' suffix is deprecated, use 'L' instead");
2282 error("unrecognized token");
2283 flags
= (FLAGS
) (flags
| f
);
2294 /* Octal or Hexadecimal constant.
2295 * First that fits: int, uint, long, ulong
2297 if (n
& 0x8000000000000000LL
)
2299 else if (n
& 0xFFFFFFFF00000000LL
)
2301 else if (n
& 0x80000000)
2308 /* First that fits: int, long, long long
2310 if (n
& 0x8000000000000000LL
)
2311 { error("signed integer overflow");
2314 else if (n
& 0xFFFFFFFF80000000LL
)
2320 case FLAGS_unsigned
:
2321 case FLAGS_decimal
| FLAGS_unsigned
:
2322 /* First that fits: uint, ulong
2324 if (n
& 0xFFFFFFFF00000000LL
)
2330 case FLAGS_decimal
| FLAGS_long
:
2331 if (n
& 0x8000000000000000LL
)
2332 { error("signed integer overflow");
2340 if (n
& 0x8000000000000000LL
)
2346 case FLAGS_unsigned
| FLAGS_long
:
2347 case FLAGS_decimal
| FLAGS_unsigned
| FLAGS_long
:
2353 printf("%x\n",flags
);
2361 /**************************************
2362 * Read in characters, converting them to real.
2364 * Exponent overflow not detected.
2365 * Too much requested precision is not detected.
2368 TOK
Lexer::inreal(Token
*t
)
2372 assert(*p
== '.' || isdigit(*p
));
2381 case TOKimaginary32v
:
2382 case TOKimaginary64v
:
2383 case TOKimaginary80v
:
2391 #endif /* __DMC__ */
2394 char hex
; // is this a hexadecimal-floating-constant?
2397 //printf("Lexer::inreal()\n");
2398 stringbuffer
.reset();
2404 // Get next char from input
2406 //printf("dblstate = %d, c = '%c'\n", dblstate, c);
2411 case 0: // opening state
2422 if (c
== 'X' || c
== 'x')
2426 case 1: // digits to left of .
2427 case 3: // digits to right of .
2428 case 7: // continuing exponent digits
2429 if (!isdigit(c
) && !(hex
&& isxdigit(c
)))
2432 goto Lnext
; // ignore embedded '_'
2438 case 2: // no more digits to left of .
2443 case 4: // no more digits to right of .
2444 if ((c
== 'E' || c
== 'e') ||
2445 hex
&& (c
== 'P' || c
== 'p'))
2447 hex
= 0; // exponent is always decimal
2451 error("binary-exponent-part required");
2454 case 5: // looking immediately to right of E
2456 if (c
== '-' || c
== '+')
2458 case 6: // 1st exponent digit expected
2460 error("exponent expected");
2464 case 8: // past end of exponent digits
2469 stringbuffer
.writeByte(c
);
2474 stringbuffer
.writeByte(0);
2476 #if _WIN32 && __DMC__
2477 char *save
= __locale_decpoint
;
2478 __locale_decpoint
= ".";
2481 t
->float80value
= real_t::parse((char *)stringbuffer
.data
, real_t::LongDouble
);
2483 t
->float80value
= strtold((char *)stringbuffer
.data
, NULL
);
2491 real_t::parse((char *)stringbuffer
.data
, real_t::Float
);
2493 strtof((char *)stringbuffer
.data
, NULL
);
2495 result
= TOKfloat32v
;
2501 real_t::parse((char *)stringbuffer
.data
, real_t::Double
);
2503 strtod((char *)stringbuffer
.data
, NULL
);
2505 result
= TOKfloat64v
;
2509 if (!global
.params
.useDeprecated
)
2510 error("'l' suffix is deprecated, use 'L' instead");
2512 result
= TOKfloat80v
;
2516 if (*p
== 'i' || *p
== 'I')
2518 if (!global
.params
.useDeprecated
&& *p
== 'I')
2519 error("'I' suffix is deprecated, use 'i' instead");
2524 result
= TOKimaginary32v
;
2527 result
= TOKimaginary64v
;
2530 result
= TOKimaginary80v
;
2534 #if _WIN32 && __DMC__
2535 __locale_decpoint
= save
;
2537 if (errno
== ERANGE
)
2538 error("number is not representable");
2542 /*********************************************
2544 * Currently, the only pragma supported is:
2545 * #line linnum [filespec]
2548 void Lexer::pragma()
2552 char *filespec
= NULL
;
2553 Loc loc
= this->loc
;
2555 while (isblank(*p
)) p
++;
2560 if (tok
.value
!= TOKidentifier
|| tok
.ident
!= Id::line
)
2564 if (tok
.value
== TOKint32v
|| tok
.value
== TOKint64v
)
2565 linnum
= tok
.uns64value
- 1;
2577 this->loc
.linnum
= linnum
;
2579 this->loc
.filename
= filespec
;
2595 continue; // skip white space
2598 if (mod
&& memcmp(p
, "__FILE__", 8) == 0)
2601 filespec
= mem
.strdup(loc
.filename
? loc
.filename
: mod
->ident
->toChars());
2608 stringbuffer
.reset();
2623 stringbuffer
.writeByte(0);
2624 filespec
= mem
.strdup((char *)stringbuffer
.data
);
2630 { unsigned u
= decodeUTF();
2631 if (u
== PS
|| u
== LS
)
2634 stringbuffer
.writeByte(c
);
2644 { unsigned u
= decodeUTF();
2645 if (u
== PS
|| u
== LS
)
2653 error(loc
, "#line integer [\"filespec\"]\\n expected");
2657 /********************************************
2658 * Decode UTF character.
2659 * Issue error messages for invalid sequences.
2660 * Return decoded character, advance p to last character in UTF sequence.
2663 unsigned Lexer::decodeUTF()
2667 unsigned char *s
= p
;
2675 // Check length of remaining string up to 6 UTF-8 characters
2676 for (len
= 1; len
< 6 && s
[len
]; len
++)
2680 msg
= utf_decodeChar(s
, len
, &idx
, &u
);
2690 /***************************************************
2691 * Parse doc comment embedded between t->ptr and p.
2692 * Remove trailing blanks and tabs from lines.
2693 * Replace all newlines with \n.
2694 * Remove leading comment character from each line.
2695 * Decide if it's a lineComment or a blockComment.
2696 * Append to previous one for this token.
2699 void Lexer::getDocComment(Token
*t
, unsigned lineComment
)
2702 unsigned char ct
= t
->ptr
[2];
2703 unsigned char *q
= t
->ptr
+ 3; // start of comment text
2706 unsigned char *qend
= p
;
2707 if (ct
== '*' || ct
== '+')
2710 /* Scan over initial row of ****'s or ++++'s or ////'s
2712 for (; q
< qend
; q
++)
2718 /* Remove trailing row of ****'s or ++++'s
2722 for (; q
< qend
; qend
--)
2729 for (; q
< qend
; q
++)
2731 unsigned char c
= *q
;
2737 if (linestart
&& c
== ct
)
2739 /* Trim preceding whitespace up to preceding \n
2741 while (buf
.offset
&& (buf
.data
[buf
.offset
- 1] == ' ' || buf
.data
[buf
.offset
- 1] == '\t'))
2753 continue; // skip the \r
2761 (q
[2] == 168 || q
[2] == 169))
2771 c
= '\n'; // replace all newlines with \n
2775 /* Trim trailing whitespace
2777 while (buf
.offset
&& (buf
.data
[buf
.offset
- 1] == ' ' || buf
.data
[buf
.offset
- 1] == '\t'))
2785 // Always end with a newline
2786 if (!buf
.offset
|| buf
.data
[buf
.offset
- 1] != '\n')
2787 buf
.writeByte('\n');
2791 // It's a line comment if the start of the doc comment comes
2792 // after other non-whitespace on the same line.
2793 unsigned char** dc
= (lineComment
&& anyToken
)
2797 // Combine with previous doc comment, if any
2799 *dc
= combineComments(*dc
, (unsigned char *)buf
.data
);
2801 *dc
= (unsigned char *)buf
.extractData();
2804 /********************************************
2805 * Combine two document comments into one.
2808 unsigned char *Lexer::combineComments(unsigned char *c1
, unsigned char *c2
)
2810 unsigned char *c
= c2
;
2815 { size_t len1
= strlen((char *)c1
);
2816 size_t len2
= strlen((char *)c2
);
2818 c
= (unsigned char *)mem
.malloc(len1
+ 1 + len2
+ 1);
2819 memcpy(c
, c1
, len1
);
2821 memcpy(c
+ len1
+ 1, c2
, len2
);
2822 c
[len1
+ 1 + len2
] = 0;
2828 /********************************************
2829 * Create an identifier in the string table.
2832 Identifier
*Lexer::idPool(const char *s
)
2834 size_t len
= strlen(s
);
2835 StringValue
*sv
= stringtable
.update(s
, len
);
2836 Identifier
*id
= (Identifier
*) sv
->ptrvalue
;
2839 id
= new Identifier(sv
->lstring
.string
, TOKidentifier
);
2845 /*********************************************
2846 * Create a unique identifier using the prefix s.
2849 Identifier
*Lexer::uniqueId(const char *s
, int num
)
2851 size_t slen
= strlen(s
);
2853 assert(slen
+ sizeof(num
) * 3 + 1 <= sizeof(buffer
));
2854 sprintf(buffer
, "%s%d", s
, num
);
2855 return idPool(buffer
);
2858 Identifier
*Lexer::uniqueId(const char *s
)
2861 return uniqueId(s
, ++num
);
2864 /****************************************
2872 static Keyword keywords
[] =
2876 { "this", TOKthis
},
2877 { "super", TOKsuper
},
2878 { "assert", TOKassert
},
2879 { "null", TOKnull
},
2880 { "true", TOKtrue
},
2881 { "false", TOKfalse
},
2882 { "cast", TOKcast
},
2884 { "delete", TOKdelete
},
2885 { "throw", TOKthrow
},
2886 { "module", TOKmodule
},
2887 { "pragma", TOKpragma
},
2888 { "typeof", TOKtypeof
},
2889 { "typeid", TOKtypeid
},
2891 { "template", TOKtemplate
},
2893 { "void", TOKvoid
},
2894 { "byte", TOKint8
},
2895 { "ubyte", TOKuns8
},
2896 { "short", TOKint16
},
2897 { "ushort", TOKuns16
},
2898 { "int", TOKint32
},
2899 { "uint", TOKuns32
},
2900 { "long", TOKint64
},
2901 { "ulong", TOKuns64
},
2902 { "cent", TOKcent
, },
2903 { "ucent", TOKucent
, },
2904 { "float", TOKfloat32
},
2905 { "double", TOKfloat64
},
2906 { "real", TOKfloat80
},
2908 { "bool", TOKbool
},
2909 { "char", TOKchar
},
2910 { "wchar", TOKwchar
},
2911 { "dchar", TOKdchar
},
2913 { "ifloat", TOKimaginary32
},
2914 { "idouble", TOKimaginary64
},
2915 { "ireal", TOKimaginary80
},
2917 { "cfloat", TOKcomplex32
},
2918 { "cdouble", TOKcomplex64
},
2919 { "creal", TOKcomplex80
},
2921 { "delegate", TOKdelegate
},
2922 { "function", TOKfunction
},
2926 { "else", TOKelse
},
2927 { "while", TOKwhile
},
2930 { "switch", TOKswitch
},
2931 { "case", TOKcase
},
2932 { "default", TOKdefault
},
2933 { "break", TOKbreak
},
2934 { "continue", TOKcontinue
},
2935 { "synchronized", TOKsynchronized
},
2936 { "return", TOKreturn
},
2937 { "goto", TOKgoto
},
2939 { "catch", TOKcatch
},
2940 { "finally", TOKfinally
},
2941 { "with", TOKwith
},
2943 { "foreach", TOKforeach
},
2944 { "foreach_reverse", TOKforeach_reverse
},
2945 { "reversed", TOKreversed
},
2946 { "scope", TOKscope
},
2948 { "struct", TOKstruct
},
2949 { "class", TOKclass
},
2950 { "interface", TOKinterface
},
2951 { "union", TOKunion
},
2952 { "enum", TOKenum
},
2953 { "import", TOKimport
},
2954 { "mixin", TOKmixin
},
2955 { "static", TOKstatic
},
2956 { "final", TOKfinal
},
2957 { "const", TOKconst
},
2958 { "typedef", TOKtypedef
},
2959 { "alias", TOKalias
},
2960 { "override", TOKoverride
},
2961 { "abstract", TOKabstract
},
2962 { "volatile", TOKvolatile
},
2963 { "debug", TOKdebug
},
2964 { "deprecated", TOKdeprecated
},
2967 { "inout", TOKinout
},
2968 { "lazy", TOKlazy
},
2969 { "auto", TOKauto
},
2971 { "align", TOKalign
},
2972 { "extern", TOKextern
},
2973 { "private", TOKprivate
},
2974 { "package", TOKpackage
},
2975 { "protected", TOKprotected
},
2976 { "public", TOKpublic
},
2977 { "export", TOKexport
},
2979 { "body", TOKbody
},
2980 { "invariant", TOKinvariant
},
2981 { "unittest", TOKunittest
},
2982 { "version", TOKversion
},
2983 //{ "manifest", TOKmanifest },
2987 { "macro", TOKmacro
},
2991 { "and", TOKandand
},
2994 { "extends", TOKextends
},
2995 { "implements", TOKimplements
},
2996 { "log_error", TOKlog_error
},
2997 { "log_warning", TOKlog_warning
},
2998 { "log_info", TOKlog_info
},
2999 { "log_trace", TOKlog_trace
},
3001 { "pure", TOKpure
},
3002 { "nothrow", TOKnothrow
},
3003 { "__traits", TOKtraits
},
3004 { "__overloadset", TOKoverloadset
},
3008 int Token::isKeyword()
3010 for (unsigned u
= 0; u
< sizeof(keywords
) / sizeof(keywords
[0]); u
++)
3012 if (keywords
[u
].value
== value
)
3018 void Lexer::initKeywords()
3022 unsigned nkeywords
= sizeof(keywords
) / sizeof(keywords
[0]);
3024 if (global
.params
.Dversion
== 1)
3029 for (u
= 0; u
< nkeywords
; u
++)
3032 //printf("keyword[%d] = '%s'\n",u, keywords[u].name);
3033 s
= keywords
[u
].name
;
3034 v
= keywords
[u
].value
;
3035 sv
= stringtable
.insert(s
, strlen(s
));
3036 sv
->ptrvalue
= (void *) new Identifier(sv
->lstring
.string
,v
);
3038 //printf("tochars[%d] = '%s'\n",v, s);
3039 Token::tochars
[v
] = s
;
3042 Token::tochars
[TOKeof
] = "EOF";
3043 Token::tochars
[TOKlcurly
] = "{";
3044 Token::tochars
[TOKrcurly
] = "}";
3045 Token::tochars
[TOKlparen
] = "(";
3046 Token::tochars
[TOKrparen
] = ")";
3047 Token::tochars
[TOKlbracket
] = "[";
3048 Token::tochars
[TOKrbracket
] = "]";
3049 Token::tochars
[TOKsemicolon
] = ";";
3050 Token::tochars
[TOKcolon
] = ":";
3051 Token::tochars
[TOKcomma
] = ",";
3052 Token::tochars
[TOKdot
] = ".";
3053 Token::tochars
[TOKxor
] = "^";
3054 Token::tochars
[TOKxorass
] = "^=";
3055 Token::tochars
[TOKassign
] = "=";
3056 Token::tochars
[TOKconstruct
] = "=";
3058 Token::tochars
[TOKblit
] = "=";
3060 Token::tochars
[TOKlt
] = "<";
3061 Token::tochars
[TOKgt
] = ">";
3062 Token::tochars
[TOKle
] = "<=";
3063 Token::tochars
[TOKge
] = ">=";
3064 Token::tochars
[TOKequal
] = "==";
3065 Token::tochars
[TOKnotequal
] = "!=";
3066 Token::tochars
[TOKnotidentity
] = "!is";
3067 Token::tochars
[TOKtobool
] = "!!";
3068 Token::tochars
[TOKat
] = "@";
3070 Token::tochars
[TOKunord
] = "!<>=";
3071 Token::tochars
[TOKue
] = "!<>";
3072 Token::tochars
[TOKlg
] = "<>";
3073 Token::tochars
[TOKleg
] = "<>=";
3074 Token::tochars
[TOKule
] = "!>";
3075 Token::tochars
[TOKul
] = "!>=";
3076 Token::tochars
[TOKuge
] = "!<";
3077 Token::tochars
[TOKug
] = "!<=";
3079 Token::tochars
[TOKnot
] = "!";
3080 Token::tochars
[TOKtobool
] = "!!";
3081 Token::tochars
[TOKshl
] = "<<";
3082 Token::tochars
[TOKshr
] = ">>";
3083 Token::tochars
[TOKushr
] = ">>>";
3084 Token::tochars
[TOKadd
] = "+";
3085 Token::tochars
[TOKmin
] = "-";
3086 Token::tochars
[TOKmul
] = "*";
3087 Token::tochars
[TOKdiv
] = "/";
3088 Token::tochars
[TOKmod
] = "%";
3089 Token::tochars
[TOKslice
] = "..";
3090 Token::tochars
[TOKdotdotdot
] = "...";
3091 Token::tochars
[TOKand
] = "&";
3092 Token::tochars
[TOKandand
] = "&&";
3093 Token::tochars
[TOKor
] = "|";
3094 Token::tochars
[TOKoror
] = "||";
3095 Token::tochars
[TOKarray
] = "[]";
3096 Token::tochars
[TOKindex
] = "[i]";
3097 Token::tochars
[TOKaddress
] = "&";
3098 Token::tochars
[TOKstar
] = "*";
3099 Token::tochars
[TOKtilde
] = "~";
3100 Token::tochars
[TOKdollar
] = "$";
3101 Token::tochars
[TOKcast
] = "cast";
3102 Token::tochars
[TOKplusplus
] = "++";
3103 Token::tochars
[TOKminusminus
] = "--";
3104 Token::tochars
[TOKtype
] = "type";
3105 Token::tochars
[TOKquestion
] = "?";
3106 Token::tochars
[TOKneg
] = "-";
3107 Token::tochars
[TOKuadd
] = "+";
3108 Token::tochars
[TOKvar
] = "var";
3109 Token::tochars
[TOKaddass
] = "+=";
3110 Token::tochars
[TOKminass
] = "-=";
3111 Token::tochars
[TOKmulass
] = "*=";
3112 Token::tochars
[TOKdivass
] = "/=";
3113 Token::tochars
[TOKmodass
] = "%=";
3114 Token::tochars
[TOKshlass
] = "<<=";
3115 Token::tochars
[TOKshrass
] = ">>=";
3116 Token::tochars
[TOKushrass
] = ">>>=";
3117 Token::tochars
[TOKandass
] = "&=";
3118 Token::tochars
[TOKorass
] = "|=";
3119 Token::tochars
[TOKcatass
] = "~=";
3120 Token::tochars
[TOKcat
] = "~";
3121 Token::tochars
[TOKcall
] = "call";
3122 Token::tochars
[TOKidentity
] = "is";
3123 Token::tochars
[TOKnotidentity
] = "!is";
3124 Token::tochars
[TOKendline
] = "\\n";
3126 Token::tochars
[TOKorass
] = "|=";
3127 Token::tochars
[TOKidentifier
] = "identifier";
3130 Token::tochars
[TOKdotexp
] = "dotexp";
3131 Token::tochars
[TOKdotti
] = "dotti";
3132 Token::tochars
[TOKdotvar
] = "dotvar";
3133 Token::tochars
[TOKdottype
] = "dottype";
3134 Token::tochars
[TOKsymoff
] = "symoff";
3135 Token::tochars
[TOKtypedot
] = "typedot";
3136 Token::tochars
[TOKarraylength
] = "arraylength";
3137 Token::tochars
[TOKarrayliteral
] = "arrayliteral";
3138 Token::tochars
[TOKassocarrayliteral
] = "assocarrayliteral";
3139 Token::tochars
[TOKstructliteral
] = "structliteral";
3140 Token::tochars
[TOKstring
] = "string";
3141 Token::tochars
[TOKdsymbol
] = "symbol";
3142 Token::tochars
[TOKtuple
] = "tuple";
3143 Token::tochars
[TOKdeclaration
] = "declaration";
3144 Token::tochars
[TOKdottd
] = "dottd";
3145 Token::tochars
[TOKlogger
] = "logger";
3146 Token::tochars
[TOKon_scope_exit
] = "scope(exit)";