meta data for this page
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
include [2020/04/25 18:15] – external edit 127.0.0.1 | include [2021/02/05 21:35] – revusky | ||
---|---|---|---|
Line 19: | Line 19: | ||
Thus, JavaCC 21 introduces a setting called **DEFAULT_LEXICAL_STATE**. That means that any lexical specifications where the lexical state is unspecified are in that state. Thus, a JSON grammar would likely have something like this at the top: | Thus, JavaCC 21 introduces a setting called **DEFAULT_LEXICAL_STATE**. That means that any lexical specifications where the lexical state is unspecified are in that state. Thus, a JSON grammar would likely have something like this at the top: | ||
- | options { | + | |
- | | + | DEFAULT_LEXICAL_STATE=" |
- | } | + | |
| | ||
In that case, any grammar for a language that wants to handle embedded JSON data would presumably define its own " | In that case, any grammar for a language that wants to handle embedded JSON data would presumably define its own " | ||
Line 33: | Line 33: | ||
You can still *inject* code into the generated parser or lexer class, from within an included grammar, but you need to write something like: | You can still *inject* code into the generated parser or lexer class, from within an included grammar, but you need to write something like: | ||
- | INJECT(**PARSER_CLASS**) : | + | INJECT(PARSER_CLASS) : |
- | { | + | |
- | ... | + | |
- | } | + | |
{ | { | ||
... | ... | ||
Line 43: | Line 40: | ||
or: | or: | ||
- | INJECT(**LEXER_CLASS**) : | + | INJECT(LEXER_CLASS) : |
- | { | + | |
- | ... | + | |
- | } | + | |
{ | { | ||
... | ... | ||
Line 54: | Line 48: | ||
INJECT(JSONParser) : | INJECT(JSONParser) : | ||
- | { | ||
- | ... | ||
- | } | ||
{ | { | ||
... | ... |