Class: Language::Atom::Aka
- Inherits:
-
Language::Atom
- Object
- Language::Atom
- Language::Atom::Aka
- Defined in:
- lib/language/atom/aka.rb
Instance Method Summary collapse
-
#initialize(name:, parent:) ⇒ Aka
constructor
A new instance of Aka.
- #parse(parser) ⇒ Object
- #to_s ⇒ Object
Methods inherited from Language::Atom
#<<, #>>, #absent, #aka, #any, #ignore, #inspect, #maybe, #repeat, #str, #then, #|
Constructor Details
#initialize(name:, parent:) ⇒ Aka
Returns a new instance of Aka.
6 7 8 9 |
# File 'lib/language/atom/aka.rb', line 6 def initialize(name:, parent:) @name = name @parent = parent end |
Instance Method Details
#parse(parser) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/language/atom/aka.rb', line 11 def parse(parser) clone = Parser.new(root: self, input: parser.input, cursor: parser.cursor) @parent.parse(clone) if clone.output? parser.output = Output.new(@name => clone.output) else parser.output[@name] = Output.new(clone.buffer) parser.buffer = "" end parser.cursor = clone.cursor end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/language/atom/aka.rb', line 27 def to_s @parent ? "#{@parent}.aka(#{@name.inspect})" : "aka(#{@name.inspect})" end |