Sha256: d223a2e5c5849c29ec8c9401d13eb07314e7cab8855f27dbb79ed3ef3eb449e7
Contents?: true
Size: 1.12 KB
Versions: 2
Compression:
Stored size: 1.12 KB
Contents
require "forwardable" require "lrama/grammar/code/initial_action_code" require "lrama/grammar/code/no_reference_code" require "lrama/grammar/code/printer_code" require "lrama/grammar/code/rule_action" module Lrama class Grammar class Code extend Forwardable def_delegators "token_code", :s_value, :line, :column, :references attr_reader :type, :token_code def initialize(type:, token_code:) @type = type @token_code = token_code end def ==(other) self.class == other.class && self.type == other.type && self.token_code == other.token_code end # $$, $n, @$, @n are translated to C code def translated_code t_code = s_value.dup references.reverse_each do |ref| first_column = ref.first_column last_column = ref.last_column str = reference_to_c(ref) t_code[first_column...last_column] = str end return t_code end private def reference_to_c(ref) raise NotImplementedError.new("#reference_to_c is not implemented") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lrama-0.6.3 | lib/lrama/grammar/code.rb |
lrama-0.6.2 | lib/lrama/grammar/code.rb |