Class: Parser::CommentParser

Inherits:
StringScanner show all
Defined in:
lib/parser/comment_parser.rb

Overview

Creates an instance of Comment, then parses the content and adds the contained doc- and tokenlines to it.

See Also:

Instance Method Summary collapse

Methods inherited from StringScanner

#intelligent_skip_until, #save_scanned, #scan_until_ahead, #scan_until_or_end, #skip_escaping_until

Constructor Details

#initialize(input) ⇒ CommentParser

Returns a new instance of CommentParser.



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

def initialize(input)
  super(input)
  @comment = Comment.new(input)
end

Instance Method Details

#parseParser::Comment

All lines, that start with a ‘@-symbol` will be processed as tokenline. If the next line after a token starts with two spaces, it will be interpreted as continuation of the preceding token.

All other lines are interpreted as doclines

Examples:

multiline token

@multiline_token this is a multi_line token, it won't
  stop if i intend the next line with two spaces, like "  "

Returns:

  • (Parser::Comment)

    Attaches all found doc- and tokenlines to the instance of comment



27
28
29
30
31
32
33
34
35
36
# File 'lib/parser/comment_parser.rb', line 27

def parse
  # we don't want the linebreak of the comment start in our first docline
  # i.e. ignore '/**\n' 
  self.skip LINE_END
  
  while not eos? do
    parse_comment_line
  end
  return @comment
end