In Files

  • ripper/tools/dsl.rb

Parent

Methods

Class/Module Index [+]

Quicksearch

DSL

Simple DSL implementation for Ripper code generation

input: % ripper: stmts_add(stmts_new, void_stmt) %

output:

VALUE v1, v2;
v1 = dispatch0(stmts_new);
v2 = dispatch0(void_stmt);
$$ = dispatch2(stmts_add, v1, v2);

Attributes

events[R]

Public Class Methods

new(code, options) click to toggle source
 
               # File ripper/tools/dsl.rb, line 11
def initialize(code, options)
  @events = {}
  @error = options.include?("error")
  @brace = options.include?("brace")
  @final = options.include?("final")
  @vars = 0

  # create $1 == "$1", $2 == "$2", ...
  re, s = "", ""
  1.upto(9) do |n|
    re << "(..)"
    s << "$#{ n }"
  end
  /#{ re }/ =~ s

  # struct parser_params *p
  p = "p"

  @code = ""
  @last_value = eval(code)
end