1
2
3
4
5
6 classmap LexerFileTokenLexerClassMap;
7
8 prefix "gendoc/html";
9
10 tokens LexerFileTokenLexerTokens
11 {
12 (CLASSMAP, "'classmap'"), (PREFIX, "'prefix'"), (TOKENS, "'tokens'"), (KEYWORDS, "'keywords'"), (EXPRESSIONS, "'expressions'"), (LEXER, "'lexer'"),
13 (VARIABLES, "''variables'"), (ACTIONS, "'actions'"), (API, "'api'"), (INCLUDE, "'include'"),
14 (FILEPATH, "file path"), (DOLLAR, "'$'"), (EXCLAMATION, "'!'"),
15 (AUTO, "'auto'"), (REGISTER, "'register'"), (STATIC, "'static'"), (EXTERN, "'extern'"), (MUTABLE, "'mutable'"),
16 (CHAR, "'char'"), (WCHART, "'wchar_t'"), (BOOL, "'bool'"), (SHORT, "'short'"), (INT, "'int'"), (LONG, "'long'"), (SIGNED, "'signed'"), (UNSIGNED, "'unsigned'"),
17 (FLOAT, "'float'"), (DOUBLE, "'double'"), (VOID, "'void'"),
18 (TYPEDEF, "'typedef'"), (CONST, "'const'"), (VOLATILE, "'volatile'"), (USING, "'using'"), (NAMESPACE, "'namespace'"), (THROW, "'throw'"), (SIZEOF, "'sizeof'"), (OPERATOR, "'operator'"),
19 (DYNAMICCAST, "'dynamic_cast'"), (STATICCAST, "'static_cast'"), (REINTERPRETCAST, "'reinterpret_cast'"), (CONSTCAST, "'const_cast'"), (TYPEID, "'typeid'"), (THIS, "'this'"),
20 (NEW, "'new'"), (DELETE, "'delete'"), (TRUE, "'true'"), (FALSE, "'false'"), (NULLPTR, "'nullptr'"),
21 (CASE, "'case'"), (DEFAULT, "'default'"), (IF, "'if'"), (ELSE, "'else'"), (SWITCH, "'switch'"), (WHILE, "'while'"), (DO, "'do'"), (FOR, "'for'"),
22 (BREAK, "'break'"), (CONTINUE, "'continue'"), (RETURN, "'return'"), (GOTO, "'goto'"), (TRY, "'try'"), (CATCH, "'catch'"),
23 (INTLIT, "integer literal"), (FLOATINGLIT, "floating literal"), (CHARLIT, "character literal"), (STRINGLIT, "string literal"),
24 (DISJUNCTION, "'||'"), (AMPAMP, "'&&'"), (DOTSTAR, "'.*'"), (ARROWSTAR, "'->*'"),
25 (BITOR, "'|'"), (BITXOR, "'^'"), (AMP, "'&'"), (EQ, "'=='"), (NEQ, "'!='"), (LEQ, "'<='"), (GEQ, "'>='"), (SHIFTLEFT, "'<<'"), (SHIFTRIGHT, "'>>'"),
26 (PLUS, "'+'"), (MINUS, "'-'"), (STAR, "'*'"), (DIV, "'/'"), (REM, "'%'"), (PLUSPLUS, "'++'"), (MINUSMINUS, "'--'"), (CPL, "'~'"), (DOT, "'.'"), (ARROW, "'->'"), (QUEST, "'?'"),
27 (LPAREN, "'('"), (RPAREN, "')'"), (LBRACE, "'{'"), (RBRACE, "'}'"), (LBRACKET, "'['"), (RBRACKET, "']'"), (LANGLE, "'<'"), (RANGLE, "'>'"), (ELLIPSIS, "'...'"),
28 (COLONCOLON, "'::'"), (COLON, "':'"), (SEMICOLON, "';'"), (HASH, "'#'"), (COMMA, "','"), (ASSIGN, "'='"), (MULASSIGN, "'*='"), (DIVASSIGN, "'/='"), (REMASSIGN, "'%='"),
29 (PLUSASSIGN, "'+='"), (MINUSASSIGN, "'-='"), (SHIFTLEFTASSIGN, "'<<='"), (SHIFTRIGHTASSIGN, "'>>='"), (ANDASSIGN, "'&='"), (XORASSIGN, "'^='"), (ORASSIGN, "'|='"),
30 (WS, "white space"), (LINECOMMENT, "line comment"), (BLOCKCOMMENT, "block comment"), (KEYWORD, "keyword"), (ID, "identifier"), (NUMBER, "number"), (PP, "pp"), (OTHER, "other")
31 }
32
33 keywords LexerFileTokenLexerKeywords
34 {
35 ("classmap", CLASSMAP), ("prefix", PREFIX), ("tokens", TOKENS), ("keywords", KEYWORDS), ("expressions", EXPRESSIONS), ("lexer", LEXER),
36 ("variables", VARIABLES), ("actions", ACTIONS), ("api", API), ("include", INCLUDE),
37 ("auto", AUTO), ("register", REGISTER), ("static", STATIC), ("extern", EXTERN), ("mutable", MUTABLE),
38 ("char", CHAR), ("wchar_t", WCHART), ("bool", BOOL), ("short", SHORT), ("int", INT), ("long", LONG), ("signed", SIGNED), ("unsigned", UNSIGNED),
39 ("float", FLOAT), ("double", DOUBLE), ("void", VOID),
40 ("typedef", TYPEDEF), ("const", CONST), ("volatile", VOLATILE), ("using", USING), ("namespace", NAMESPACE), ("throw", THROW), ("sizeof", SIZEOF), ("operator", OPERATOR),
41 ("dynamic_cast", DYNAMICCAST), ("static_cast", STATICCAST), ("reinterpret_cast", REINTERPRETCAST), ("const_cast", CONSTCAST), ("typeid", TYPEID), ("this", THIS),
42 ("new", NEW), ("delete", DELETE), ("true", TRUE), ("false", FALSE), ("nullptr", NULLPTR),
43 ("case", CASE), ("default", DEFAULT), ("if", IF), ("else", ELSE), ("switch", SWITCH), ("while", WHILE), ("do", DO), ("for", FOR),
44 ("break", BREAK), ("continue", CONTINUE), ("return", RETURN), ("goto", GOTO), ("try", TRY), ("catch", CATCH)
45 }
46
47 expressions
48 {
49 ws = "[\t ]+";
50 newline = "\r\n|\n|\r";
51 linecomment = "//[^\n\r]*{newline}";
52 blockcomment = "/\*([^*]|\*[^/])*\*/";
53 comment = "{linecomment}|{blockcomment}";
54 id = "{idstart}{idcont}*";
55 decdigit="[0-9]";
56 octaldigit="[0-7]";
57 hexdigit="[0-9a-fA-F]";
58 hex4 = "{hexdigit}{hexdigit}{hexdigit}{hexdigit}";
59 hex8 = "{hex4}{hex4}";
60 octalliteral = "0{octaldigit}*";
61 decimalliteral = "[1-9]{decdigit}*";
62 hexliteral = "(0x|0X){hexdigit}+";
63 unsignedsuffix = "u|U";
64 longlongsuffix = "ll|LL";
65 longsuffix = "l|L";
66 integersuffix = "{unsignedsuffix}({longlongsuffix}|{longsuffix})?";
67 integerliteral = "({octalliteral}|{decimalliteral}|{hexliteral}){integersuffix}?";
68 fraction = "{decdigit}*\.{decdigit}+|{decdigit}+\.";
69 sign = "\+|-";
70 exponent = "(e|E){sign}?{decdigit}+";
71 floatingsuffix="f|F|l|L";
72 floatingliteral = "({fraction}{exponent}?|{decdigit}+{exponent}){floatingsuffix}?";
73 escape = "\\((x|X){hexdigit}+|(d|D){decdigit}+|{octaldigit}+|u{hex4}|U{hex8}|(a|b|f|n|r|t|v|.))";
74 cchar = "[^'\\\n\r]|{escape}";
75 narrowcharliteral = "'{cchar}+'";
76 universalcharliteral = "(u|U)'{cchar}+'";
77 widecharliteral = "L'{cchar}+'";
78 charliteral = "{narrowcharliteral}|{universalcharliteral}|{widecharliteral}";
79 schar = "[^\"\\\n\r]|{escape}";
80 encodingprefix = "u8|u|U|L";
81 stringliteral = "{encodingprefix}?\"{schar}*\"";
82 }
83
84 lexer LexerFileTokenLexer
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 "$" { return OTHER; }
98 "\|\|" { return OTHER; }
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 }