Class: TDParser::TerminalParser
Instance Attribute Summary collapse
-
#equality ⇒ Object
readonly
Returns the value of attribute equality.
-
#symbol ⇒ Object
readonly
Returns the value of attribute symbol.
Instance Method Summary collapse
- #==(r) ⇒ Object
- #call(tokens, buff) ⇒ Object
-
#initialize(obj, eqsym) ⇒ TerminalParser
constructor
A new instance of TerminalParser.
- #to_s ⇒ Object
Methods inherited from Parser
#%, #*, #+, #-, #/, #>, #>>, #do, #optimize, #parse, #peek, #same?, #to_proc, #|, #~@
Methods included from TDParser
#any_rule, #backref, #chainl, #chainr, #condition_rule, define, #empty_rule, #fail_rule, #leftrec, #none_rule, #rightrec, #rule, #stackref, #state, #token
Methods included from BufferUtils
Constructor Details
#initialize(obj, eqsym) ⇒ TerminalParser
Returns a new instance of TerminalParser.
240 241 242 243 |
# File 'lib/tdp.rb', line 240 def initialize(obj, eqsym) @symbol = obj @equality = eqsym end |
Instance Attribute Details
#equality ⇒ Object (readonly)
Returns the value of attribute equality.
238 239 240 |
# File 'lib/tdp.rb', line 238 def equality @equality end |
#symbol ⇒ Object (readonly)
Returns the value of attribute symbol.
238 239 240 |
# File 'lib/tdp.rb', line 238 def symbol @symbol end |
Instance Method Details
#==(r) ⇒ Object
255 256 257 258 259 |
# File 'lib/tdp.rb', line 255 def ==(r) (self.class == r.class) && (@symbol == r.symbol) && (@equality == r.equality) end |
#call(tokens, buff) ⇒ Object
245 246 247 248 249 250 251 252 253 |
# File 'lib/tdp.rb', line 245 def call(tokens, buff) t = tokens.shift buff.unshift(t) if( @symbol.__send__(@equality,t) || t.__send__(@equality,@symbol) ) Sequence[t] else nil end end |
#to_s ⇒ Object
261 262 263 |
# File 'lib/tdp.rb', line 261 def to_s() "#{@symbol}" end |