Hide command_invocation

This commit is contained in:
Uy Ha 2021-06-08 00:02:13 +02:00
parent a4960577dd
commit 9e0798cc16
9 changed files with 1262 additions and 1286 deletions

View file

@ -6,7 +6,6 @@ message([[]])
---
(source_file
(command_invocation
(normal_command
(identifier)
(arguments
@ -14,17 +13,15 @@ message([[]])
)
)
)
)
=======================================
One bracket argument [bracket_argument]
=======================================
message([[An argument]])
message([[an argument]])
---
(source_file
(command_invocation
(normal_command
(identifier)
(arguments
@ -32,17 +29,15 @@ message([[An argument]])
)
)
)
)
========================================
Two bracket arguments [bracket_argument]
========================================
message([[First argument]] [[Second argument]])
message([[first argument]] [[second argument]])
---
(source_file
(command_invocation
(normal_command
(identifier)
(arguments
@ -52,20 +47,18 @@ message([[First argument]] [[Second argument]])
)
)
)
)
========================================================
Two bracket with two equals arguments [bracket_argument]
========================================================
message(
[====[First argument]====]
[====[Second argument]====]
[====[first argument]====]
[====[second argument]====]
)
---
(source_file
(command_invocation
(normal_command
(identifier)
(seperation (space))
@ -77,19 +70,17 @@ message(
)
)
)
)
===================================================
Bracket argument with line break [bracket_argument]
===================================================
message([[An argument
message([[an argument
with line break
]])
---
(source_file
(command_invocation
(normal_command
(identifier)
(arguments
@ -97,5 +88,4 @@ with line break
)
)
)
)

View file

@ -8,18 +8,14 @@ endforeach()
---
(source_file
(command_invocation
(foreach_command
(foreach)
(variable)
)
)
(command_invocation
(endforeach_command
(endforeach)
)
)
)
=========================================================
Empty foreach loop with one argument endforeach [foreach]
@ -31,18 +27,14 @@ endforeach(var)
---
(source_file
(command_invocation
(foreach_command
(foreach)
(variable)
)
)
(command_invocation
(endforeach_command
(endforeach)
(variable)
)
)
)
===========================
@ -55,18 +47,14 @@ ENDFOREACH()
---
(source_file
(command_invocation
(foreach_command
(foreach)
(variable)
)
)
(command_invocation
(endforeach_command
(endforeach)
)
)
)
============================
Mixed case foreach [foreach]
@ -78,15 +66,11 @@ endForEach()
---
(source_file
(command_invocation
(foreach_command
(foreach)
(variable)
)
)
(command_invocation
(endforeach_command
(endforeach)
)
)
)

View file

@ -7,12 +7,10 @@ message()
---
(source_file
(command_invocation
(normal_command
(identifier)
)
)
)
=============================================================
Command invocation without argument with spaces [no_argument]
@ -23,13 +21,11 @@ message( )
---
(source_file
(command_invocation
(normal_command
(identifier)
(seperation (space))
)
)
)
==============================================================
Command invocation without argument with newline [no_argument]
@ -42,7 +38,6 @@ message(
---
(source_file
(command_invocation
(normal_command
(identifier)
(seperation
@ -50,5 +45,4 @@ message(
)
)
)
)

View file

@ -6,7 +6,6 @@ message("")
---
(source_file
(command_invocation
(normal_command
(identifier)
(arguments
@ -14,7 +13,6 @@ message("")
)
)
)
)
=====================================
One quoted argument [quoted_argument]
@ -24,7 +22,6 @@ message("An argument")
---
(source_file
(command_invocation
(normal_command
(identifier)
(arguments
@ -32,7 +29,6 @@ message("An argument")
)
)
)
)
======================================
Two quoted arguments [quoted_argument]
@ -42,7 +38,6 @@ message("First argument" "Second argument")
---
(source_file
(command_invocation
(normal_command
(identifier)
(arguments
@ -52,7 +47,6 @@ message("First argument" "Second argument")
)
)
)
)
===================================================
A quoted argument with line break [quoted_argument]
@ -63,7 +57,6 @@ with line break")
---
(source_file
(command_invocation
(normal_command
(identifier)
(arguments
@ -71,7 +64,6 @@ with line break")
)
)
)
)
========================================
One variable reference [quoted_argument]
@ -81,7 +73,6 @@ message("${var}")
---
(source_file
(command_invocation
(normal_command
(identifier)
(arguments
@ -95,7 +86,6 @@ message("${var}")
)
)
)
)
=========================================
Two Variable references [quoted_argument]
@ -105,7 +95,6 @@ message("${var} ${var}")
---
(source_file
(command_invocation
(normal_command
(identifier)
(arguments
@ -120,4 +109,3 @@ message("${var} ${var}")
)
)
)
)

View file

@ -7,7 +7,6 @@ message(STATUS)
---
(source_file
(command_invocation
(normal_command
(identifier)
(arguments
@ -15,7 +14,6 @@ message(STATUS)
)
)
)
)
=========================================================
Command invocation with two arguments [unquoted_argument]
@ -26,7 +24,6 @@ message(STATUS Hello)
---
(source_file
(command_invocation
(normal_command
(identifier)
(arguments
@ -36,7 +33,6 @@ message(STATUS Hello)
)
)
)
)
===============================================================
Command invocations with leading seperation [unquoted_argument]
@ -48,7 +44,6 @@ STATUS)
---
(source_file
(command_invocation
(normal_command
(identifier)
(seperation (space))
@ -56,8 +51,6 @@ STATUS)
(argument (unquoted_argument))
)
)
)
(command_invocation
(normal_command
(identifier)
(seperation (line_ending (newline)))
@ -66,18 +59,16 @@ STATUS)
)
)
)
)
============================================================
Command invocations with escape sequence [unquoted_argument]
============================================================
message( STATUS)
message( STATUS)
message(
STATUS)
---
(source_file
(command_invocation
(normal_command
(identifier)
(seperation (space))
@ -85,8 +76,6 @@ STATUS)
(argument (unquoted_argument))
)
)
)
(command_invocation
(normal_command
(identifier)
(seperation (line_ending (newline)))
@ -95,7 +84,6 @@ STATUS)
)
)
)
)
========================================
Variable referencing [unquoted_argument]
@ -104,7 +92,6 @@ message(${var_ref})
---
(source_file
(command_invocation
(normal_command
(identifier)
(arguments
@ -116,5 +103,4 @@ message(${var_ref})
)
)
)
)

View file

@ -2,7 +2,7 @@ module.exports = grammar({
name: "cmake",
rules: {
source_file: ($) => repeat($.command_invocation),
source_file: ($) => repeat($._command_invocation),
line_ending: ($) => $.newline,
seperation: ($) => choice($.space, $.line_ending),
@ -46,7 +46,7 @@ module.exports = grammar({
normal_command: ($) =>
seq($.identifier, "(", repeat($.seperation), optional($.arguments), ")"),
command_invocation: ($) => choice($.normal_command, $.foreach_command, $.endforeach_command),
_command_invocation: ($) => choice($.normal_command, $.foreach_command, $.endforeach_command),
},
});

View file

@ -5,7 +5,7 @@
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "command_invocation"
"name": "_command_invocation"
}
},
"line_ending": {
@ -13,6 +13,11 @@
"name": "newline"
},
"seperation": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "REPEAT1",
"content": {
"type": "CHOICE",
"members": [
{
@ -24,14 +29,16 @@
"name": "line_ending"
}
]
}
}
},
"space": {
"type": "PATTERN",
"value": "[ \\t]+"
"value": "[ \\t]"
},
"newline": {
"type": "PATTERN",
"value": "\\n+"
"value": "\\n"
},
"foreach": {
"type": "PATTERN",
@ -490,7 +497,7 @@
}
]
},
"command_invocation": {
"_command_invocation": {
"type": "CHOICE",
"members": [
{

View file

@ -76,29 +76,6 @@
]
}
},
{
"type": "command_invocation",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "endforeach_command",
"named": true
},
{
"type": "foreach_command",
"named": true
},
{
"type": "normal_command",
"named": true
}
]
}
},
{
"type": "endforeach_command",
"named": true,
@ -261,7 +238,7 @@
"named": true,
"fields": {},
"children": {
"multiple": false,
"multiple": true,
"required": true,
"types": [
{
@ -284,7 +261,15 @@
"required": false,
"types": [
{
"type": "command_invocation",
"type": "endforeach_command",
"named": true
},
{
"type": "foreach_command",
"named": true
},
{
"type": "normal_command",
"named": true
}
]

File diff suppressed because it is too large Load diff