Sha256: cd46417c26b83ebbf8a79f264b449cadae69b4164099b40b232f970d74c921ab
Contents?: true
Size: 920 Bytes
Versions: 5
Compression:
Stored size: 920 Bytes
Contents
module Antelope module Generator class CSource < CHeader def action_for(state) out = "" grammar.terminals.each do |terminal| action = state[terminal.name] if action.size == 2 && action[0] == :state out << "#{action[1] + 1}, " elsif action.size == 2 && [:reduce, :accept].include?(action[0]) if $DEBUG out << "#{prefix.upcase}STATES + #{action[1] + 1}, " else out << "#{table.size + action[1] + 1}, " end else out << "0, " end end out.chomp(", ") end def cify_block(block) block.gsub(/\$([0-9]+)/, "#{prefix}vals[\\1]") .gsub(/\$\$/, "#{prefix}out") end def generate template "c_source", "#{file}.c" end end end end
Version data entries
5 entries across 5 versions & 1 rubygems