Class: Parsby::Token
- Inherits:
-
Object
- Object
- Parsby::Token
- Defined in:
- lib/parsby.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#%(p) ⇒ Object
Flipped version of Parsby#%, so you can specify the token of a parser at the beginning of a parser expression.
-
#==(t) ⇒ Object
Compare tokens.
-
#initialize(name) ⇒ Token
constructor
Makes a token with the given name.
-
#to_s ⇒ Object
Renders token name by surrounding it in angle brackets.
Constructor Details
#initialize(name) ⇒ Token
Makes a token with the given name.
381 382 383 |
# File 'lib/parsby.rb', line 381 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
378 379 380 |
# File 'lib/parsby.rb', line 378 def name @name end |
Instance Method Details
#%(p) ⇒ Object
Flipped version of Parsby#%, so you can specify the token of a parser at the beginning of a parser expression.
397 398 399 |
# File 'lib/parsby.rb', line 397 def %(p) p % self end |
#==(t) ⇒ Object
Compare tokens
391 392 393 |
# File 'lib/parsby.rb', line 391 def ==(t) t.is_a?(self.class) && t.name == name end |
#to_s ⇒ Object
Renders token name by surrounding it in angle brackets.
386 387 388 |
# File 'lib/parsby.rb', line 386 def to_s "<#{name}>" end |