class TDParser::Parser
Public Instance Methods
%(other)
click to toggle source
# File lib/tdparser/parser.rb, line 58 def %(other) StackParser.new(self, other) end
*(other)
click to toggle source
# File lib/tdparser/parser.rb, line 40 def *(other) if other.is_a?(Range) n = other.min else n = other other = nil end IterationParser.new(self, n, other) end
+(other)
click to toggle source
# File lib/tdparser/parser.rb, line 32 def +(other) ParallelParser.new(self, other) end
-(other)
click to toggle source
# File lib/tdparser/parser.rb, line 28 def -(other) ConcatParser.new(self, other) end
/(other)
click to toggle source
# File lib/tdparser/parser.rb, line 54 def /(other) LabelParser.new(self, other) end
==(_other)
click to toggle source
# File lib/tdparser/parser.rb, line 20 def ==(_other) false end
>(other)
click to toggle source
# File lib/tdparser/parser.rb, line 62 def >(other) Parser.new do |tokens, buff| buff[other] = buff.dup self[tokens, buff] end end
>>(other)
click to toggle source
# File lib/tdparser/parser.rb, line 50 def >>(other) ActionParser.new(self, other) end
call(*args)
click to toggle source
# File lib/tdparser/parser.rb, line 14 def call(*args); end
do(&block)
click to toggle source
# File lib/tdparser/parser.rb, line 100 def do(&block) self >> block end
optimize(_default = false)
click to toggle source
# File lib/tdparser/parser.rb, line 16 def optimize(_default = false) dup end
parse(tokens = nil, buff = nil, &blk)
click to toggle source
# File lib/tdparser/parser.rb, line 73 def parse(tokens = nil, buff = nil, &blk) buff ||= TokenBuffer.new @tokens = if blk.nil? if tokens.respond_to?(:shift) && tokens.respond_to?(:unshift) tokens elsif tokens.respond_to?(:each) TokenGenerator.new(tokens) else tokens end else TokenGenerator.new(&blk) end r = call(@tokens, buff) if r.nil? nil else r[0] end end
peek()
click to toggle source
# File lib/tdparser/parser.rb, line 94 def peek t = @tokens.shift @tokens.unshift(t) unless t.nil? t end
same?(r)
click to toggle source
# File lib/tdparser/parser.rb, line 24 def same?(r) self == r end
to_proc()
click to toggle source
# File lib/tdparser/parser.rb, line 6 def to_proc proc { |*x| call(*x) } end
to_s()
click to toggle source
# File lib/tdparser/parser.rb, line 10 def to_s '??' end
|(other)
click to toggle source
# File lib/tdparser/parser.rb, line 36 def |(other) ChoiceParser.new(self, other).optimize(true) end