Module: Hemingway::Special

Includes:
Treetop::Runtime
Included in:
Latex, SpecialParser
Defined in:
lib/hemingway/special/special.rb

Defined Under Namespace

Modules: Special0

Instance Method Summary collapse

Instance Method Details

#_nt_escapeObject



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/hemingway/special/special.rb', line 145

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

  if has_terminal?("\\", false, index)
    r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
    @index += 1
  else
    terminal_parse_failure("\\")
    r0 = nil
  end

  node_cache[:escape][start_index] = r0

  r0
end

#_nt_specialObject



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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/hemingway/special/special.rb', line 24

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

  i0, s0 = index, []
  r1 = _nt_escape
  s0 << r1
  if r1
    i2 = index
    if has_terminal?("#", false, index)
      r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
      @index += 1
    else
      terminal_parse_failure("#")
      r3 = nil
    end
    if r3
      r2 = r3
    else
      if has_terminal?("$", false, index)
        r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        terminal_parse_failure("$")
        r4 = nil
      end
      if r4
        r2 = r4
      else
        if has_terminal?("%", false, index)
          r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure("%")
          r5 = nil
        end
        if r5
          r2 = r5
        else
          if has_terminal?("&", false, index)
            r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
            @index += 1
          else
            terminal_parse_failure("&")
            r6 = nil
          end
          if r6
            r2 = r6
          else
            if has_terminal?("_", false, index)
              r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
              @index += 1
            else
              terminal_parse_failure("_")
              r7 = nil
            end
            if r7
              r2 = r7
            else
              if has_terminal?("{", false, index)
                r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
                @index += 1
              else
                terminal_parse_failure("{")
                r8 = nil
              end
              if r8
                r2 = r8
              else
                if has_terminal?("}", false, index)
                  r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
                  @index += 1
                else
                  terminal_parse_failure("}")
                  r9 = nil
                end
                if r9
                  r2 = r9
                else
                  if has_terminal?("textbackslash{}", false, index)
                    r10 = instantiate_node(SyntaxNode,input, index...(index + 15))
                    @index += 15
                  else
                    terminal_parse_failure("textbackslash{}")
                    r10 = nil
                  end
                  if r10
                    r2 = r10
                  else
                    @index = i2
                    r2 = nil
                  end
                end
              end
            end
          end
        end
      end
    end
    s0 << r2
  end
  if s0.last
    r0 = instantiate_node(SpecialNode,input, i0...index, s0)
    r0.extend(Special0)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:special][start_index] = r0

  r0
end

#rootObject



10
11
12
# File 'lib/hemingway/special/special.rb', line 10

def root
  @root ||= :special
end