Sha256: d0446a8b29d327e2bd2162257b9401c0b439c87c7f0984c8cc64c183de92e271

Contents?: true

Size: 737 Bytes

Versions: 1

Compression:

Stored size: 737 Bytes

Contents

# encoding: utf-8
# frozen_string_literal: true

module Carbon
  module Compiler
    class Parser
      module Root
        # Parses a class.
        module Class
        protected

          def parse_class
            start = expect :class
            expect :do
            elements = []
            elements << parse_class_element until peek?(:end)
            stop = expect :end

            Node::Definition::Class.new(elements, components: [start, stop])
          end

          def parse_class_element
            name = parse_name
            expect :":"
            type = parse_type
            expect :";"

            Node::Definition::Class::Element.new([name, type])
          end
        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/root/class.rb