Class: Code::Parser::Whitespace

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

Instance Method Summary collapse

Instance Method Details

#asteriskObject



22
23
24
# File 'lib/code/parser/whitespace.rb', line 22

def asterisk
  str("*")
end

#double_slash_commentObject



30
31
32
# File 'lib/code/parser/whitespace.rb', line 30

def double_slash_comment
  slash << slash << (newline.absent << any).repeat << newline.maybe
end

#hash_commentObject



26
27
28
# File 'lib/code/parser/whitespace.rb', line 26

def hash_comment
  hashtag << (newline.absent << any).repeat << newline.maybe
end

#hashtagObject



14
15
16
# File 'lib/code/parser/whitespace.rb', line 14

def hashtag
  str("#")
end

#multi_line_commentObject



34
35
36
37
# File 'lib/code/parser/whitespace.rb', line 34

def multi_line_comment
  slash << asterisk << ((asterisk << slash).absent << any).repeat <<
    asterisk.maybe << slash.maybe
end

#newlineObject



10
11
12
# File 'lib/code/parser/whitespace.rb', line 10

def newline
  str("\n")
end

#rootObject



43
44
45
46
47
48
# File 'lib/code/parser/whitespace.rb', line 43

def root
  (
    space | newline | hash_comment | double_slash_comment |
      multi_line_comment
  ).repeat(1)
end

#slashObject



18
19
20
# File 'lib/code/parser/whitespace.rb', line 18

def slash
  str("/")
end

#spaceObject



6
7
8
# File 'lib/code/parser/whitespace.rb', line 6

def space
  str(" ")
end

#without_newlineObject



39
40
41
# File 'lib/code/parser/whitespace.rb', line 39

def without_newline
  (space | multi_line_comment).repeat(1)
end