diff --git a/lib/cmock_header_parser.rb b/lib/cmock_header_parser.rb index 689d769..afadb48 100644 --- a/lib/cmock_header_parser.rb +++ b/lib/cmock_header_parser.rb @@ -50,6 +50,9 @@ class CMockHeaderParser source.gsub!(/\/\/(?:.+\/\*|\*(?:$|[^\/])).*$/, '') # remove line comments that comment out the start of blocks source.gsub!(/\/\*.*?\*\//m, '') # remove block comments source.gsub!(/\/\/.*$/, '') # remove line comments (all that remain) + + # remove assembler pragma sections + source.gsub!(/^\s*#\s*pragma\s+asm\s+.*?#\s*pragma\s+endasm/m, '') # remove preprocessor statements source.gsub!(/^\s*#.*/, '') diff --git a/test/unit/cmock_header_parser_test.rb b/test/unit/cmock_header_parser_test.rb index 347dd02..1613594 100644 --- a/test/unit/cmock_header_parser_test.rb +++ b/test/unit/cmock_header_parser_test.rb @@ -83,6 +83,21 @@ class CMockHeaderParserTest < Test::Unit::TestCase assert_equal(expected, @parser.import_source(source)) end + + + should "remove assembler pragma sections" do + source = + " #pragma\tasm\n" + + " .foo\n" + + " lda %m\n" + + " nop\n" + + "# pragma endasm \n" + + "foo" + + expected = ["foo"] + + assert_equal(expected, @parser.import_source(source)) + end should "smush lines together that contain continuation characters" do @@ -527,4 +542,4 @@ class CMockHeaderParserTest < Test::Unit::TestCase assert_equal(expected, @parser.parse(source)[:functions]) end -end \ No newline at end of file +end