Class: Code::Parser::Operation
Direct Known Subclasses
Addition, AndOperator, BitwiseAnd, BitwiseOr, ChainedCall, Equality, Greater, Multiplication, OrKeyword, OrOperator, Range, Shift
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/operation.rb', line 16
def operator
raise NotImplementedError
end
|
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/code/parser/operation.rb', line 20
def root
(
statement.aka(:first) <<
(
whitespace? << operator.aka(:operator) << whitespace? <<
statement.aka(:statement)
).repeat(1).aka(:others).maybe
)
.aka(:operation)
.then do |output|
output[:operation][:others] ? output : output[:operation][:first]
end
end
|
#statement ⇒ Object
4
5
6
|
# File 'lib/code/parser/operation.rb', line 4
def statement
raise NotImplementedError
end
|
#whitespace ⇒ Object
8
9
10
|
# File 'lib/code/parser/operation.rb', line 8
def whitespace
::Code::Parser::Whitespace
end
|
#whitespace? ⇒ Boolean
12
13
14
|
# File 'lib/code/parser/operation.rb', line 12
def whitespace?
whitespace.maybe
end
|