Extract out to scan_bracket_argument
function
This commit is contained in:
parent
3b2b47dbaa
commit
06d75be374
|
@ -24,3 +24,7 @@ message(STATUS #[[Some comment]] "comment is next" #[[Some comment]])
|
||||||
(comment (bracket_argument))
|
(comment (bracket_argument))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
======================
|
||||||
|
Line comment [comment]
|
||||||
|
======================
|
||||||
|
|
|
@ -3,16 +3,11 @@
|
||||||
#include <tree_sitter/parser.h>
|
#include <tree_sitter/parser.h>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
enum TokenType { BRACKET_ARGUMENT };
|
enum TokenType { BRACKET_ARGUMENT, LINE_COMMENT };
|
||||||
void skip(TSLexer *lexer) { lexer->advance(lexer, true); }
|
void skip(TSLexer *lexer) { lexer->advance(lexer, true); }
|
||||||
void advance(TSLexer *lexer) { lexer->advance(lexer, false); }
|
void advance(TSLexer *lexer) { lexer->advance(lexer, false); }
|
||||||
bool scan(void *payload, TSLexer *lexer, const bool *valid_symbols) {
|
bool scan_bracket_argument(TSLexer *lexer) {
|
||||||
using std::iswspace;
|
while (std::iswspace(lexer->lookahead))
|
||||||
|
|
||||||
if (!valid_symbols[BRACKET_ARGUMENT])
|
|
||||||
return false;
|
|
||||||
|
|
||||||
while (iswspace(lexer->lookahead))
|
|
||||||
skip(lexer);
|
skip(lexer);
|
||||||
|
|
||||||
if (lexer->lookahead != '[')
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue