Class: Code::Parser::UnaryMinus

Inherits:
Language
  • Object
show all
Defined in:
lib/code/parser/unary_minus.rb

Instance Method Summary collapse

Methods inherited from Language

<<, >>, absent, aka, #any, ignore, #inspect, maybe, parse, #parse, repeat, #str, then, #to_s, |

Instance Method Details

#minusObject



16
17
18
# File 'lib/code/parser/unary_minus.rb', line 16

def minus
  str("-")
end

#operatorObject



20
21
22
# File 'lib/code/parser/unary_minus.rb', line 20

def operator
  minus
end

#rootObject



24
25
26
27
28
# File 'lib/code/parser/unary_minus.rb', line 24

def root
  (operator.aka(:operator) << whitespace? << unary_minus.aka(:right)).aka(
    :unary_minus
  ) | ::Code::Parser::Power
end

#unary_minusObject



4
5
6
# File 'lib/code/parser/unary_minus.rb', line 4

def unary_minus
  ::Code::Parser::UnaryMinus
end

#whitespaceObject



8
9
10
# File 'lib/code/parser/unary_minus.rb', line 8

def whitespace
  ::Code::Parser::Whitespace
end

#whitespace?Boolean

Returns:



12
13
14
# File 'lib/code/parser/unary_minus.rb', line 12

def whitespace?
  whitespace.maybe
end