Class: Language::Atom

Inherits:
Object
  • Object
show all
Defined in:
lib/language/atom.rb,
lib/language/atom/or.rb,
lib/language/atom/aka.rb,
lib/language/atom/and.rb,
lib/language/atom/any.rb,
lib/language/atom/str.rb,
lib/language/atom/then.rb,
lib/language/atom/maybe.rb,
lib/language/atom/absent.rb,
lib/language/atom/ignore.rb,
lib/language/atom/repeat.rb

Direct Known Subclasses

Absent, Aka, And, Any, Ignore, Maybe, Or, Repeat, Str, Then

Defined Under Namespace

Classes: Absent, Aka, And, Any, Ignore, Maybe, Or, Repeat, Str, Then

Instance Method Summary collapse

Instance Method Details

#<<(other) ⇒ Object



41
42
43
# File 'lib/language/atom.rb', line 41

def <<(other)
  And.new(left: self, right: other)
end

#>>(other) ⇒ Object



37
38
39
# File 'lib/language/atom.rb', line 37

def >>(other)
  And.new(left: self, right: other)
end

#absentObject



13
14
15
# File 'lib/language/atom.rb', line 13

def absent
  Absent.new(parent: self)
end

#aka(name) ⇒ Object



29
30
31
# File 'lib/language/atom.rb', line 29

def aka(name)
  Aka.new(parent: self, name:)
end

#anyObject



5
6
7
# File 'lib/language/atom.rb', line 5

def any
  Any.new
end

#ignoreObject



17
18
19
# File 'lib/language/atom.rb', line 17

def ignore
  Ignore.new(parent: self)
end

#inspectObject



57
58
59
# File 'lib/language/atom.rb', line 57

def inspect
  to_s
end

#maybeObject



21
22
23
# File 'lib/language/atom.rb', line 21

def maybe
  Maybe.new(parent: self)
end

#parse(_parser) ⇒ Object

Raises:

  • (NotImplementedError)


49
50
51
# File 'lib/language/atom.rb', line 49

def parse(_parser)
  raise NotImplementedError, "#{self.class}#parse"
end

#repeat(minimum = 0, maximum = nil) ⇒ Object



25
26
27
# File 'lib/language/atom.rb', line 25

def repeat(minimum = 0, maximum = nil)
  Repeat.new(parent: self, minimum:, maximum:)
end

#str(string) ⇒ Object



9
10
11
# File 'lib/language/atom.rb', line 9

def str(string)
  Str.new(string:)
end

#then(&block) ⇒ Object



45
46
47
# File 'lib/language/atom.rb', line 45

def then(&block)
  Then.new(parent: self, block:)
end

#to_sObject

Raises:

  • (NotImplementedError)


53
54
55
# File 'lib/language/atom.rb', line 53

def to_s
  raise NotImplementedError, "#{self.class}#parse"
end

#|(other) ⇒ Object



33
34
35
# File 'lib/language/atom.rb', line 33

def |(other)
  Or.new(left: self, right: other)
end