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 revisionBoth sides next revision
new_settings_in_javacc_21 [2021/12/20 15:04] revuskynew_settings_in_javacc_21 [2022/02/15 01:49] chamberlain
Line 1: Line 1:
 Here is a list of settings that exist in JavaCC 21 but are not (and never were) present in the legacy JavaCC tool: Here is a list of settings that exist in JavaCC 21 but are not (and never were) present in the legacy JavaCC tool:
  
 +  * **BASE_NAME** This option is used to set the name of the parser, lexer, constants, and NFA data files instead of using the default naming convention that prefixes these files with the name of the grammar file. If this option is set to an empty string (BASE_NAME="";) then these filenames will not receive a prefix. 
   * **BASE_SRC_DIR** This supersedes the older OUTPUT_DIRECTORY setting. Files are generated //relative// to the BASE_SRC_DIR, i.e. taking into account the package naming. If this is unset, BASE_SRC_DIR is assumed to be the directory where the grammar is.   * **BASE_SRC_DIR** This supersedes the older OUTPUT_DIRECTORY setting. Files are generated //relative// to the BASE_SRC_DIR, i.e. taking into account the package naming. If this is unset, BASE_SRC_DIR is assumed to be the directory where the grammar is.
 +  * **CONSTANTS_CLASS** This option is used to set the name of the generated constants file instead of using the default file name based on the grammar filename.
   * **DEACTIVATE_TOKENS** This setting allows you to indicate that certain token types are de-activated by default when you instantiate the parser. Something like: ''DEACTIVATE_TOKENS=OPEN_PAREN,CLOSE_PAREN;'' would mean that those two tokens are not //active// by default when you instantiate the parser. Of course, you could use ''ACTIVE_TOKENS(....)'' to activate them when needed in the parse.   * **DEACTIVATE_TOKENS** This setting allows you to indicate that certain token types are de-activated by default when you instantiate the parser. Something like: ''DEACTIVATE_TOKENS=OPEN_PAREN,CLOSE_PAREN;'' would mean that those two tokens are not //active// by default when you instantiate the parser. Of course, you could use ''ACTIVE_TOKENS(....)'' to activate them when needed in the parse.
   * **ENSURE_FINAL_EOL** With this setting turned on (it is off by default) the generated parser ensures that the input file ends with a newline character. (It tacks one on if it is not present.) This is a nitpicking detail but it is surprisingly difficult to write certain grammars (ones that are very line-oriented) if you cannot be sure that every line (including the last one!) ends with a newline.   * **ENSURE_FINAL_EOL** With this setting turned on (it is off by default) the generated parser ensures that the input file ends with a newline character. (It tacks one on if it is not present.) This is a nitpicking detail but it is surprisingly difficult to write certain grammars (ones that are very line-oriented) if you cannot be sure that every line (including the last one!) ends with a newline.
   * **EXTRA_TOKENS** This setting allows you to indicate some additional token types that are not defined with regular expressions in the lexical grammar. This can be useful particularly in token hook routines.   * **EXTRA_TOKENS** This setting allows you to indicate some additional token types that are not defined with regular expressions in the lexical grammar. This can be useful particularly in token hook routines.
   * **FAULT_TOLERANT** This turns on the experimental support for building a [[fault tolerant]] parser. It is off by default.   * **FAULT_TOLERANT** This turns on the experimental support for building a [[fault tolerant]] parser. It is off by default.
 +  * **LEXER_CLASS** This option sets the name of the generated lexer file instead of using the default file name based on the grammar filename. This option also sets the name of the NFA data file to use this same prefix. For example, LEXER_CLASS="FooLexer"; generates FooLexer.java and FooNfaData.java.
 +  * **PARSER_CLASS** This option is used to set the name of the generated parser file instead of using the default file name based on the grammar filename.
   * **PRESERVE_LINE_ENDINGS** This is now off by default. That means that all Windows/DOS style line endings (\r\n) are converted to UNIX/MacOS style (\n) internally when the file is read in. Note, by the way, that one advantage of this and the TABS_TO_SPACES option is that if you convert tabs to spaces and line endings to \n then your grammar's lexical specification can be a bit simpler. And your own code that runs over Tokens and Nodes. Your code can just assume that any line endings are a simple \n and and your horizontal whitespace is just spaces, not a mix of tabs and spaces, independently of what platform the generated code is running on.   * **PRESERVE_LINE_ENDINGS** This is now off by default. That means that all Windows/DOS style line endings (\r\n) are converted to UNIX/MacOS style (\n) internally when the file is read in. Note, by the way, that one advantage of this and the TABS_TO_SPACES option is that if you convert tabs to spaces and line endings to \n then your grammar's lexical specification can be a bit simpler. And your own code that runs over Tokens and Nodes. Your code can just assume that any line endings are a simple \n and and your horizontal whitespace is just spaces, not a mix of tabs and spaces, independently of what platform the generated code is running on.
   * **SMART_NODE_CREATION** This is the default behavior, so you would have to explicitly turn it off. It means that if no JJTree-style tree-building annotation is used, then a new Node will be created if there are more than one Nodes on the stack. So, a production like '' A (B)* '' will create a new Node if there are one or more B's after the A. If there is only an ''A'' then the production will just leave it on the stack. It is our belief that this is the behavior that most people would want most of the time.   * **SMART_NODE_CREATION** This is the default behavior, so you would have to explicitly turn it off. It means that if no JJTree-style tree-building annotation is used, then a new Node will be created if there are more than one Nodes on the stack. So, a production like '' A (B)* '' will create a new Node if there are one or more B's after the A. If there is only an ''A'' then the production will just leave it on the stack. It is our belief that this is the behavior that most people would want most of the time.