Class: Code::Parser::Code

Inherits:
Language show all
Defined in:
lib/code/parser/code.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

#presentObject



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

def present
  (whitespace? << statement << whitespace?).repeat(1)
end

#rootObject



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

def root
  present | whitespace?.then { [] }
end

#statementObject



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

def statement
  ::Code::Parser::Statement
end

#whitespaceObject



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

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

#whitespace?(&block) ⇒ Boolean

Returns:



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

def whitespace?(&block)
  whitespace.maybe(&block)
end