From fcb453728821223028bd13ad0e2d58d135ef0859 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 7 Dec 2017 14:17:23 -0800 Subject: [PATCH] Fix regex for unknown preprocessor directives Signed-off-by: Nathan Sobo --- corpus/preprocessor.txt | 10 ++++++++++ grammar.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/corpus/preprocessor.txt b/corpus/preprocessor.txt index 4180bdf..542a7d0 100644 --- a/corpus/preprocessor.txt +++ b/corpus/preprocessor.txt @@ -133,3 +133,13 @@ int main() { (return_statement (number_literal)) (preproc_else (return_statement (number_literal))))))) + +==================================== +Unknown preprocessor directives +==================================== + +#pragma mark - UIViewController + +--- + +(translation_unit (preproc_call (preproc_directive) (preproc_arg))) diff --git a/grammar.js b/grammar.js index a077c38..321c499 100644 --- a/grammar.js +++ b/grammar.js @@ -149,7 +149,7 @@ module.exports = grammar({ repeat($._compound_statement_item) ), - preproc_directive: $ => /#[ \t]+\a\w*/, + preproc_directive: $ => /#[ \t]*\a\w*/, preproc_arg: $ => token(prec(-1, repeat1(choice(/./, '\\\n')))), // Main Grammar