Sha256: 6ce24deabf258fe5fe95a11255ac719c33962cdbeef3c94f71fea890b3528966

Contents?: true

Size: 726 Bytes

Versions: 6

Compression:

Stored size: 726 Bytes

Contents

module Lrama
  class Grammar
    class Code
      class InitialActionCode < Code
        private

        # * ($$) yylval
        # * (@$) yylloc
        # * ($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 == :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."
          else
            raise "Unexpected. #{self}, #{ref}"
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lrama-0.6.2 lib/lrama/grammar/code/initial_action_code.rb
lrama-0.6.1 lib/lrama/grammar/code/initial_action_code.rb
lrama-0.6.0 lib/lrama/grammar/code/initial_action_code.rb
lrama-0.5.12 lib/lrama/grammar/code/initial_action_code.rb
lrama-0.5.11 lib/lrama/grammar/code/initial_action_code.rb
lrama-0.5.10 lib/lrama/grammar/code/initial_action_code.rb