Class: Rattler::BackEnd::ParserGenerator::BackReferenceGenerator

Inherits:
ExprGenerator
  • Object
show all
Defined in:
lib/rattler/back_end/parser_generator/back_reference_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ExprGenerator

#gen_direct_action, #gen_dispatch_action, #gen_intermediate, #initialize

Methods included from Parsers

define

Constructor Details

This class inherits a constructor from Rattler::BackEnd::ParserGenerator::ExprGenerator

Class Method Details

.nested(*args) ⇒ Object



56
57
58
# File 'lib/rattler/back_end/parser_generator/back_reference_generator.rb', line 56

def BackReferenceGenerator.nested(*args)
  NestedBackReferenceGenerator.new(*args)
end

.top_level(*args) ⇒ Object



65
66
67
# File 'lib/rattler/back_end/parser_generator/back_reference_generator.rb', line 65

def BackReferenceGenerator.top_level(*args)
  TopLevelBackReferenceGenerator.new(*args)
end

Instance Method Details

#gen_assert(ref, scope = {}) ⇒ Object



12
13
14
15
16
17
# File 'lib/rattler/back_end/parser_generator/back_reference_generator.rb', line 12

def gen_assert(ref, scope={})
  expr do
    gen_intermediate_assert ref, scope
    @g << ' && true'
  end
end

#gen_basic(ref, scope = {}) ⇒ Object

:nodoc:



8
9
10
# File 'lib/rattler/back_end/parser_generator/back_reference_generator.rb', line 8

def gen_basic(ref, scope={})
  @g << "@scanner.scan(#{ref.re_expr(scope)})"
end

#gen_disallow(ref, scope = {}) ⇒ Object



19
20
21
22
23
24
# File 'lib/rattler/back_end/parser_generator/back_reference_generator.rb', line 19

def gen_disallow(ref, scope={})
  expr do
    gen_intermediate_disallow ref, scope
    @g << ' && true'
  end
end

#gen_intermediate_assert(ref, scope = {}) ⇒ Object



37
38
39
# File 'lib/rattler/back_end/parser_generator/back_reference_generator.rb', line 37

def gen_intermediate_assert(ref, scope={})
  @g << "@scanner.skip(/(?=#{ref.re_source(scope)})/)"
end

#gen_intermediate_disallow(ref, scope = {}) ⇒ Object



41
42
43
# File 'lib/rattler/back_end/parser_generator/back_reference_generator.rb', line 41

def gen_intermediate_disallow(ref, scope={})
  @g << "@scanner.skip(/(?!#{ref.re_source(scope)})/)"
end

#gen_intermediate_skip(ref, scope = {}) ⇒ Object



45
46
47
# File 'lib/rattler/back_end/parser_generator/back_reference_generator.rb', line 45

def gen_intermediate_skip(ref, scope={})
  @g << "@scanner.skip(#{ref.re_expr(scope)})"
end

#gen_skip(ref, scope = {}) ⇒ Object



30
31
32
33
34
35
# File 'lib/rattler/back_end/parser_generator/back_reference_generator.rb', line 30

def gen_skip(ref, scope={})
  expr do
    gen_intermediate_skip ref, scope
    @g << ' && true'
  end
end

#gen_token(ref, scope = {}) ⇒ Object



26
27
28
# File 'lib/rattler/back_end/parser_generator/back_reference_generator.rb', line 26

def gen_token(ref, scope={})
  gen_basic ref, scope
end