Sha256: 70b24f531f2b3f8c841d85cc45620dbf223c1aa9cd7e9afcc21ef3590d2df7ca

Contents?: true

Size: 1.46 KB

Versions: 4

Compression:

Stored size: 1.46 KB

Contents

Productions:
%len = grammar.all_productions.size.to_s.size
%productions = recognizer.states.map(&:rules).inject(:merge).
%  select(&:final?).map { |x| [x.to_s(false), x.production.block] }
%body = productions.map { |_| _[0].size }.max
%productions.each do |prod|
  {{= sprintf("%-#{body}s", prod[0]) }} %{prod[1]}
%end

%if unused_symbols.any?
Symbols unused in grammar:
%  unused_symbols.each do |sym|
  %{sym}
%  end
%end

Precedence:
  --- highest
% grammar.precedence.each do |pr|
  %{"%-8s" % pr.type} %{pr.level}:
    {{= "{" << pr.tokens.to_a.join(", ") << "}" }}
% end
  --- lowest

%states = grammar.states.to_a
%table.each_with_index do |v, i|
%  state = states[i]
  State %{i}:
%  state.rules.each do |rule|
    %{rule}
      {%{rule.lookahead.to_a.join(", ")}}
%  end
%  transitions = v.each.select { |_, a| a && a[0] == :state }
%  reductions  = v.each.select { |_, a| a && a[0] == :reduce}
%  accepting   = v.each.select { |_, a| a && a[0] == :accept}
%  thing = [:transitions, :reductions, :accepting]
%  num_type = {
%    transitions: "State",
%    reductions: "Rule",
%    accepting: "Rule"
%  }
%  h = Hash[thing.zip([transitions, reductions, accepting])]
%  h.each do |key, value|
%    next unless value.any?
    %{key}:
%    value.each do |token, (_, name)|
%       token_value = grammar.terminals.
%          find { |_| _.name == token } || token
      %{token_value}: %{num_type[key]} %{name}
%     end
%   end

%end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
antelope-0.3.2 lib/antelope/generator/templates/info.ant
antelope-0.3.0 lib/antelope/generator/templates/info.ant
antelope-0.2.4 lib/antelope/generator/templates/info.ant
antelope-0.2.3 lib/antelope/generator/templates/info.ant