Class LexerTokenRule<TLexerState>
The lexer token rule class. It defines how and when a token will be generated for given regular expression pattern.
Inherited Members
Namespace: SpiceSharpParser.Lexers
Assembly: SpiceSharpParser.dll
Syntax
public class LexerTokenRule<TLexerState> : LexerRegexRule where TLexerState : LexerState
Type Parameters
Name | Description |
---|---|
TLexerState | Type of lexer state. |
Constructors
| Improve this Doc View SourceLexerTokenRule(Int32, String, String, Func<TLexerState, String, LexerRuleReturnDecision>, Func<TLexerState, String, LexerRuleUseDecision>, Boolean, Boolean)
Initializes a new instance of the LexerTokenRule<TLexerState> class.
Declaration
public LexerTokenRule(int tokenType, string ruleName, string regularExpressionPattern, Func<TLexerState, string, LexerRuleReturnDecision> returnDecisionProvider = null, Func<TLexerState, string, LexerRuleUseDecision> useDecisionProvider = null, bool ignoreCase = true, bool topRule = false)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | tokenType | Token type. |
System.String | ruleName | Rule name. |
System.String | regularExpressionPattern | A token rule pattern. |
System.Func<TLexerState, System.String, LexerRuleReturnDecision> | returnDecisionProvider | A token rule return decision provider. |
System.Func<TLexerState, System.String, LexerRuleUseDecision> | useDecisionProvider | A token rule use decision provider. |
System.Boolean | ignoreCase | Ignore case. |
System.Boolean | topRule | Is most important rule. |
Properties
| Improve this Doc View SourceReturnDecisionProvider
Gets the provider that tells whether the rule should be returned.
Declaration
public Func<TLexerState, string, LexerRuleReturnDecision> ReturnDecisionProvider { get; }
Property Value
Type | Description |
---|---|
System.Func<TLexerState, System.String, LexerRuleReturnDecision> |
TokenType
Gets the type of a generated token.
Declaration
public int TokenType { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
TopRule
Gets the value indicating whether rule is most important.
Declaration
public bool TopRule { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
UseDecisionProvider
Gets the provider that tells whether the rule should be used.
Declaration
public Func<TLexerState, string, LexerRuleUseDecision> UseDecisionProvider { get; }
Property Value
Type | Description |
---|---|
System.Func<TLexerState, System.String, LexerRuleUseDecision> |
Methods
| Improve this Doc View SourceCanUse(TLexerState, String)
Returns true if the rule is active or should be skipped.
Declaration
public bool CanUse(TLexerState lexerState, string lexem)
Parameters
Type | Name | Description |
---|---|---|
TLexerState | lexerState | The current lexer state. |
System.String | lexem | A lexem value. |
Returns
Type | Description |
---|---|
System.Boolean | True if the lexer token rule is active or should be skipped. |
Clone()
Clones the rule.
Declaration
public override LexerRegexRule Clone()
Returns
Type | Description |
---|---|
LexerRegexRule | A clone of rule. |