Module: Brevity::Modifier

Includes:
DuplicateModifier, StretchModifier, TransposeModifier, Treetop::Runtime
Included in:
Expression, ModifierParser, Sequence
Defined in:
lib/brevity/parsing/modifiers/modifier.rb

Instance Method Summary collapse

Methods included from StretchModifier

#_nt_stretch_modifier

Methods included from Duration

#_nt_den_only, #_nt_duration, #_nt_num_and_den, #_nt_num_only

Methods included from PositiveInteger

#_nt_positive_integer

Methods included from NonnegativeInteger

#_nt_nonnegative_integer

Methods included from TransposeModifier

#_nt_transpose_modifier

Methods included from DuplicateModifier

#_nt_duplicate_modifier

Instance Method Details

#_nt_modifierObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/brevity/parsing/modifiers/modifier.rb', line 19

def _nt_modifier
  start_index = index
  if node_cache[:modifier].has_key?(index)
    cached = node_cache[:modifier][index]
    if cached
      node_cache[:modifier][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  i0 = index
  r1 = _nt_transpose_modifier
  if r1
    r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
    r0 = r1
  else
    r2 = _nt_duplicate_modifier
    if r2
      r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
      r0 = r2
    else
      r3 = _nt_stretch_modifier
      if r3
        r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
        r0 = r3
      else
        @index = i0
        r0 = nil
      end
    end
  end

  node_cache[:modifier][start_index] = r0

  r0
end

#rootObject



9
10
11
# File 'lib/brevity/parsing/modifiers/modifier.rb', line 9

def root
  @root ||= :modifier
end