Class: Code::Parser::LeftOperation

Inherits:
Language
  • Object
show all
Defined in:
lib/code/parser/left_operation.rb

Instance Method Summary collapse

Instance Method Details

#operatorObject



18
19
20
# File 'lib/code/parser/left_operation.rb', line 18

def operator
  str("")
end

#right_statementObject



22
23
24
# File 'lib/code/parser/left_operation.rb', line 22

def right_statement
  Statement
end

#rootObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/code/parser/left_operation.rb', line 26

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

#statementObject



6
7
8
# File 'lib/code/parser/left_operation.rb', line 6

def statement
  Statement
end

#whitespaceObject



10
11
12
# File 'lib/code/parser/left_operation.rb', line 10

def whitespace
  Whitespace
end

#whitespace?Boolean

Returns:



14
15
16
# File 'lib/code/parser/left_operation.rb', line 14

def whitespace?
  whitespace.maybe
end