Skip to content

Commit 7bb63be

Browse files
committed
Restore CParser hack.
1 parent dd550e7 commit 7bb63be

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

lib/yard/parser/c/c_parser.rb

+17-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,14 @@ def consume_body_statements
9797
stmts = []
9898
brace_level = 1
9999
loop do
100-
strip_non_statement_data
100+
# Need to include the @! directive tags for them to be processed
101+
# along with the body statement content.
102+
# (At least the @!group directive.)
103+
directive_tags = capture_directive_tags_hack do
104+
strip_non_statement_data
105+
end
106+
stmts.concat(directive_tags)
107+
101108
start = @index
102109
line = @line
103110
consume_until(/[{};]/)
@@ -115,6 +122,15 @@ def consume_body_statements
115122
stmts
116123
end
117124

125+
def capture_directive_tags_hack
126+
temp = @statements.dup
127+
yield if block_given?
128+
stmts = (@statements - temp)
129+
stmts.select do |stmt|
130+
stmt.is_a?(Comment) && stmt.source.start_with?('@!')
131+
end
132+
end
133+
118134
def strip_non_statement_data
119135
start = @index
120136
loop do

spec/parser/c_parser_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def parse(contents)
130130
parse <<-eof
131131
void Init_Mask(void)
132132
{
133-
rb_cExample = rb_define_class("Example", rb_cObject);
133+
rb_cExample = rb_define_class("Example", rb_cObject);
134134
135135
// @!group Foos
136136

0 commit comments

Comments
 (0)