meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
include [2020/04/25 18:15] – external edit 127.0.0.1include [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="JSON"; +    DEFAULT_LEXICAL_STATE="JSON"; 
-    }+
          
 In that case, any grammar for a language that wants to handle embedded JSON data would presumably define its own "default" lexical state, and when it wants to embedded JSON data, would have to make an explicit switch to that JSON lexical state that is the *default* in the included grammar. In that case, any grammar for a language that wants to handle embedded JSON data would presumably define its own "default" lexical state, and when it wants to embedded JSON data, would have to make an explicit switch to that JSON lexical state that is the *default* in the included grammar.
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) :
-    { 
-       ... 
-    } 
     {     {
        ...        ...