meta data for this page
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
convention_over_configuration [2020/02/13 21:07] – [Putting your AST Nodes in their own package] revusky | convention_over_configuration [2020/10/22 18:19] (current) – revusky | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Convention over Configuration (when possible) ====== | ====== Convention over Configuration (when possible) ====== | ||
- | It is our considered view that a tool having a plethora of configuration options can it make it far less usable. Or, at the very least, if there are a lot of configuration options, the neophyte user should be able to ignore them for the most part. One key aspect of this is having sensible defaults that correspond to the typical usage scenarios. Another aspect is simply having naming conventions so that the tool can infer the names of files and their locations, etcetera. | + | It is our considered view that a tool having a plethora of configuration options can make it far less usable. Or, at the very least, if there are a lot of configuration options, the neophyte user should be able to ignore them for the most part. One key aspect of this is having sensible defaults that correspond to the typical usage scenarios. Another aspect is simply having naming conventions so that the tool can infer the names of files and their locations, etcetera. |
===== Naming and Source Code Organization Conventions in JavaCC21 ===== | ===== Naming and Source Code Organization Conventions in JavaCC21 ===== | ||
Line 9: | Line 9: | ||
* The name of the generated parser class will be '' | * The name of the generated parser class will be '' | ||
- | * The generated lexer (a.k.a. *tokenizer*) class will be named '' | + | * The generated lexer (a.k.a. *tokenizer*) class will be named '' |
- | options { | ||
| | ||
... | ... | ||
- | } | ||
| | ||
However, for people who never used legacy JavaCC, this would have no bearing and we assume that most people would prefer the shorter name '' | However, for people who never used legacy JavaCC, this would have no bearing and we assume that most people would prefer the shorter name '' | ||
- | The generated constants interface will be called '' | + | The generated constants interface will be called '' |
- | If not specified otherwise, all classes will be generated with no package (the default package) in the same directory as the FreeCC | + | If not specified otherwise, all classes will be generated with no package (the default package) in the same directory as the grammar file. However, in this instance, it is strongly recommended that, at least for non-trivial projects, you should specify a package using the PARSER_PACKAGE option and also a base source directory using the new '' |
===== Putting your AST Nodes in their own package ===== | ===== Putting your AST Nodes in their own package ===== | ||
Line 26: | Line 24: | ||
If you have tree building enabled, you may wish to specify a separate directory in which to put the classes used to represent the nodes in your parse tree. You can do this using the NODE_PACKAGE option. Like PARSER_PACKAGE, | If you have tree building enabled, you may wish to specify a separate directory in which to put the classes used to represent the nodes in your parse tree. You can do this using the NODE_PACKAGE option. Like PARSER_PACKAGE, | ||
- | Note that the default name for the base node class has been changed from SimpleNode to BaseNode. If you wish to use a different name, for example, to keep using SimpleNode, you can use the BASE_NODE_CLASS option to specify a different name, i.e. BASE_NODE_CLASS=" | + | Note that the default name for the base node class has been changed from SimpleNode to BaseNode. If you wish to use a different name, for example, to keep using SimpleNode, you can use the BASE_NODE_CLASS option to specify a different name, i.e. BASE_NODE_CLASS=" |
Because of the above changes, there are various configuration options in legacy JavaCC that are no longer meaningful in JavaCC 21. They are listed here: [[Deprecated Settings]]. | Because of the above changes, there are various configuration options in legacy JavaCC that are no longer meaningful in JavaCC 21. They are listed here: [[Deprecated Settings]]. |