class Parslet::Expression


its own gem one fine day.
This can be viewed as an extension to parslet and might even be hosted in
fledged parser and on the other hand might even turn out really useful.
does, minus the actions. This is on one hand a good example of a fully
Allows specifying rules as strings using the exact same grammar that treetop

def initialize(str, opts={}, context=self)


Parslet::Expression.new("'a' 'b'")

Example:

Creates a parslet from a foreign language expression.
def initialize(str, opts={}, context=self)
  @type = opts[:type] || :treetop
  @exp = str
  @parslet = transform(
    parse(str))
end

def parse(str)


Parses the string and returns a parse tree.
def parse(str)
  parser = Treetop::Parser.new
  parser.parse(str)
end

def to_parslet


Turns this expression into a parslet.
def to_parslet
  @parslet
end

def transform(tree)


Transforms the parse tree into a parslet expression.
def transform(tree)
  transform = Treetop::Transform.new
  
  # pp tree
  transform.apply(tree)
rescue 
  warn "Could not transform: " + tree.inspect
  raise
end