Class: SDL4R::Tokenizer::Matcher
- Inherits:
-
Object
- Object
- SDL4R::Tokenizer::Matcher
- Defined in:
- lib/sdl4r/tokenizer.rb
Overview
:nodoc: all
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
If
nil
, this Matcher is normal, otherwise it is meant to detect errors and this returns a message. -
#next_mode ⇒ Object
readonly
Returns the value of attribute next_mode.
-
#push_back_eol ⇒ Object
readonly
Indicates whether the matched token tends to match the end of line character and whether it should be pushed back in this cases.
-
#regex ⇒ Object
readonly
Returns the value of attribute regex.
-
#token_type ⇒ Object
readonly
Returns the value of attribute token_type.
Instance Method Summary collapse
-
#initialize(token_type, regex, options = {}, &block) ⇒ Matcher
constructor
:nodoc: all.
-
#process_token(token) ⇒ Object
Called when a token is found in order to remove meaningless characters, etc.
Constructor Details
#initialize(token_type, regex, options = {}, &block) ⇒ Matcher
:nodoc: all
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/sdl4r/tokenizer.rb', line 43 def initialize(token_type, regex, = {}, &block) = { :next_mode => nil, :push_back_eol => false, :error => nil, }.merge() @token_type = token_type @regex = regex @next_mode = [:next_mode] @push_back_eol = [:push_back_eol] @error = [:error] if block_given? instance_eval(&block) end end |
Instance Attribute Details
#error ⇒ Object (readonly)
If nil
, this Matcher is normal, otherwise it is meant to detect errors and this returns a message.
68 69 70 |
# File 'lib/sdl4r/tokenizer.rb', line 68 def error @error end |
#next_mode ⇒ Object (readonly)
Returns the value of attribute next_mode.
60 61 62 |
# File 'lib/sdl4r/tokenizer.rb', line 60 def next_mode @next_mode end |
#push_back_eol ⇒ Object (readonly)
Indicates whether the matched token tends to match the end of line character and whether it should be pushed back in this cases.
64 65 66 |
# File 'lib/sdl4r/tokenizer.rb', line 64 def push_back_eol @push_back_eol end |
#regex ⇒ Object (readonly)
Returns the value of attribute regex.
60 61 62 |
# File 'lib/sdl4r/tokenizer.rb', line 60 def regex @regex end |
#token_type ⇒ Object (readonly)
Returns the value of attribute token_type.
60 61 62 |
# File 'lib/sdl4r/tokenizer.rb', line 60 def token_type @token_type end |
Instance Method Details
#process_token(token) ⇒ Object
Called when a token is found in order to remove meaningless characters, etc.
71 72 73 |
# File 'lib/sdl4r/tokenizer.rb', line 71 def process_token(token) token end |