blob: 2b2dea74abe951369a321e580c8667b98e3d9c7f (
plain)
1
2
3
4
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
37
38
39
40
41
42
43
44
45
46
47
48
49
|
module YARD::MRuby::Parser::C
class HeaderParser < Parser
# Consumes a directive and generates a DirectiveStatement
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
def consume_body_statements
@in_body_statements = true
result = super
@in_body_statements = false
result
end
end
#
# Register all header files (.h) to be processed with the above HeaderParser
YARD::Parser::SourceParser.register_parser_type :header, HeaderParser, 'h'
end
|