Module PatternMatching::USAGE
In: lib/patternmatching.rb
Exception NotMatched PatternFragments MatchExec Node NodeBuilder DSL_INSIDE DSL_MODULE DSL_OUTSIDE DSL_INSIDE USAGE VERSION Collector DSL_OUTSIDE DSL_MODULE PatternMatching dot/f_3.png
 The module is only for showing usage...

Using module

 # If installed from rubygems
 require "rubygems"
 gem "patternmatching"

 # for use
 require "patternmatching"

Structured data example

 val = 200
 code = PatternMatching.build {plus(mul(100, 100), val)}

Partial func example

 class Calc
   extend PatternMatching

   func(:calcm).seems as {plus(:a, :b)} do
     calcm(a) + calcm(b)
   end
   func(:calcm).seems as {mul(:a, :b)} do
     calcm(a) * calcm(b)
   end
   func(:calcm).seems as {:value} do
     value
   end
 end

 p Calc.new.calcm(code)

Pattern matching example

 include PatternMatching

 def calc(code)
   make(code) {
     seems as {plus(:a, :b)} do calc(a) + calc(b) end
     seems as {mul(:a, :b)} do  calc(a) * calc(b) end
     seems something do code end
   }
 end

 p calc(code)

For more

see README.txt

[Validate]