Configuration
This chapter contains examples of configuration settings organized by category.
You can copy these options to input files .
General settings
Only selected options are shown.
// ========== Comments (global level) ==========
// Header comment placed in each file
%option Code.HeaderComment "My application"
%option Code.HeaderComment "by John Doe"
%option Code.HeaderComment "...more rows..."
// Comment generation, settings given below turn 'everything on'
%option Code.AppComments Detailed
%option Code.UserComments On
%option Code.UserCommentsDecoration On
// ========== Namespaces (global level) ==========
// Default namespace for all generated files
// Can be overriden in particual files
%option Code.Namespace "MyNamespace"
// References to external namespaces
// These references appear in all generated files
// (Other references can be added in each file)
%option Code.Using "SomeNamespace"
%option Code.Using "OtherNamespace"
// ========== Base class ==========
// A single common base class for all lexers and all parsers
// can be generated. Alternatively each lexer and parser
// can have its own distinct hierarchy of classes
%option Code.Base.OwnClass true
%option Code.Base.BaseClassName "MyBase"
// additional settings:
%option Code.Base.FileName "MyBaseFilename" // if necessary
%option Code.Base.Namespace "DifferentNamespace" // if necessary
Lexer settings
// ========== Lexer base class ==========
// Declaring a base lexer class makes sense only
// if there are mutliple lexers in the application
// and common class for all of them is required
%option Lexer.Code.BaseClass.ClassName "BaseForAllLexers"
// ========== Lexer definitions ==========
// When there are multiple lexers in the application
// their common definitions can be placed in a single file
// and referenced from all generated lexers
%option Lexer.Code.BaseDefs.OwnFile true
%option Lexer.Code.BaseDefs.FileName "CommonLexerDefs"
// there is also one more option: to place these definitions
// toghter with base class (if one is used):
%option Lexer.Code.BaseDefs.WithBase true
// ========== Lexer class ==========
// Class containing lexer
%option Lexer.Code.Lexer.ClassName "MyLexer"
%option Lexer.Code.Lexer.FileName "MyLexerFile"
// ========== Implementation of lexer methods ==========
// Implementation of ReadInputBytes/ReadInputChars (required)
// Way of implementing can be customized here
%option Lexer.Code.ReadInputImpl UserCode // UserCode is default
// NextToken() function custom arguments (optional)
%option Lexer.Code.NextTokenFuncArgs Custom
%option Lexer.Code.NextTokenFuncArgsCustom { int someArg, string otherArg }
// ========== Lexer features ==========
// DO NOT enable all features
// Enable only features you need
// REJECT
%option Lexer.RejectEnabled true
// MORE
%option Lexer.MoreEnabled true
// LESS
%option Lexer.LessEnabled true
// Tracing location
%option Lexer.LocationInfoEnabled
// ========== Input buffer format ==========
// Lexer can read bytes or chars
// Input format is controlled by option:
%option Lexer.In.Formats Bytes // Bytes, Chars or BytesChars
// when set to BytesChars, default format is given here:
%option Lexer.In.FormatDefault Bytes
// ========== Input encoding ==========
// Input encoding can be fixed or switchable.
%option Lexer.In.EncodingSwitchable true
// User can explicily specify list of supported encodings
// When this option is not set, all encodings are supported
%option Lexer.In.Encodings ASCII, UTF8
%option Lexer.In.Encodings UTF16
// This option sets default encoding (if encodins are switchable)
// or the only encoding (when non-switcahble)
%option Lexer.In.Encoding UTF8
// For two-byte encodings endiannes can be specified
// With autodetection on, this is default endiannes
%option Lexer.In.Endiannes LE
// Autodetection can be used when encoding is switchable
%option Lexer.In.EncodingAutodetect true
// Some extra options can be set (usually defaults are fine)
%option Lexer.In.EncodingAutodetectOptions None
// ========== Handling EOL characters ==========
// By default EOLs are converted to symbol
%option Lexer.Eol.Mode Symbol // Symbol, Chars or None
// Multiple EOLs can be defined (from predefined set)
%option Lexer.Eol.Codes CRLF, LSEP, PSEP
// (If completely custom EOL sequences are necessary
// these must be set programatically after lexer init)
// 'Artificial' EOL can be generated at end of file
%option Lexer.Eol.EolOnEof false // off by default
// If EOL sequences use high character codes, EOL map sholud be
// compressed. Auto setting takes care of it.
%option Lexer.Eol.MapMode Auto // Auto by default
// ========== Debugging Lexer ==========
// adds structures describing lexer gramamr
// (remember to disable it in production code)
%option Lexer.Debug.Infos true
// adds methods for browsing automaton
%option Lexer.Debug.Methods true
// enable report of most recent steps taken by lexer
%option Lexer.Debug.RecentStepsReport true
%option Lexer.Debug.RecentStepsCount 100 // 100 is default
// other options
%option Lexer.Debug.LastInputChar true
%option Lexer.Debug.Comments true
// ========== Tracing Lexer ==========
// Following options add methods for tracing
// lexer activity. User must provide
// implementation for enabled methods
%option Lexer.Trace.InputMatched true
%option Lexer.Trace.InputMatchedImpl UserCode
%option Lexer.Trace.NextSymbol true
%option Lexer.Trace.NextSymbolImpl UserCode
%option Lexer.Trace.InputNotMatched true
%option Lexer.Trace.InputNotMatchedImpl UserCode
Parser settings
// ========== Parser definitions ==========
// When there are multiple parsers in the application
// their common definitions can be placed in single file
// and referenced from all generated parses
%option Parser.Code.BaseDefs.OwnFile true
%option Parser.Code.BaseDefs.FileName "CommonParserDefs"
// ========== Parser class ==========
// Class containing parser
%option Parser.Code.Parser.ClassName "MyParser"
%option Parser.Code.Parser.FileName "MyParserFile"
// ========== Parser main settings ==========
// Type of grammar, it's best to use default LROpt
%option Parser.GrammarType LROpt
// Operation mode, default is Pull
%option Parser.PullPush Pull
// Use defaulting, Setting On decreases parser tables
%option Parser.Reduction.Defaulting On
// When defaulting is used, preview
// provides early error detection
%option Parser.Reduction.PreviewCheck Yes
// ========== Conflict handling settings ==========
// Enable this to prefer shift over reduce
%option Parser.Conflicts.SR_ResolveAsShift Yes
// ========== Value storage ==========
// Placement of values, on stack or dedicated heap
%option Parser.ValueData.Placement Stack // Stack is default
// When single value type is used, this sets type
%option Parser.Value.FieldType "string"
// ========== Location handling ==========
// Parser can trace from-to ranges or just start locations
%option Parser.Location.Mode Range // Off, Start or Range
// Parser can calculate location of nonterminals
// from locations of reduced elements
%option Parser.Location.AutoCalc true
// ========== Debugging Parser ==========
// add structures describing parser grammar
// (remember to disable it in production code)
%option Parser.Debug.Infos true
// add structures dscribing automaton
%option Parser.Debug.StateInfos true
// add methods for browsing automaton
// these work best if StateInfos is enabled as well
%option Parser.Debug.Methods true
// save additional debug info on automaton stack
%option Parser.Debug.DebugStack true
// enable report of most recent steps taken by parer
%option Parser.Debug.RecentStepsReport true
%option Parser.Debug.RecentStepsCount 100 // 100 is default
// summary of value data can be stored in recent steps
// (this introduces some performance penalty)
%option Parser.Debug.RecentStepsValueData
// other options
%option Parser.Debug.LastErrorInfo true
%option Parser.Debug.Comments true
// ========== Tracing Parser ==========
// Following options add methods for tracing
// parser activity. User must provide
// implementation for enabled methods
%option Parser.Trace.ParseError true
%option Parser.Trace.ParseErrorImpl UserCode
%option Parser.Trace.ParseReduce true
%option Parser.Trace.ParseReduceImpl UserCode
%option Parser.Trace.ParseShift
%option Parser.Trace.ParseShiftImpl UserCode