Sha256: 88aace75967cc6fdd7a896265e898cccd3d689db30714c0a79bc44b1100a55f1

Contents?: true

Size: 1013 Bytes

Versions: 7

Compression:

Stored size: 1013 Bytes

Contents

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

7 entries across 7 versions & 1 rubygems

Version Path
lrama-0.6.9 lib/lrama/grammar/code/initial_action_code.rb
lrama-0.6.8 lib/lrama/grammar/code/initial_action_code.rb
lrama-0.6.7 lib/lrama/grammar/code/initial_action_code.rb
lrama-0.6.6 lib/lrama/grammar/code/initial_action_code.rb
lrama-0.6.5 lib/lrama/grammar/code/initial_action_code.rb
lrama-0.6.4 lib/lrama/grammar/code/initial_action_code.rb
lrama-0.6.3 lib/lrama/grammar/code/initial_action_code.rb