Sha256: fa91f719e96467ff3c01d6728d7af6387f476da1fc47fad6ad52ba1afb686d8d
Contents?: true
Size: 1.64 KB
Versions: 1
Compression:
Stored size: 1.64 KB
Contents
# encoding: utf-8 # frozen_string_literal: true require "carbon/compiler/parser/firsts" require "carbon/compiler/parser/helpers" require "carbon/compiler/parser/common" require "carbon/compiler/parser/root" require "carbon/compiler/parser/statements" require "carbon/compiler/parser/expressions" module Carbon module Compiler # The parser. This takes a series of tokens, generated by the {Scanner}, # and derives structure from these tokens. This makes the fundamental # bases of creating a concrete representation of what is in the file. class Parser include Parser::Helpers include Parser::Common include Parser::Root include Parser::Statements include Parser::Expressions # The scanner that acts as the source of the tokens. # # @return [Scanner] attr_reader :scanner # Initialize the parser. It takes a scanner, and the project that # the parser is a part of. # # @param scanner [Scanner] # @param project [Project] def initialize(scanner) @scanner = scanner @file = @scanner.file @enum = @scanner.each end # Pretty inspect. # # @return [String] def inspect "#<#{self.class} #{@scanner.file.name}>" end # Parses the input. This is cached to prevent multiple runs. # # @return [Parser::Node] def parse @_root ||= parse_root end alias_method :root, :parse # Destroys the cache for {#parse}, allowing the parsing to occur again. # # @return [void] def clear! @enum.reset @_root = nil 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.rb |