Class: Treetop::Runtime::SyntaxNode

Inherits:
Object
  • Object
show all
Defined in:
lib/abnftt.rb

Instance Method Summary collapse

Instance Method Details

#astObject



12
13
14
# File 'lib/abnftt.rb', line 12

def ast
  fail "undefined_ast #{inspect}"
end

#ast_from_percent(base, first, second) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/abnftt.rb', line 15

def ast_from_percent(base, first, second)
  c1 = first.to_i(base).chr(Encoding::UTF_8)
  case second[0]
  when nil
    ["cs", c1]
  when "-"
    c2 = second[1..-1].to_i(base).chr(Encoding::UTF_8)
    ["char-range", c1, c2]
  when "."
    el = second.split(".")
    el[0] = first
    ["cs", el.map {|c| c.to_i(base).chr(Encoding::UTF_8)}.join]
  else
    fail "ast_from_percent"
  end
end

#clean_abnfObject



5
6
7
8
9
10
11
# File 'lib/abnftt.rb', line 5

def clean_abnf
  if elements
    elements.map {|el| el.clean_abnf}.join
  else
    text_value
  end
end