Skip to content

Commit

Permalink
Restore CParser hack.
Browse files Browse the repository at this point in the history
  • Loading branch information
thomthom committed Oct 25, 2019
1 parent dd550e7 commit 7bb63be
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion lib/yard/parser/c/c_parser.rb
Expand Up @@ -97,7 +97,14 @@ def consume_body_statements
stmts = []
brace_level = 1
loop do
strip_non_statement_data
# Need to include the @! directive tags for them to be processed
# along with the body statement content.
# (At least the @!group directive.)
directive_tags = capture_directive_tags_hack do
strip_non_statement_data
end
stmts.concat(directive_tags)

start = @index
line = @line
consume_until(/[{};]/)
Expand All @@ -115,6 +122,15 @@ def consume_body_statements
stmts
end

def capture_directive_tags_hack
temp = @statements.dup
yield if block_given?
stmts = (@statements - temp)
stmts.select do |stmt|
stmt.is_a?(Comment) && stmt.source.start_with?('@!')
end
end

def strip_non_statement_data
start = @index
loop do
Expand Down
2 changes: 1 addition & 1 deletion spec/parser/c_parser_spec.rb
Expand Up @@ -130,7 +130,7 @@ def parse(contents)
parse <<-eof
void Init_Mask(void)
{
rb_cExample = rb_define_class("Example", rb_cObject);
rb_cExample = rb_define_class("Example", rb_cObject);
// @!group Foos
Expand Down

0 comments on commit 7bb63be

Please sign in to comment.