Class: Code::Parser::If
Instance Method Summary
collapse
Methods inherited from Language
<<, >>, absent, aka, #any, ignore, #inspect, maybe, parse, #parse, repeat, #str, then, #to_s, |
Instance Method Details
16
17
18
|
# File 'lib/code/parser/if.rb', line 16
def code
::Code::Parser::Code
end
|
#else_keyword ⇒ Object
36
37
38
|
# File 'lib/code/parser/if.rb', line 36
def else_keyword
str("else")
end
|
#elsif_keyword ⇒ Object
32
33
34
|
# File 'lib/code/parser/if.rb', line 32
def elsif_keyword
str("elsif")
end
|
#end_keyword ⇒ Object
40
41
42
|
# File 'lib/code/parser/if.rb', line 40
def end_keyword
str("end")
end
|
8
9
10
|
# File 'lib/code/parser/if.rb', line 8
def if_class
::Code::Parser::If
end
|
#if_keyword ⇒ Object
24
25
26
|
# File 'lib/code/parser/if.rb', line 24
def if_keyword
str("if")
end
|
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/code/parser/if.rb', line 44
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
|
#statement ⇒ Object
4
5
6
|
# File 'lib/code/parser/if.rb', line 4
def statement
::Code::Parser::IfModifier
end
|
#unless_keyword ⇒ Object
28
29
30
|
# File 'lib/code/parser/if.rb', line 28
def unless_keyword
str("unless")
end
|
#whitespace ⇒ Object
12
13
14
|
# File 'lib/code/parser/if.rb', line 12
def whitespace
::Code::Parser::Whitespace
end
|
#whitespace? ⇒ Boolean
20
21
22
|
# File 'lib/code/parser/if.rb', line 20
def whitespace?
whitespace.maybe
end
|