Sha256: 34556a44f7e69232919faf72935ba410d25fe63c1be75ed8251e76fdae68bcfb

Contents?: true

Size: 634 Bytes

Versions: 15

Compression:

Stored size: 634 Bytes

Contents

# frozen_string_literal: true

class Language
  class Atom
    class Maybe < Atom
      def initialize(parent:)
        @parent = parent
      end

      def parse(parser)
        clone =
          Parser.new(
            root: self,
            input: parser.input,
            cursor: parser.cursor,
            buffer: parser.buffer
          )

        @parent.parse(clone)
      rescue Parser::Interuption
      else
        parser.buffer = clone.buffer
        parser.cursor = clone.cursor
        parser.output = clone.output
      end

      def to_s
        @parent ? "#{@parent}.maybe" : "maybe"
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
language-ruby-1.1.2 lib/language/atom/maybe.rb
language-ruby-1.1.0 lib/language/atom/maybe.rb
language-ruby-1.0.1 lib/language/atom/maybe.rb
language-ruby-1.0.0 lib/language/atom/maybe.rb
language-ruby-0.9.3 lib/language/atom/maybe.rb
language-ruby-0.9.2 lib/language/atom/maybe.rb
language-ruby-0.9.0 lib/language/atom/maybe.rb
language-ruby-0.8.4 lib/language/atom/maybe.rb
language-ruby-0.8.3 lib/language/atom/maybe.rb
language-ruby-0.8.2 lib/language/atom/maybe.rb
language-ruby-0.8.1 lib/language/atom/maybe.rb
language-ruby-0.8.0 lib/language/atom/maybe.rb
language-ruby-0.7.0 lib/language/atom/maybe.rb
language-ruby-0.6.2 lib/language/atom/maybe.rb
language-ruby-0.6.1 lib/language/atom/maybe.rb