Parse parenteses correctly
This commit is contained in:
parent
44a026bbf5
commit
19bb3af0d5
38
corpus/parentheses.txt
Normal file
38
corpus/parentheses.txt
Normal file
|
@ -0,0 +1,38 @@
|
|||
===================================================
|
||||
Parentheses inside command invocation [parentheses]
|
||||
===================================================
|
||||
message(STATUS (TEST))
|
||||
---
|
||||
(source_file
|
||||
(normal_command
|
||||
(identifier)
|
||||
(argument (unquoted_argument))
|
||||
(argument (unquoted_argument))
|
||||
)
|
||||
)
|
||||
|
||||
===========================================================
|
||||
Missing parentheses inside command invocation [parentheses]
|
||||
===========================================================
|
||||
message(STATUS (TEST)
|
||||
---
|
||||
(source_file
|
||||
(normal_command
|
||||
(identifier)
|
||||
(argument (unquoted_argument))
|
||||
(argument (unquoted_argument)) (MISSING ")")
|
||||
)
|
||||
)
|
||||
|
||||
==================================================================
|
||||
Nested missing parentheses inside command invocation [parentheses]
|
||||
==================================================================
|
||||
message(STATUS ((TEST))
|
||||
---
|
||||
(source_file
|
||||
(normal_command
|
||||
(identifier)
|
||||
(argument (unquoted_argument))
|
||||
(argument (unquoted_argument)) (MISSING ")")
|
||||
)
|
||||
)
|
|
@ -34,7 +34,8 @@ module.exports = grammar({
|
|||
cache_var: ($) => seq("$", "CACHE", "{", $.variable, "}"),
|
||||
|
||||
argument: ($) => choice($.bracket_argument, $.quoted_argument, $.unquoted_argument),
|
||||
_untrimmed_argument: ($) => choice(/\s/, $.bracket_comment, $.line_comment, $.argument),
|
||||
_untrimmed_argument: ($) => choice(/\s/, $.bracket_comment, $.line_comment, $.argument, $._paren_argument),
|
||||
_paren_argument: ($) => seq("(", $._untrimmed_argument, ")"),
|
||||
|
||||
quoted_argument: ($) => seq('"', optional($.quoted_element), '"'),
|
||||
quoted_element: ($) => repeat1(choice($.variable_ref, /[^\\"]/, $.escape_sequence)),
|
||||
|
|
|
@ -197,6 +197,27 @@
|
|||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "argument"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_paren_argument"
|
||||
}
|
||||
]
|
||||
},
|
||||
"_paren_argument": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "("
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_untrimmed_argument"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ")"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
22773
src/parser.c
22773
src/parser.c
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue