Class: Code::Parser::If

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

Instance Method Summary collapse

Instance Method Details

#codeObject



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

def code
  Code
end

#else_keywordObject



38
39
40
# File 'lib/code/parser/if.rb', line 38

def else_keyword
  str("else")
end

#elsif_keywordObject



34
35
36
# File 'lib/code/parser/if.rb', line 34

def elsif_keyword
  str("elsif")
end

#end_keywordObject



42
43
44
# File 'lib/code/parser/if.rb', line 42

def end_keyword
  str("end")
end

#if_classObject



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

def if_class
  If
end

#if_keywordObject



26
27
28
# File 'lib/code/parser/if.rb', line 26

def if_keyword
  str("if")
end

#rootObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/code/parser/if.rb', line 46

def root
  (
    (if_keyword | unless_keyword).aka(:first_operator) << whitespace <<
      statement.aka(:first_statement) << code.aka(:first_body) <<
      (
        (
          elsif_keyword.aka(:operator) << whitespace <<
            statement.aka(:statement) << code.aka(:body)
        ) |
          (
            else_keyword << whitespace <<
              (if_keyword | unless_keyword).aka(:operator) <<
              whitespace << statement.aka(:statement) << code.aka(:body)
          ) | (else_keyword.aka(:operator) << code.aka(:body))
      ).repeat(1).aka(:elses).maybe << end_keyword.maybe
  ).aka(:if) | statement
end

#statementObject



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

def statement
  IfModifier
end

#unless_keywordObject



30
31
32
# File 'lib/code/parser/if.rb', line 30

def unless_keyword
  str("unless")
end

#whitespaceObject



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

def whitespace
  Whitespace
end

#whitespace?Boolean

Returns:



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

def whitespace?
  whitespace.maybe
end