Module: Brevity::Accent

Includes:
Treetop::Runtime
Included in:
AccentParser, Note
Defined in:
lib/brevity/parsing/note/accent.rb

Instance Method Summary collapse

Instance Method Details

#_nt_accentObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/brevity/parsing/note/accent.rb', line 13

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

  if has_terminal?(@regexps[gr = '\A[.\'>^_]'] ||= Regexp.new(gr), :regexp, index)
    r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
    @index += 1
  else
    terminal_parse_failure('[.\'>^_]')
    r0 = nil
  end

  node_cache[:accent][start_index] = r0

  r0
end

#rootObject



9
10
11
# File 'lib/brevity/parsing/note/accent.rb', line 9

def root
  @root ||= :accent
end