Class: Code::Parser::ChainedCall

Inherits:
Operation show all
Defined in:
lib/code/parser/chained_call.rb

Instance Method Summary collapse

Methods inherited from Language

<<, >>, absent, aka, #any, ignore, #inspect, maybe, parse, #parse, repeat, #str, then, #to_s, |

Instance Method Details

#colonObject



20
21
22
# File 'lib/code/parser/chained_call.rb', line 20

def colon
  str(":")
end

#dotObject



16
17
18
# File 'lib/code/parser/chained_call.rb', line 16

def dot
  str(".")
end

#operatorObject



24
25
26
# File 'lib/code/parser/chained_call.rb', line 24

def operator
  dot | (colon << colon)
end

#rootObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/code/parser/chained_call.rb', line 28

def root
  (
    statement.aka(:first) <<
      (whitespace? << operator << whitespace? << statement)
        .repeat(1)
        .aka(:others)
        .maybe
  )
    .aka(:chained_call)
    .then do |output|
      if output[:chained_call][:others]
        output
      else
        output[:chained_call][:first]
      end
    end
end

#statementObject



4
5
6
# File 'lib/code/parser/chained_call.rb', line 4

def statement
  ::Code::Parser::Dictionnary
end

#whitespaceObject



8
9
10
# File 'lib/code/parser/chained_call.rb', line 8

def whitespace
  ::Code::Parser::Whitespace
end

#whitespace?Boolean

Returns:



12
13
14
# File 'lib/code/parser/chained_call.rb', line 12

def whitespace?
  whitespace.maybe
end