Class: Code::Parser::Class
Instance Method Summary
collapse
Methods inherited from Language
<<, >>, absent, aka, #any, ignore, #inspect, maybe, parse, #parse, repeat, #str, then, #to_s, |
Instance Method Details
#class_keyword ⇒ Object
24
25
26
|
# File 'lib/code/parser/class.rb', line 24
def class_keyword
str("class")
end
|
12
13
14
|
# File 'lib/code/parser/class.rb', line 12
def code
::Code::Parser::Code
end
|
#end_keyword ⇒ Object
28
29
30
|
# File 'lib/code/parser/class.rb', line 28
def end_keyword
str("end")
end
|
32
33
34
|
# File 'lib/code/parser/class.rb', line 32
def lesser
str("<")
end
|
8
9
10
|
# File 'lib/code/parser/class.rb', line 8
def name
::Code::Parser::Name
end
|
36
37
38
39
40
41
42
|
# File 'lib/code/parser/class.rb', line 36
def root
(
class_keyword << whitespace? << name.aka(:name) <<
(whitespace? << lesser << name.aka(:superclass)).maybe <<
code.aka(:body) << end_keyword.maybe
).aka(:class) | statement
end
|
#statement ⇒ Object
4
5
6
|
# File 'lib/code/parser/class.rb', line 4
def statement
::Code::Parser::While
end
|
#whitespace ⇒ Object
16
17
18
|
# File 'lib/code/parser/class.rb', line 16
def whitespace
::Code::Parser::Whitespace
end
|
#whitespace? ⇒ Boolean
20
21
22
|
# File 'lib/code/parser/class.rb', line 20
def whitespace?
whitespace.maybe
end
|