diff --git a/corpus/comment.txt b/corpus/comment.txt index d6de6b6..b3fe10c 100644 --- a/corpus/comment.txt +++ b/corpus/comment.txt @@ -24,3 +24,7 @@ message(STATUS #[[Some comment]] "comment is next" #[[Some comment]]) (comment (bracket_argument)) ) ) + +====================== +Line comment [comment] +====================== diff --git a/src/scanner.cc b/src/scanner.cc index 790648c..fa250f5 100644 --- a/src/scanner.cc +++ b/src/scanner.cc @@ -3,16 +3,11 @@ #include namespace { -enum TokenType { BRACKET_ARGUMENT }; +enum TokenType { BRACKET_ARGUMENT, LINE_COMMENT }; void skip(TSLexer *lexer) { lexer->advance(lexer, true); } void advance(TSLexer *lexer) { lexer->advance(lexer, false); } -bool scan(void *payload, TSLexer *lexer, const bool *valid_symbols) { - using std::iswspace; - - if (!valid_symbols[BRACKET_ARGUMENT]) - return false; - - while (iswspace(lexer->lookahead)) +bool scan_bracket_argument(TSLexer *lexer) { + while (std::iswspace(lexer->lookahead)) skip(lexer); if (lexer->lookahead != '[') @@ -47,6 +42,11 @@ bool scan(void *payload, TSLexer *lexer, const bool *valid_symbols) { } } } + return false; +} +bool scan(void *payload, TSLexer *lexer, const bool *valid_symbols) { + if (valid_symbols[BRACKET_ARGUMENT]) + return scan_bracket_argument(lexer); return false; }