3 // These are all supported lexer sections:
5 // Lexer file header. Appears at the top of h + cpp files. Use e.g. for copyrights.
6 @lexer::header {/* lexer header section */}
8 // Appears before any #include in h + cpp files.
9 @lexer::preinclude {/* lexer precinclude section */}
11 // Follows directly after the standard #includes in h + cpp files.
13 /* lexer postinclude section */
15 #pragma GCC diagnostic ignored "-Wunused-parameter"
19 // Directly preceds the lexer class declaration in the h file (e.g. for additional types etc.).
20 @lexer::context {/* lexer context section */}
22 // Appears in the public part of the lexer in the h file.
23 @lexer::members {/* public lexer declarations section */
24 bool canTestFoo() { return true; }
25 bool isItFoo() { return true; }
26 bool isItBar() { return true; }
28 void myFooLexerAction() { /* do something*/ };
29 void myBarLexerAction() { /* do something*/ };
32 // Appears in the private part of the lexer in the h file.
33 @lexer::declarations {/* private lexer declarations/members section */}
35 // Appears in line with the other class member definitions in the cpp file.
36 @lexer::definitions {/* lexer definitions section */}
38 channels { CommentsChannel, DirectiveChannel }
50 ID: LETTER (LETTER | '0'..'9')*;
51 fragment LETTER : [a-zA-Z\u0080-\u{10FFFF}];
65 OpenCurly: '{' -> pushMode(Mode1);
66 CloseCurly: '}' -> popMode;
69 Dollar: '$' -> more, mode(Mode1);
70 Ampersand: '&' -> type(DUMMY);
73 Foo: {canTestFoo()}? 'foo' {isItFoo()}? { myFooLexerAction(); };
74 Bar: 'bar' {isItBar()}? { myBarLexerAction(); };
75 Any: Foo Dot Bar? DotDot Baz;
77 Comment : '#' ~[\r\n]* '\r'? '\n' -> channel(CommentsChannel);
78 WS: [ \t\r\n]+ -> channel(99);