Module: Interscript::DSL::Items

Includes:
SymbolMM
Included in:
Aliases, Group
Defined in:
lib/interscript/dsl/items.rb

Defined Under Namespace

Modules: Maps Classes: Map, Stages

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, **kwargs, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/interscript/dsl/items.rb', line 4

def method_missing sym, *args, **kwargs, &block
  super if args.length > 0
  super if kwargs.length > 0
  super if sym.to_s =~ /[?!=]\z/
  super unless sym.to_s =~ /\A[\w\d]+\z/
  super if block_given?

  Interscript::Node::Item::Alias.new(sym)
end

Instance Method Details

#any(*chars) ⇒ Object



14
15
16
17
# File 'lib/interscript/dsl/items.rb', line 14

def any(*chars)
  puts "any(#{chars.inspect}) from #{self.inspect}" if $DEBUG
  Interscript::Node::Item::Any.new(*chars)
end

#capture(expr) ⇒ Object

(…)



36
37
38
39
# File 'lib/interscript/dsl/items.rb', line 36

def capture(expr)
  puts "capture(#{expr.inspect}) from #{self.inspect}" if $DEBUG
  Interscript::Node::Item::CaptureGroup.new(expr)
end

#mapObject

Implementation of ‘map.x`



48
# File 'lib/interscript/dsl/items.rb', line 48

def map; Interscript::DSL::Items::Maps; end

#maybe(*chars) ⇒ Object

a?



20
21
22
23
# File 'lib/interscript/dsl/items.rb', line 20

def maybe(*chars)
  puts "maybe(#{chars.inspect}) from #{self.inspect}" if $DEBUG
  Interscript::Node::Item::Maybe.new(*chars)
end

#maybe_some(*chars) ⇒ Object



25
26
27
28
# File 'lib/interscript/dsl/items.rb', line 25

def maybe_some(*chars)
  puts "maybe_some(#{chars.inspect}) from #{self.inspect}" if $DEBUG
  Interscript::Node::Item::MaybeSome.new(*chars)
end

#ref(int) ⇒ Object

1



42
43
44
45
# File 'lib/interscript/dsl/items.rb', line 42

def ref(int)
  puts "ref(#{int.inspect}) from #{self.inspect}" if $DEBUG
  Interscript::Node::Item::CaptureRef.new(int)
end

#some(*chars) ⇒ Object



30
31
32
33
# File 'lib/interscript/dsl/items.rb', line 30

def some(*chars)
  puts "some(#{chars.inspect}) from #{self.inspect}" if $DEBUG
  Interscript::Node::Item::Some.new(*chars)
end

#stageObject

Implementation of ‘stage.x`



51
# File 'lib/interscript/dsl/items.rb', line 51

def stage; Stages.new; end