Sha256: 2dcf6bd618c72ca02a81282faff4dbb3383dcc71739994a86269b91e90d9b0e8

Contents?: true

Size: 844 Bytes

Versions: 1

Compression:

Stored size: 844 Bytes

Contents

# encoding: utf-8
# frozen_string_literal: true

require "carbon/compiler/parser/expressions/precedence"
require "carbon/compiler/parser/expressions/primary"

module Carbon
  module Compiler
    class Parser
      # Parses expressions.
      module Expressions
        include Precedence
        include Primary

      protected

        PRECEDENCE = {
          "=": 1,
          "||": 2,
          "&&": 3,
          "|": 4,
          "^": 5,
          "&": 6,
          "===": 7, "==": 7, "!=": 7,
          "<": 8, ">": 8, "<=": 8, ">=": 8,
          "<<": 9, ">>": 9,
          "+": 10, "-": 10,
          "*": 11, "/": 11, "%": 11,
          ".": 12, "[": 12
        }.freeze
        RIGHT = [:"=", :"."].freeze

        def parse_expression
          parse_precedence(parse_expression_primary, 0)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
carbon-compiler-0.2.0 lib/carbon/compiler/parser/expressions.rb