Fix a case with an empty body with comment(s)
This commit is contained in:
committed by
Michael Hoffmann
parent
9903dc0b57
commit
4e33af0710
@@ -37,7 +37,9 @@ module.exports = function make_grammar(dialect) {
|
||||
// also allow objects to handle .tfvars in json format
|
||||
config_file: $ => optional(choice($.body, $.object)),
|
||||
|
||||
body: $ => seq(
|
||||
body: $ => choice(
|
||||
$._shim,
|
||||
seq(
|
||||
optional($._shim),
|
||||
repeat1(
|
||||
choice(
|
||||
@@ -46,6 +48,7 @@ module.exports = function make_grammar(dialect) {
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
attribute: $ => seq(
|
||||
$.identifier,
|
||||
|
||||
@@ -98,6 +98,8 @@ public:
|
||||
return false;
|
||||
}
|
||||
if (valid_symbols[SHIM]) {
|
||||
lexer->mark_end(lexer);
|
||||
while(skip_comment(lexer));
|
||||
if (lexer->lookahead != '}') {
|
||||
return accept_inplace(lexer, SHIM);
|
||||
}
|
||||
@@ -271,6 +273,20 @@ private:
|
||||
return iswxdigit(lexer->lookahead);
|
||||
}
|
||||
|
||||
bool skip_comment(TSLexer* lexer) {
|
||||
while (iswspace(lexer->lookahead)) {
|
||||
skip(lexer);
|
||||
}
|
||||
if (lexer->lookahead != '#') {
|
||||
return false;
|
||||
}
|
||||
skip(lexer);
|
||||
while (lexer->lookahead != '\n') {
|
||||
skip(lexer);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool in_context_type(ContextType type) {
|
||||
if (context_stack.empty()) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user