fix: else and endif arguments

This commit is contained in:
Uy Ha 2022-07-08 12:04:54 +07:00
parent 13c7c529d7
commit 3d23db47a5
5 changed files with 11505 additions and 11060 deletions

View file

@ -106,3 +106,42 @@ endif()
(endif_command (endif)) (endif_command (endif))
) )
) )
==============================================
Condition with not and parentheses [condition]
==============================================
if(NOT (A AND B) OR C)
else(NOT (A AND B) OR C)
endif(NOT (A AND B) OR C)
---
(source_file
(if_condition
(if_command
(if)
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
)
(else_command
(else)
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
)
(endif_command
(endif)
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
)
)
)

View file

@ -50,8 +50,8 @@ module.exports = grammar({
if_command: ($) => command($.if, repeat($._untrimmed_argument)), if_command: ($) => command($.if, repeat($._untrimmed_argument)),
elseif_command: ($) => command($.elseif, repeat($._untrimmed_argument)), elseif_command: ($) => command($.elseif, repeat($._untrimmed_argument)),
else_command: ($) => command($.else, optional(seq(/\s*/, $.argument, /\s*/))), else_command: ($) => command($.else, repeat($._untrimmed_argument)),
endif_command: ($) => command($.endif, optional(seq(/\s*/, $.argument, /\s*/))), endif_command: ($) => command($.endif, repeat($._untrimmed_argument)),
if_condition: ($) => if_condition: ($) =>
seq( seq(
$.if_command, $.if_command,

View file

@ -505,29 +505,11 @@
"value": "(" "value": "("
}, },
{ {
"type": "CHOICE", "type": "REPEAT",
"members": [ "content": {
{
"type": "SEQ",
"members": [
{
"type": "PATTERN",
"value": "\\s*"
},
{
"type": "SYMBOL", "type": "SYMBOL",
"name": "argument" "name": "_untrimmed_argument"
},
{
"type": "PATTERN",
"value": "\\s*"
} }
]
},
{
"type": "BLANK"
}
]
}, },
{ {
"type": "STRING", "type": "STRING",
@ -554,29 +536,11 @@
"value": "(" "value": "("
}, },
{ {
"type": "CHOICE", "type": "REPEAT",
"members": [ "content": {
{
"type": "SEQ",
"members": [
{
"type": "PATTERN",
"value": "\\s*"
},
{
"type": "SYMBOL", "type": "SYMBOL",
"name": "argument" "name": "_untrimmed_argument"
},
{
"type": "PATTERN",
"value": "\\s*"
} }
]
},
{
"type": "BLANK"
}
]
}, },
{ {
"type": "STRING", "type": "STRING",

View file

@ -49,9 +49,17 @@
"type": "argument", "type": "argument",
"named": true "named": true
}, },
{
"type": "bracket_comment",
"named": true
},
{ {
"type": "else", "type": "else",
"named": true "named": true
},
{
"type": "line_comment",
"named": true
} }
] ]
} }
@ -141,9 +149,17 @@
"type": "argument", "type": "argument",
"named": true "named": true
}, },
{
"type": "bracket_comment",
"named": true
},
{ {
"type": "endif", "type": "endif",
"named": true "named": true
},
{
"type": "line_comment",
"named": true
} }
] ]
} }

22450
src/parser.c

File diff suppressed because it is too large Load diff