Class: Code::Parser::Power
Instance Method Summary
collapse
Methods inherited from Language
<<, >>, absent, aka, #any, ignore, #inspect, maybe, parse, #parse, repeat, #str, then, #to_s, |
Instance Method Details
20
21
22
|
# File 'lib/code/parser/power.rb', line 20
def asterisk
str("*")
end
|
24
25
26
|
# File 'lib/code/parser/power.rb', line 24
def operator
asterisk << asterisk
end
|
4
5
6
|
# File 'lib/code/parser/power.rb', line 4
def power
::Code::Parser::Power
end
|
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/code/parser/power.rb', line 28
def root
(
statement.aka(:left) <<
(
whitespace? << operator.aka(:operator) << whitespace? <<
power.aka(:right)
).maybe
)
.aka(:power)
.then do |output|
output[:power][:right] ? output : output[:power][:left]
end
end
|
#statement ⇒ Object
8
9
10
|
# File 'lib/code/parser/power.rb', line 8
def statement
::Code::Parser::Negation
end
|
#whitespace ⇒ Object
12
13
14
|
# File 'lib/code/parser/power.rb', line 12
def whitespace
::Code::Parser::Whitespace
end
|
#whitespace? ⇒ Boolean
16
17
18
|
# File 'lib/code/parser/power.rb', line 16
def whitespace?
whitespace.maybe
end
|