Class: TDParser::NonTerminalParser
Overview
end of Parser
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#symbol ⇒ Object
readonly
Returns the value of attribute symbol.
Instance Method Summary collapse
- #==(r) ⇒ Object
- #call(tokens, buff) ⇒ Object
-
#initialize(context, sym, *options) ⇒ NonTerminalParser
constructor
A new instance of NonTerminalParser.
- #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(context, sym, *options) ⇒ NonTerminalParser
Returns a new instance of NonTerminalParser.
208 209 210 211 212 |
# File 'lib/tdp.rb', line 208 def initialize(context, sym, *) @context = context @symbol = sym @options = end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
207 208 209 |
# File 'lib/tdp.rb', line 207 def context @context end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
207 208 209 |
# File 'lib/tdp.rb', line 207 def @options end |
#symbol ⇒ Object (readonly)
Returns the value of attribute symbol.
207 208 209 |
# File 'lib/tdp.rb', line 207 def symbol @symbol end |
Instance Method Details
#==(r) ⇒ Object
225 226 227 228 229 230 |
# File 'lib/tdp.rb', line 225 def ==(r) (self.class == r.class) && (@context == r.context) && (@symbol == r.symbol) && (@options == r.) end |
#call(tokens, buff) ⇒ Object
214 215 216 217 218 219 220 221 222 223 |
# File 'lib/tdp.rb', line 214 def call(tokens, buff) res = nil case @symbol when Symbol, String res = @context.__send__(@symbol,*@options).call(tokens, buff) when Parser res = @symbol.call(tokens, buff) end res end |
#to_s ⇒ Object
232 233 234 |
# File 'lib/tdp.rb', line 232 def to_s() "#{@symbol.to_s}" end |