Sha256: b91f9eacd3b3a3494b15e272afa5c7dee38d125d8bd32a7ee688e14ec7367172

Contents?: true

Size: 1.37 KB

Versions: 4

Compression:

Stored size: 1.37 KB

Contents

Productions:
% grammar.productions.each do |k, v|
%  v.each do |prod|
  <%= k %> → <%= prod[:items].join(" ") %> <%= prod[:block] %>
%  end
% end

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

% len = tableizer.table.flatten.map(&:keys).flatten.map(&:size).max
% states = grammar.states.to_a
% tableizer.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[0] == :state      }
%   reductions  = v.each.select { |_, a| a[0] == :reduce     }
%   accepting   = v.each.select { |_, a| a[0] == :accept     }
%   conflicts   = v.each.select { |_, (a, b)| a.is_a?(Array) }
%   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 %>: <%= num_type[key] %> <%= name %>
%     end
%   end
%   if conflicts.any?
    conflicts:
%     conflicts.each do |token, (first, second)|
      <%= token %>: <%= first.join(" ") %>/<%= second.join(" ") %>
%     end
%   end

% end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
antelope-0.1.5 lib/antelope/generator/templates/output.erb
antelope-0.1.4 lib/antelope/generator/templates/output.erb
antelope-0.1.3 lib/antelope/generator/templates/output.erb
antelope-0.1.2 lib/antelope/generator/templates/output.erb