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
new_syntax_summary [2020/07/20 21:24] – [A list of lexical specifications, a.k.a. Token Productions can be written without the curly braces.] revuskynew_syntax_summary [2023/04/10 10:04] (current) revusky
Line 1: Line 1:
-====== Summary of the Newer Streamlined Syntax ======+====== Overview of the Newer Streamlined Syntax ======
  
-The following is a summary of the newer streamlined syntax that was recently [[https://javacc.com/2020/07/07/announce-new-syntax/|announced here.]]+The following is a summary of CongoCC'streamlined syntax from the perspective of somebody migrating 
 +from legacy JavaCC. Note that, unlike CongoCC's predecessor, JavaCC 21, CongoCC //does not// support the legacy syntax. Any existing grammar file must be converter. There is a utility available that automatically converts the legacy syntax to the streamlined syntax. You can pick up the [[https://parsers.org/download/javacc-full.jar|latest build of JavaCC 21]] and the converter can be invoked via ''java -jar javacc-full.jar convert MyGrammarfile''. (N.B. The converter is somewhat imperfect, and you may well need to hand-edit the results. Even so, it is bound to be timesaver.)
  
-I anticipate that there will soon be a utility available that automatically converts the legacy syntax to the streamlined syntax. In any case, there is no need to manually convert all of your code to the more streamlined syntax, since all the legacy syntax continues to work. Moreover, the two syntaxes can co-exist perfectly well in the same file. 
- 
-This page does not describe the new ''%%SCAN%%'' construct which is meant to supersede ''%%LOOKAHEAD%%''. That will be outlined separately. 
  
 ===== Nonterminals ===== ===== Nonterminals =====
Line 38: Line 36:
  
 </code> </code>
-you can now write:+you would now write:
  
 <code> <code>
Line 44: Line 42:
  
 </code> </code>
-===== A list of lexical specifications, a.k.a. Token Productions can be written without the curly braces. =====+===== A list of lexical specifications, a.k.a. Token Productions are written without the curly braces. =====
  
 In this case, they are written with no opening ''%%{%%'' and the list is ended with a semicolon. Thus, instead of writing: In this case, they are written with no opening ''%%{%%'' and the list is ended with a semicolon. Thus, instead of writing:
Line 61: Line 59:
  
 </code> </code>
-the newer, preferable syntax is:+the newer syntax is:
  
 <code> <code>
Line 75: Line 73:
  
 </code> </code>
-This is considered preferable, not because it saves much space (it doesn't!) but because one aspect of the newer syntax is that the ''%%{...}%%'' are reserved for elements that really are embedded Java actions. As you can see, in the newer syntax for BNF productions, the only use of ''%%{...}%%'' is for actual Java code. +This was deemedd to be preferable, not because it saves much space (it doesn't!) but because one aspect of the newer syntax is that the ''%%{...}%%'' are reserved for elements that really are embedded Java actions. As you can see, in the newer syntax for BNF productions, the only use of ''%%{...}%%'' is for actual Java code. 
  
 ===== The Options at the top of a file do not need to be in any sort of block. ===== ===== The Options at the top of a file do not need to be in any sort of block. =====
Line 88: Line 86:
  
 </code> </code>
-You can now simply put:+You now simply put:
  
 <code> <code>
Line 125: Line 123:
 <code> <code>
  INJECT MyNode :  INJECT MyNode :
-     import java.util.*;+     import java.util.List;
      extends AbstractBaseNode      extends AbstractBaseNode
      implements Nullable      implements Nullable
Line 133: Line 131:
     public List<Foo> getFoos() {return foos;}     public List<Foo> getFoos() {return foos;}
          
-    public void setFoos() {this.foos = foos;}+    public void setFoos(List<Foo> foos) {this.foos = foos;}
 } }
  
Line 141: Line 139:
 ===== New SCAN construct which replaces LOOKAHEAD ===== ===== New SCAN construct which replaces LOOKAHEAD =====
  
-This will be detailed in a separate page.+The new ''SCAN'' instruction supersedes the legacy ''LOOKAHEAD''. See [[scan statement|here]] for more information. 
 + 
 +===== New "up to here" syntax ===== 
 + 
 +The [[up to here]] syntax provides a way to specify [[choice points|lookahead]] in a much more clean, intuitive way. See [[up to here|here]] for more information.