Sha256: 03677624b431a1decd713165e28c1cde158d8ecc6099bf10bd0ae5f0aac577f3
Contents?: true
Size: 642 Bytes
Versions: 3
Compression:
Stored size: 642 Bytes
Contents
# A small example on how to make parslet ignore parts of the parse tree. $:.unshift File.dirname(__FILE__) + "/../lib" require 'parslet' class IgnoreParslet < Parslet::Atoms::Base def initialize(parslet) @parslet = parslet end def to_s_inner(prec) @parslet.to_s(prec) end def try(source, context) success, value = result = @parslet.try(source, context) return succ(nil) if success return result end end module IgnoreDSL def ignore IgnoreParslet.new(self) end end class Parslet::Atoms::Base include IgnoreDSL end include Parslet p (str('a') >> str('b').ignore >> str('c')). parse('abc')
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
ghazel-parslet-1.4.0.2 | example/ignore.rb |
ghazel-parslet-1.4.0.1 | example/ignore.rb |
parslet-1.4.0 | example/ignore.rb |