Sha256: 88d9a563653cb1a7fbab559ca167fe67977525e359e3bd3334f6663df4823b11

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module Lrama
  class Grammar
    class Code
      class InitialActionCode < Code
        private

        # * ($$) yylval
        # * (@$) yylloc
        # * ($:$) error
        # * ($1) error
        # * (@1) error
        # * ($:1) error
        def reference_to_c(ref)
          case
          when ref.type == :dollar && ref.name == "$" # $$
            "yylval"
          when ref.type == :at && ref.name == "$" # @$
            "yylloc"
          when ref.type == :index && ref.name == "$" # $:$
            raise "$:#{ref.value} can not be used in initial_action."
          when ref.type == :dollar # $n
            raise "$#{ref.value} can not be used in initial_action."
          when ref.type == :at # @n
            raise "@#{ref.value} can not be used in initial_action."
          when ref.type == :index # $:n
            raise "$:#{ref.value} can not be used in initial_action."
          else
            raise "Unexpected. #{self}, #{ref}"
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lrama-0.7.0 lib/lrama/grammar/code/initial_action_code.rb
lrama-0.6.11 lib/lrama/grammar/code/initial_action_code.rb
lrama-0.6.10 lib/lrama/grammar/code/initial_action_code.rb