meta data for this page
  •  

This is an old revision of the document!


Obsolete Settings from Legacy JavaCC

As a result of quite a bit of forward evolution, some of the settings from legacy JavaCC (and JJTree) are obsolete in JavaCC21. We don't anticipate that any of them will be missed.

  • STATIC: JavaCC21 does not support static parsers. Or, in other words, this is always set to false, (and thus, ignored.)
  • UNICODE_INPUT: Effectively, this is now always set to true, so it is superfluous, (and thus, ignored.)
  • USER_CHAR_STREAM: This was a setting that allowed you to define your own implementation of the CharStream interface. It seems unlikely that very many (if any) people were using this and it has been removed in order to simplify the codebase.
  • BUILD_LEXER: It is rather hard to fathom what the point of this setting ever was. Presumably, the case where you don't build a lexer is the one in which you define your own XXXLexer implementation. However, the USER_DEFINED_LEXER setting (previously called USER_TOKEN_MANAGER) always existed, so it is not clear why this setting was ever needed.
  • BUILD_PARSER: Another bizarre setting really. If all you want to do is build a lexer, and not a parser, then just don't define any grammatical productions in your grammar and all we build is a parser!
  • KEEP_LINE_COL: JavaCC21 always puts location information in Tokens and Node objects. (Really, why would you ever want to throw away location info?) For more thoughts on this issue, see The Gigabyte is the new Megabyte.
  • ERROR_REPORTING: This was an option that was true by default, but you could turn it off in order to generate a somewhat smaller .class file, except that error messages would be much less informative because of information being thrown away. I did some experimenting and found that the generated XXXParser.class was typically about 10% smaller with ERROR_REPORTING off. The tradeoff looks terrible and, as with KEEP_LINE_COL, it looks utterly foolish to ever turn this off. So, the setting is now gone and the option is always effectively on.
  • SANITY_CHECK: By default, the parser generator does some various sanity checks before generating the various files. This setting in the legacy JavaCC tool allowed you to turn this off. (Why would anybody turn this off?) This setting is gone and is now effectively always true.
  • CACHE_TOKENS: I never even understood what the point of this setting was. It must have been some kind of speculative peephole optimization, except I don't think it was even correct. There would be problems with switches of lexical state in some cases. The setting is now gone and is always effectively false. (Which was the default before, which everybody was using anyway.)
  • TRACK_TOKENS : There is no real reason for this setting to exist any more, since, by default, Tokens are added to the AST and they have their line/column information. In fact, all Node objects have line/column information.
  • COMMON_TOKEN_ACTION : This feature is still supported but the configuration setting is no longer necessary, since JavaCC21 deduces it from the presence (or absence) of the appropriately named method in your generated lexer class.
  • NODE_SCOPE_HOOK : As with COMMON_TOKEN_OPTION, the feature is still supported but the configuration option is no longer necessary, since JavaCC21 deduces it from the presence or absence of the appropriately named method or methods in your generated parser class. See Node Life Cycle Hooks for more information.
  • NODE_EXTENDS : Since JavaCC21 has the INCLUDE statement, there is no need for this configuration option to exist. If you want to specify that your BaseNode class extends some specific class, simply use code injection to specify this.

   INJECT(BaseNode) : {extends SomeClass}

The following configuration options are still supported but are deprecated in JavaCC21:

  • OUTPUT_DIRECTORY: This is deprecated in favor of the new BASE_SRC_DIR option. See convention over configuration for more information on the preferred way to specify your directory layout when using JavaCC21.
  • NODE_PREFIX: Use of this is not encouraged in JavaCC21. By default, it is simply the empty string. (In JavaCC (or JJTree to be precise) it was “AST” by default.)

The following option has been renamed for consistency, but the older name is still supported:

USER_TOKEN_MANAGER is now USER_DEFINED_LEXER.

The use of both PARSER_BEGIN….PARSER_END and TOKEN_MGR_DECLS is deprecated in favor of the new code injection feature. Injecting code into the generated parser and lexer is simply a specific case of code injection, so there is no need for these separate constructs.

To specify the parser class name, you may use the PARSER_CLASS configuration option. However, it is not mandatory, since a Foo.javacc file will automatically generate a parser class called FooParser and a lexer class called FooLexer.

See new settings in JavaCC 21 for information on settings introduced in JavaCC21 that were not present in legacy JavaCC.