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
Last revisionBoth sides next revision
key_differences [2020/04/25 18:15] – external edit 127.0.0.1key_differences [2021/02/08 18:09] – ↷ Links adapted because of a move operation revusky
Line 16: Line 16:
  
 JavaCC 21 introduces a new statement called **INJECT** that allows you to "inject" code into the files that the tool generates. This can help you to avoid the error-prone anti-pattern of generating code and editing it afterwards. See [[Code Injection in JavaCC 21]] for more information. JavaCC 21 introduces a new statement called **INJECT** that allows you to "inject" code into the files that the tool generates. This can help you to avoid the error-prone anti-pattern of generating code and editing it afterwards. See [[Code Injection in JavaCC 21]] for more information.
 +
 +===== Streamlined Syntax =====
 +
 +JavaCC 21 incorporates an [[new syntax summary|alternative streamlined syntax]] that should be quite a bit more pleasant to write and easier to read.
 +
 +The difference is frequently dramatic. Where the legacy tool required you to write things like:
 +
 +<code>
 +    LOOKAHEAD (Foo() Bar()) Foo() Bar() Baz()
 +</code>
 +
 +in JavaCC 21 you could express the above as:
 +
 +<code>
 +     Foo Bar =>|| Baz
 +</code>         
 +
 +===== More powerful lookahead =====
 +
 +Perhaps most importantly, the longstanding bug of nested syntactic lookahead not working correctly has [[https://javacc.com/2020/07/15/nested-syntactic-lookahead-works/|finally been squashed]]!
 +
 +The ''SCAN'' construct (designed to supersede the legacy ''LOOKAHEAD'') offers a superset of the legacy ''LOOKAHEAD'' functionality. [[contextual_predicates]] predicates allow you to define conditions at [[choice points]] based on scanning backwards in the parse/lookahead stack. [[contextual_predicates]] also works in arbitrarily nested scanahead.
 +
 +The new [[up to here]] construct should eliminate the need to write more verbose and error-prone numerical and syntactic lookahead constructs. 
 +
 +
 +
  
 ===== JavaCC 21 is being actively developed ===== ===== JavaCC 21 is being actively developed =====
  
-JavaCC 21 now supports the full Java language up through Java 13. Since the [[Java.javacc|https://github.com/javacc21/javacc21/blob/master/src/main/grammars/Java.javacc]] is embedded in [[JavaCC.javacc|https://github.com/javacc21/javacc21/blob/master/src/main/grammars/JavaCC.javacc#L341]] using the new [[INCLUDE]] mechanism, that Java grammar is usable on its own. Note that this grammar successfully parses all the Java source code in the OpenJDK 13, as well as all the Java source code in JRuby, Jython, and FreeMarker. So, if anybody needs a Java code parser for use in their own projects, this is quite usable! +JavaCC 21 now supports the full Java language up through Java 15. Since the [[https://github.com/javacc21/javacc21/blob/master/src/main/grammars/Java.javacc|Java grammar]] is embedded in [[https://github.com/javacc21/javacc21/blob/master/src/main/grammars/JavaCC.javacc#L413|JavaCC grammar]] using the [[INCLUDE]] mechanism, that Java grammar is usable on its own. Note that this grammar successfully parses all the Java source code in the OpenJDK 15, as well as all the Java source code in JRuby, Jython, and FreeMarker. So, if anybody needs a Java code parser for use in their own projects, this is quite usable!