Sha256: b09e7f00a42813f10b709fb5aff659b16b2130b54b3429abbf4c6bd024341223
Contents?: true
Size: 703 Bytes
Versions: 12
Compression:
Stored size: 703 Bytes
Contents
# Names a match to influence tree construction. # # Example: # # str('foo') # will return 'foo', # str('foo').as(:foo) # will return :foo => 'foo' # class Parslet::Atoms::Named < Parslet::Atoms::Base attr_reader :parslet, :name def initialize(parslet, name) super() @parslet, @name = parslet, name end def apply(source, context, consume_all) success, value = result = parslet.apply(source, context, consume_all) return result unless success succ( produce_return_value( value)) end def to_s_inner(prec) "#{name}:#{parslet.to_s(prec)}" end private def produce_return_value(val) { name => flatten(val, true) } end end
Version data entries
12 entries across 12 versions & 2 rubygems