Class: Code::Parser::Call
Instance Method Summary
collapse
Methods inherited from Language
<<, >>, absent, aka, #any, ignore, #inspect, maybe, parse, #parse, repeat, #str, then, #to_s, |
Instance Method Details
72
73
74
|
# File 'lib/code/parser/call.rb', line 72
def argument
keyword_argument | regular_argument
end
|
#arguments ⇒ Object
76
77
78
79
80
|
# File 'lib/code/parser/call.rb', line 76
def arguments
opening_parenthesis.ignore << whitespace? << argument.repeat(0, 1) <<
(comma << whitespace? << argument << whitespace?).repeat <<
whitespace? << closing_parenthesis.ignore.maybe
end
|
102
103
104
105
106
107
108
109
110
111
112
|
# File 'lib/code/parser/call.rb', line 102
def block
(
do_keyword << whitespace? << parameters.aka(:parameters).maybe <<
code.aka(:body) << end_keyword.maybe
) |
(
opening_curly_bracket << whitespace? <<
parameters.aka(:parameters).maybe << code.aka(:body) <<
closing_curly_bracket.maybe
)
end
|
#closing_curly_bracket ⇒ Object
44
45
46
|
# File 'lib/code/parser/call.rb', line 44
def closing_curly_bracket
str("}")
end
|
#closing_parenthesis ⇒ Object
52
53
54
|
# File 'lib/code/parser/call.rb', line 52
def closing_parenthesis
str(")")
end
|
16
17
18
|
# File 'lib/code/parser/call.rb', line 16
def code
::Code::Parser::Code
end
|
#code_present ⇒ Object
20
21
22
|
# File 'lib/code/parser/call.rb', line 20
def code_present
::Code::Parser::Code.new.present
end
|
24
25
26
|
# File 'lib/code/parser/call.rb', line 24
def colon
str(":")
end
|
28
29
30
|
# File 'lib/code/parser/call.rb', line 28
def comma
str(",")
end
|
#do_keyword ⇒ Object
56
57
58
|
# File 'lib/code/parser/call.rb', line 56
def do_keyword
str("do")
end
|
#end_keyword ⇒ Object
60
61
62
|
# File 'lib/code/parser/call.rb', line 60
def end_keyword
str("end")
end
|
36
37
38
|
# File 'lib/code/parser/call.rb', line 36
def equal
str("=")
end
|
#keyword_argument ⇒ Object
64
65
66
|
# File 'lib/code/parser/call.rb', line 64
def keyword_argument
name.aka(:name) << colon << code_present.aka(:value)
end
|
#keyword_parameter ⇒ Object
82
83
84
85
|
# File 'lib/code/parser/call.rb', line 82
def keyword_parameter
name.aka(:name) << whitespace? << colon.aka(:keyword) <<
code_present.aka(:default).maybe
end
|
4
5
6
|
# File 'lib/code/parser/call.rb', line 4
def name
::Code::Parser::Name
end
|
#opening_curly_bracket ⇒ Object
40
41
42
|
# File 'lib/code/parser/call.rb', line 40
def opening_curly_bracket
str("{")
end
|
#opening_parenthesis ⇒ Object
48
49
50
|
# File 'lib/code/parser/call.rb', line 48
def opening_parenthesis
str("(")
end
|
#parameter ⇒ Object
92
93
94
|
# File 'lib/code/parser/call.rb', line 92
def parameter
keyword_parameter | regular_parameter
end
|
#parameters ⇒ Object
96
97
98
99
100
|
# File 'lib/code/parser/call.rb', line 96
def parameters
pipe.ignore << whitespace? << parameter.repeat(0, 1) <<
(whitespace? << comma << whitespace? << parameter).repeat <<
whitespace? << pipe.ignore.maybe
end
|
32
33
34
|
# File 'lib/code/parser/call.rb', line 32
def pipe
str("|")
end
|
#regular_argument ⇒ Object
68
69
70
|
# File 'lib/code/parser/call.rb', line 68
def regular_argument
code_present.aka(:value)
end
|
#regular_parameter ⇒ Object
87
88
89
90
|
# File 'lib/code/parser/call.rb', line 87
def regular_parameter
name.aka(:name) << whitespace? <<
(equal << whitespace? << code_present.aka(:default)).maybe
end
|
114
115
116
117
118
119
|
# File 'lib/code/parser/call.rb', line 114
def root
(
name.aka(:name) << (whitespace? << arguments.aka(:arguments)).maybe <<
(whitespace? << block.aka(:block)).maybe
).aka(:call)
end
|
#whitespace ⇒ Object
8
9
10
|
# File 'lib/code/parser/call.rb', line 8
def whitespace
::Code::Parser::Whitespace
end
|
#whitespace? ⇒ Boolean
12
13
14
|
# File 'lib/code/parser/call.rb', line 12
def whitespace?
whitespace.maybe
end
|