Class: Rattler::Parsers::Parser

Inherits:
Util::Node show all
Includes:
Runtime::ParserHelper
Defined in:
lib/rattler/parsers/parser.rb

Overview

Parser is the base class for all of Rattler’s combinator parser types.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Runtime::ParserHelper

#select_captures

Methods inherited from Util::Node

#==, [], #[], #attrs, #can_equal?, #child, #children, #each, #empty?, #eql?, #initialize, #inspect, #method_missing, #name, #pretty_print, #pretty_print_cycle, #respond_to?, #same_contents?, #to_graphviz, #with_attrs, #with_attrs!, #with_children

Constructor Details

This class inherits a constructor from Rattler::Util::Node

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Rattler::Util::Node

Class Method Details

.parsed(*args) ⇒ Object



11
12
13
# File 'lib/rattler/parsers/parser.rb', line 11

def self.parsed(*args) #:nodoc:

  self[*args]
end

Instance Method Details

#&(other) ⇒ Sequence



62
63
64
# File 'lib/rattler/parsers/parser.rb', line 62

def &(other)
  Sequence[self, other]
end

#>>(semantic) ⇒ AttributedSequence



69
70
71
# File 'lib/rattler/parsers/parser.rb', line 69

def >>(semantic)
  AttributedSequence[self, semantic]
end

#capturing?Boolean



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

def capturing?
  true
end

#capturing_decidable?Boolean



29
30
31
# File 'lib/rattler/parsers/parser.rb', line 29

def capturing_decidable?
  true
end

#labeled?Boolean

true if the parser associates a label with parse results. Only instances of Label should return true.



38
39
40
# File 'lib/rattler/parsers/parser.rb', line 38

def labeled?
  false
end

#list(sep_parser, lower_bound, upper_bound) ⇒ Repeat



103
104
105
# File 'lib/rattler/parsers/parser.rb', line 103

def list(sep_parser, lower_bound, upper_bound)
  ListParser[self, sep_parser, lower_bound, upper_bound]
end

#one_or_moreRepeat



95
96
97
# File 'lib/rattler/parsers/parser.rb', line 95

def one_or_more
  repeat(1, nil)
end

#optionalRepeat



82
83
84
# File 'lib/rattler/parsers/parser.rb', line 82

def optional
  repeat(0, 1)
end

#repeat(lower_bound, upper_bound) ⇒ Repeat



76
77
78
# File 'lib/rattler/parsers/parser.rb', line 76

def repeat(lower_bound, upper_bound)
  Repeat[self, lower_bound, upper_bound]
end

#semantic?Boolean



48
49
50
# File 'lib/rattler/parsers/parser.rb', line 48

def semantic?
  false
end

#sequence?Boolean



43
44
45
# File 'lib/rattler/parsers/parser.rb', line 43

def sequence?
  false
end

#skipSkip



108
109
110
# File 'lib/rattler/parsers/parser.rb', line 108

def skip
  Skip[self]
end

#variable_capture_count?Boolean



23
24
25
# File 'lib/rattler/parsers/parser.rb', line 23

def variable_capture_count?
  false
end

#with_ws(ws) ⇒ Parser



114
115
116
# File 'lib/rattler/parsers/parser.rb', line 114

def with_ws(ws)
  self
end

#zero_or_moreRepeat



88
89
90
# File 'lib/rattler/parsers/parser.rb', line 88

def zero_or_more
  repeat(0, nil)
end

#|(other) ⇒ Choice



55
56
57
# File 'lib/rattler/parsers/parser.rb', line 55

def |(other)
  Choice[self, other]
end