Module: Rattler::Parsers::Combining

Included in:
Choice, Label, ListParser, Predicate, Repeat, Sequencing, Skip
Defined in:
lib/rattler/parsers/combining.rb

Overview

Combining describes a parser that is a combination of other parsers.

Instance Method Summary collapse

Instance Method Details

#capturing?Boolean

Returns true if the parser returns parse results on success, or false if the parser simply returns true on success.

Returns:

  • (Boolean)

    true if the parser returns parse results on success, or false if the parser simply returns true on success



7
8
9
# File 'lib/rattler/parsers/combining.rb', line 7

def capturing?
  @capturing ||= any? {|child| child.capturing? }
end

#capturing_decidable?Boolean

true if it can be determined statically whether the parser returns parse results on success

Returns:

  • (Boolean)

    true if it can be determined statically whether the parser returns parse results on success



12
13
14
# File 'lib/rattler/parsers/combining.rb', line 12

def capturing_decidable?
  @capturing_decidable ||= all? {|child| child.capturing_decidable? }
end

#semantic?Boolean

Returns true if the parser is a semantic action.

Returns:

  • (Boolean)

    true if the parser is a semantic action



17
18
19
# File 'lib/rattler/parsers/combining.rb', line 17

def semantic?
  @semantic = any? {|child| child.semantic? }
end

#with_ws(ws) ⇒ Parser

Returns a new parser that uses ws to skip whitespace.

Parameters:

  • ws (Parser)

    the parser used to skip whitespace

Returns:

  • (Parser)

    a new parser that uses ws to skip whitespace



22
23
24
# File 'lib/rattler/parsers/combining.rb', line 22

def with_ws(ws)
  self.class.new(children.map {|_| _.with_ws(ws) }, attrs)
end