Sha256: c622da452bb2a3eabfd133c48c267eff685273fbc4456cb81acc26f990cd16bf
Contents?: true
Size: 1.47 KB
Versions: 1
Compression:
Stored size: 1.47 KB
Contents
# encoding: utf-8 # frozen_string_literal: true # rubocop:disable Metrics/CyclomaticComplexity require "carbon/compiler/parser/root/class" require "carbon/compiler/parser/root/directive" require "carbon/compiler/parser/root/enum" require "carbon/compiler/parser/root/function" require "carbon/compiler/parser/root/struct" require "carbon/compiler/parser/root/trait" module Carbon module Compiler class Parser # Parses root definitions, like functions and enums. module Root include Class include Directive include Enum include Function include Struct include Trait protected Parser.first(:root, [:":", :module, :struct, :class, :trait, :enum, :def]) def parse_root children = [] until peek? :EOF children << case peek.type when :":" then parse_directive when :module then parse_module when :struct then parse_struct when :class then parse_class when :trait then parse_trait when :enum then parse_enum when :def then parse_function else error first(:root) end end Node::Root.new(children) end def parse_module expect :module name = parse_module_name expect :"." Node::Definition::Module.new([name]) 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.rb |