Module: Carbon::Compiler::Parser::Firsts::ClassMethods
- Defined in:
- lib/carbon/compiler/parser/firsts.rb
Overview
The class methods that should be placed on the parser.
Instance Method Summary collapse
- #first(name, tokens = nil) ⇒ Object
-
#firsts ⇒ {Symbol => Set<Symbol>}
The first sets.
Instance Method Details
#first(name) ⇒ Set<::Symbol> #first(name, tokens) ⇒ void
40 41 42 43 44 45 46 |
# File 'lib/carbon/compiler/parser/firsts.rb', line 40 def first(name, tokens = nil) if tokens firsts[name].merge(tokens) else firsts.fetch(name) end end |
#firsts ⇒ {Symbol => Set<Symbol>}
The first sets. The key is the name of a node, and the value is a set of all tokens that can be at the start of that node.
17 18 19 |
# File 'lib/carbon/compiler/parser/firsts.rb', line 17 def firsts @firsts ||= Hash.new { |h, k| h[k] = Set.new } end |