Class: YARD::MRuby::Parser::C::HeaderParser

Inherits:
Parser
  • Object
show all
Defined in:
lib/yard/mruby/parser/c/header_parser.rb

Instance Method Summary collapse

Instance Method Details

#consume_body_statementsObject



38
39
40
41
42
43
# File 'lib/yard/mruby/parser/c/header_parser.rb', line 38

def consume_body_statements
  @in_body_statements = true
  result = super
  @in_body_statements = false
  result
end

#consume_directiveObject

Consumes a directive and generates a DirectiveStatement



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/yard/mruby/parser/c/header_parser.rb', line 5

def consume_directive
  super if @in_body_statements

  @newline = false
  start = @index
  line = @line
  statement = DirectiveStatement.new(nil, @file, line)
  @statements << statement
  attach_comment(statement)

  multiline = false
  advance_loop do
    chr = char
    case chr
    when '\\'; multiline=true; advance
    when /\s/; consume_whitespace
    else advance
    end

    if @newline
      if multiline
        multiline = false
      else
        break
      end
    end
  end

  decl = @content[start...@index]

  statement.declaration = decl
end