1
2
3
4
5
6 classmap ParserFileTokenLexerClassMap;
7
8 prefix "gendoc/html";
9
10 tokens ParserFileTokenLexerTokens
11 {
12 (PARSER, "'parser'"), (API, "'api'"), (INCLUDE, "'include'"), (MAIN, "'main'"), (USELEXER, "'uselexer'"), (RULEINFO, "'ruleinfo'"), (EMPTY, "'empty'"), (VAR, "'var'"),
13 (CPPPREFIX, "cpp-prefix"), (HPPPREFIX, "hpp-prefix"), (FILEPATH, "file path"), (PRODUCES, "'::='"), (EXCLAMATION, "'!'"),
14 (AUTO, "'auto'"), (REGISTER, "'register'"), (STATIC, "'static'"), (EXTERN, "'extern'"), (MUTABLE, "'mutable'"),
15 (CHAR, "'char'"), (WCHART, "'wchar_t'"), (BOOL, "'bool'"), (SHORT, "'short'"), (INT, "'int'"), (LONG, "'long'"), (SIGNED, "'signed'"), (UNSIGNED, "'unsigned'"),
16 (FLOAT, "'float'"), (DOUBLE, "'double'"), (VOID, "'void'"),
17 (TYPEDEF, "'typedef'"), (CONST, "'const'"), (VOLATILE, "'volatile'"), (USING, "'using'"), (NAMESPACE, "'namespace'"), (THROW, "'throw'"), (SIZEOF, "'sizeof'"), (OPERATOR, "'operator'"),
18 (DYNAMICCAST, "'dynamic_cast'"), (STATICCAST, "'static_cast'"), (REINTERPRETCAST, "'reinterpret_cast'"), (CONSTCAST, "'const_cast'"), (TYPEID, "'typeid'"), (THIS, "'this'"),
19 (NEW, "'new'"), (DELETE, "'delete'"), (TRUE, "'true'"), (FALSE, "'false'"), (NULLPTR, "'nullptr'"),
20 (CASE, "'case'"), (DEFAULT, "'default'"), (IF, "'if'"), (ELSE, "'else'"), (SWITCH, "'switch'"), (WHILE, "'while'"), (DO, "'do'"), (FOR, "'for'"),
21 (BREAK, "'break'"), (CONTINUE, "'continue'"), (RETURN, "'return'"), (GOTO, "'goto'"), (TRY, "'try'"), (CATCH, "'catch'"),
22 (INTLIT, "integer literal"), (FLOATINGLIT, "floating literal"), (CHARLIT, "character literal"), (STRINGLIT, "string literal"),
23 (DISJUNCTION, "'||'"), (AMPAMP, "'&&'"), (DOTSTAR, "'.*'"), (ARROWSTAR, "'->*'"),
24 (BITOR, "'|'"), (BITXOR, "'^'"), (AMP, "'&'"), (EQ, "'=='"), (NEQ, "'!='"), (LEQ, "'<='"), (GEQ, "'>='"), (SHIFTLEFT, "'<<'"), (SHIFTRIGHT, "'>>'"),
25 (PLUS, "'+'"), (MINUS, "'-'"), (STAR, "'*'"), (DIV, "'/'"), (REM, "'%'"), (PLUSPLUS, "'++'"), (MINUSMINUS, "'--'"), (CPL, "'~'"), (DOT, "'.'"), (ARROW, "'->'"), (QUEST, "'?'"),
26 (LPAREN, "'('"), (RPAREN, "')'"), (LBRACE, "'{'"), (RBRACE, "'}'"), (LBRACKET, "'['"), (RBRACKET, "']'"), (LANGLE, "'<'"), (RANGLE, "'>'"), (ELLIPSIS, "'...'"),
27 (COLONCOLON, "'::'"), (COLON, "':'"), (SEMICOLON, "';'"), (HASH, "'#'"), (COMMA, "','"), (ASSIGN, "'='"), (MULASSIGN, "'*='"), (DIVASSIGN, "'/='"), (REMASSIGN, "'%='"),
28 (PLUSASSIGN, "'+='"), (MINUSASSIGN, "'-='"), (SHIFTLEFTASSIGN, "'<<='"), (SHIFTRIGHTASSIGN, "'>>='"), (ANDASSIGN, "'&='"), (XORASSIGN, "'^='"), (ORASSIGN, "'|='"),
29 (WS, "white space"), (LINECOMMENT, "line comment"), (BLOCKCOMMENT, "block comment"), (KEYWORD, "keyword"), (ID, "identifier"), (NUMBER, "number"), (PP, "pp"), (OTHER, "other")
30 }
31
32 keywords ParserFileTokenLexerKeywords
33 {
34 ("parser", PARSER), ("api", API), ("include", INCLUDE), ("main", MAIN), ("uselexer", USELEXER), ("ruleinfo", RULEINFO), ("empty", EMPTY), ("var", VAR),
35 ("auto", AUTO), ("register", REGISTER), ("static", STATIC), ("extern", EXTERN), ("mutable", MUTABLE),
36 ("char", CHAR), ("wchar_t", WCHART), ("bool", BOOL), ("short", SHORT), ("int", INT), ("long", LONG), ("signed", SIGNED), ("unsigned", UNSIGNED),
37 ("float", FLOAT), ("double", DOUBLE), ("void", VOID),
38 ("typedef", TYPEDEF), ("const", CONST), ("volatile", VOLATILE), ("using", USING), ("namespace", NAMESPACE), ("throw", THROW), ("sizeof", SIZEOF), ("operator", OPERATOR),
39 ("dynamic_cast", DYNAMICCAST), ("static_cast", STATICCAST), ("reinterpret_cast", REINTERPRETCAST), ("const_cast", CONSTCAST), ("typeid", TYPEID), ("this", THIS),
40 ("new", NEW), ("delete", DELETE), ("true", TRUE), ("false", FALSE), ("nullptr", NULLPTR),
41 ("case", CASE), ("default", DEFAULT), ("if", IF), ("else", ELSE), ("switch", SWITCH), ("while", WHILE), ("do", DO), ("for", FOR),
42 ("break", BREAK), ("continue", CONTINUE), ("return", RETURN), ("goto", GOTO), ("try", TRY), ("catch", CATCH)
43 }
44
45 expressions
46 {
47 ws = "[\t ]+";
48 newline = "\r\n|\n|\r";
49 linecomment = "//[^\n\r]*{newline}";
50 blockcomment = "/\*([^*]|\*[^/])*\*/";
51 comment = "{linecomment}|{blockcomment}";
52 separators = "({ws}|{comment})+";
53 id = "{idstart}{idcont}*";
54 decdigit="[0-9]";
55 octaldigit="[0-7]";
56 hexdigit="[0-9a-fA-F]";
57 hex4 = "{hexdigit}{hexdigit}{hexdigit}{hexdigit}";
58 hex8 = "{hex4}{hex4}";
59 octalliteral = "0{octaldigit}*";
60 decimalliteral = "[1-9]{decdigit}*";
61 hexliteral = "(0x|0X){hexdigit}+";
62 unsignedsuffix = "u|U";
63 longlongsuffix = "ll|LL";
64 longsuffix = "l|L";
65 integersuffix = "{unsignedsuffix}({longlongsuffix}|{longsuffix})?";
66 integerliteral = "({octalliteral}|{decimalliteral}|{hexliteral}){integersuffix}?";
67 fraction = "{decdigit}*\.{decdigit}+|{decdigit}+\.";
68 sign = "\+|-";
69 exponent = "(e|E){sign}?{decdigit}+";
70 floatingsuffix="f|F|l|L";
71 floatingliteral = "({fraction}{exponent}?|{decdigit}+{exponent}){floatingsuffix}?";
72 escape = "\\((x|X){hexdigit}+|(d|D){decdigit}+|{octaldigit}+|u{hex4}|U{hex8}|(a|b|f|n|r|t|v|.))";
73 cchar = "[^'\\\n\r]|{escape}";
74 narrowcharliteral = "'{cchar}+'";
75 universalcharliteral = "(u|U)'{cchar}+'";
76 widecharliteral = "L'{cchar}+'";
77 charliteral = "{narrowcharliteral}|{universalcharliteral}|{widecharliteral}";
78 schar = "[^\"\\\n\r]|{escape}";
79 encodingprefix = "u8|u|U|L";
80 stringliteral = "{encodingprefix}?\"{schar}*\"";
81 filepath = "<[^\n>]*>";
82 }
83
84 lexer ParserFileTokenLexer
85 {
86 "{ws}" { return WS; }
87 "{newline}" {}
88 "{linecomment}" { return LINECOMMENT; }
89 "{blockcomment}" { return BLOCKCOMMENT; }
90 "{id}" { int kw = GetKeywordToken(token.match); if (kw == INVALID_TOKEN) return ID; else return KEYWORD; }
91 "{charliteral}" { return CHARLIT; }
92 "{stringliteral}" { return STRINGLIT; }
93 "{floatingliteral}" { return NUMBER; }
94 "{integerliteral}" { return NUMBER; }
95 "{ws}*#[^\x0\r\n]*" { return PP; }
96 "<[^\n>]*>" { return FILEPATH; }
97 "\[cpp\]" { return PP; }
98 "\[hpp\]" { return PP; }
99 "::=" { return OTHER; }
100 "\|\|" { return OTHER; }
101 "&&" { return OTHER; }
102 "\.\*"{ return OTHER; }
103 "->\*"{ return OTHER; }
104 "\|" { return OTHER; }
105 "^" { return OTHER; }
106 "&" { return OTHER; }
107 "==" { return OTHER; }
108 "!=" { return OTHER; }
109 "<=" { return OTHER; }
110 ">=" { return OTHER; }
111 "<" { return OTHER; }
112 ">" { return OTHER; }
113 "<<"{ return OTHER; }
114 ">>" { return OTHER; }
115 "\+" { return OTHER; }
116 "-" { return OTHER; }
117 "\*" { return OTHER; }
118 "/" { return OTHER; }
119 "%" { return OTHER; }
120 "\+\+" { return OTHER; }
121 "--" { return OTHER; }
122 "!" { return OTHER; }
123 "\?" { return OTHER; }
124 "~" { return OTHER; }
125 "\." { return OTHER; }
126 "->" { return OTHER; }
127 "\[" { return OTHER; }
128 "\]" { return OTHER; }
129 "\(" { return OTHER; }
130 "\)" { return OTHER; }
131 "\{" { return OTHER; }
132 "\}" { return OTHER; }
133 "\.\.\." { return OTHER; }
134 "::" { return OTHER; }
135 ":" { return OTHER; }
136 ";" { return OTHER; }
137 "#" { return OTHER; }
138 "," { return OTHER; }
139 "=" { return OTHER; }
140 "\*=" { return OTHER; }
141 "/=" { return OTHER; }
142 "%=" { return OTHER; }
143 "\+=" { return OTHER; }
144 "-=" { return OTHER; }
145 "<<=" { return OTHER; }
146 ">>=" { return OTHER; }
147 "&=" { return OTHER; }
148 "^=" { return OTHER; }
149 "\|=" { return OTHER; }
150 }