Module: Rattler::Grammar::GrammarDSL::ClassMethods

Defined in:
lib/rattler/grammar/grammar_dsl.rb

Instance Method Summary collapse

Instance Method Details

#grammar(source = nil, &block) ⇒ Object



24
25
26
# File 'lib/rattler/grammar/grammar_dsl.rb', line 24

def grammar(source=nil, &block)
  Rattler.compile(self, source, &block)
end

#rule(name, &block) ⇒ Object



32
33
34
# File 'lib/rattler/grammar/grammar_dsl.rb', line 32

def rule(name, &block)
  rules { rule(name) {|b| b.instance_exec(&block) } }
end

#rules(&block) ⇒ Object



28
29
30
# File 'lib/rattler/grammar/grammar_dsl.rb', line 28

def rules(&block)
  Rattler.compile(self, &block)
end

#start_rule(name) ⇒ Object



20
21
22
# File 'lib/rattler/grammar/grammar_dsl.rb', line 20

def start_rule(name)
  define_method(:start_rule) { name }
end

#token(name, &block) ⇒ Object



36
37
38
# File 'lib/rattler/grammar/grammar_dsl.rb', line 36

def token(name, &block)
  rules { token(name) {|b| b.instance_exec(&block) } }
end

#with_options(options, &block) ⇒ Object



40
41
42
# File 'lib/rattler/grammar/grammar_dsl.rb', line 40

def with_options(options, &block)
  rules { with_options(options, &block) }
end

#with_ws(ws, &block) ⇒ Object



44
45
46
# File 'lib/rattler/grammar/grammar_dsl.rb', line 44

def with_ws(ws, &block)
  rules { with_ws(ws, &block) }
end