Class: LexerKit::Builder::ModeDef
- Inherits:
-
Object
- Object
- LexerKit::Builder::ModeDef
- Defined in:
- lib/lexer_kit/builder/mode_def.rb
Overview
ModeDef represents a lexer mode definition.
Instance Attribute Summary collapse
-
#delimited ⇒ Object
Returns the value of attribute delimited.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
Instance Method Summary collapse
- #add_token(token_def) ⇒ Object
-
#initialize(name, location: nil) ⇒ ModeDef
constructor
A new instance of ModeDef.
- #inspect ⇒ Object
-
#literal_tokens ⇒ Object
Get all literal tokens (for SWITCH_BYTE optimization).
-
#regex_tokens ⇒ Object
Get all regex tokens.
Constructor Details
#initialize(name, location: nil) ⇒ ModeDef
Returns a new instance of ModeDef.
10 11 12 13 14 15 |
# File 'lib/lexer_kit/builder/mode_def.rb', line 10 def initialize(name, location: nil) @name = name @tokens = [] @delimited = nil @location = location end |
Instance Attribute Details
#delimited ⇒ Object
Returns the value of attribute delimited.
8 9 10 |
# File 'lib/lexer_kit/builder/mode_def.rb', line 8 def delimited @delimited end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
7 8 9 |
# File 'lib/lexer_kit/builder/mode_def.rb', line 7 def location @location end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/lexer_kit/builder/mode_def.rb', line 7 def name @name end |
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
7 8 9 |
# File 'lib/lexer_kit/builder/mode_def.rb', line 7 def tokens @tokens end |
Instance Method Details
#add_token(token_def) ⇒ Object
17 18 19 |
# File 'lib/lexer_kit/builder/mode_def.rb', line 17 def add_token(token_def) @tokens << token_def end |
#inspect ⇒ Object
31 32 33 |
# File 'lib/lexer_kit/builder/mode_def.rb', line 31 def inspect "#<ModeDef :#{@name} tokens=#{@tokens.size}>" end |
#literal_tokens ⇒ Object
Get all literal tokens (for SWITCH_BYTE optimization)
22 23 24 |
# File 'lib/lexer_kit/builder/mode_def.rb', line 22 def literal_tokens @tokens.select(&:literal?) end |
#regex_tokens ⇒ Object
Get all regex tokens
27 28 29 |
# File 'lib/lexer_kit/builder/mode_def.rb', line 27 def regex_tokens @tokens.select(&:regex?) end |