Grammar Options - RopleyIT/GLRParser GitHub Wiki

Options section of grammar file

This section is used to list various settable options used by the parser generator. When generating the source code for the parser from the grammar input, these options are used to configure parts of the source code.

The list of options contained between the opening and closing curly braces of the options section can be in one of two formats. Either each option is just a keyword whose presence causes a corresponding flag to be set to true, or is a keyword followed by an identifier string. Options are separated from each other by commas, meaning that no comma is required after the last option in the list. At present, the following table lists all the options that have been implemented.

At present there are three possible options that can be set in the options section:

OPTION DEFAULT DESCRIPTION
assemblyref dllName (No default) This option is equivalent to adding a reference to an external assembly if the types in that assembly are needed by the inline source code in the grammar file. This option is only permitted in grammars that are being parsed for use in an inline parser. If this option appears in a grammar that is compiled with ParseLR.exe, it will cause an error message to be displayed, and no output source code will be generated. The alternative option reference is an alias for assemblyref.
using nameSpaceName (No default) This option adds a using statement to the top of the generated source file when creating the source code for an off-line parser. Its purpose is to allow the action code embedded in the off-line version of the grammar rules to gain access to .NET libraries or project DLLs without having to spell out full namespaces on library members. This option can appear multiple times, thereby permitting multiple using statements to be added to the source code. Note that there is a default list of namespaces for which using statements are added to the source code anyway. The list includes: System, System.Linq, System.Text, System.IO, and System.Collections.Generic. If you provide no using statements in the options section, these are automatically added. If you provide any using statements, this automatic addition is disabled and you will have to provide using statements for each library namespace your FSM code will need.
namespace nameSpaceName Parsing This sets the namespace for the output source code when creating an off-line parser. The value should match the namespace within which the parser class will be compiled along with its other application-specific classes.
parserclass className LRParser This sets the name of the parser class in the source code. It should obviously match the parser class name you have chosen in your non-auto-generated part of the parser class.

Example

options
{
    assemblyref SomeAssembly.dll, // An externally referenced assembly
    using System.Reflection,      // Clearly our application uses the reflection APIs
    using System.Xml,             // An example of a second using statement
    namespace MyApplication,      // Set the enclosing namespace for the application
    parserclass MyParser          // Note the absence of a trailing comma
}
⚠️ **GitHub.com Fallback** ⚠️