Class: Code::Parser::IfModifier
Instance Method Summary
collapse
Methods inherited from Language
<<, >>, absent, aka, #any, ignore, #inspect, maybe, parse, #parse, repeat, #str, then, #to_s, |
Instance Method Details
#if_keyword ⇒ Object
20
21
22
|
# File 'lib/code/parser/if_modifier.rb', line 20
def if_keyword
str("if")
end
|
#if_modifier ⇒ Object
8
9
10
|
# File 'lib/code/parser/if_modifier.rb', line 8
def if_modifier
::Code::Parser::IfModifier
end
|
36
37
38
|
# File 'lib/code/parser/if_modifier.rb', line 36
def operator
if_keyword | unless_keyword | while_keyword | until_keyword
end
|
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/code/parser/if_modifier.rb', line 40
def root
(
statement.aka(:left) <<
(
whitespace? << operator.aka(:operator) << whitespace? <<
if_modifier.aka(:right)
).maybe
)
.aka(:if_modifier)
.then do |output|
output[:if_modifier][:right] ? output : output[:if_modifier][:left]
end
end
|
#statement ⇒ Object
4
5
6
|
# File 'lib/code/parser/if_modifier.rb', line 4
def statement
::Code::Parser::OrKeyword
end
|
#unless_keyword ⇒ Object
24
25
26
|
# File 'lib/code/parser/if_modifier.rb', line 24
def unless_keyword
str("unless")
end
|
#until_keyword ⇒ Object
32
33
34
|
# File 'lib/code/parser/if_modifier.rb', line 32
def until_keyword
str("until")
end
|
#while_keyword ⇒ Object
28
29
30
|
# File 'lib/code/parser/if_modifier.rb', line 28
def while_keyword
str("while")
end
|
#whitespace ⇒ Object
12
13
14
|
# File 'lib/code/parser/if_modifier.rb', line 12
def whitespace
::Code::Parser::Whitespace.new.without_newline
end
|
#whitespace? ⇒ Boolean
16
17
18
|
# File 'lib/code/parser/if_modifier.rb', line 16
def whitespace?
whitespace.maybe
end
|