Add 2 things:
- Escape sequence - Seperation before arguments
This commit is contained in:
parent
788ec10f19
commit
2baec3b814
|
@ -33,3 +33,29 @@ message(STATUS Hello)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
===========================================
|
||||||
|
Command invocations with leading seperation
|
||||||
|
===========================================
|
||||||
|
|
||||||
|
message( STATUS)
|
||||||
|
message(
|
||||||
|
STATUS)
|
||||||
|
---
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(command_invocation
|
||||||
|
(identifier)
|
||||||
|
(seperation (space))
|
||||||
|
(arguments
|
||||||
|
(argument (unquoted_argument))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(command_invocation
|
||||||
|
(identifier)
|
||||||
|
(seperation (line_ending (newline)))
|
||||||
|
(arguments
|
||||||
|
(argument (unquoted_argument))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
19
grammar.js
19
grammar.js
|
@ -10,12 +10,27 @@ module.exports = grammar({
|
||||||
newline: $ => /\n/,
|
newline: $ => /\n/,
|
||||||
identifier: $ => /[A-Za-z_][A-Za-z0-9_]*/,
|
identifier: $ => /[A-Za-z_][A-Za-z0-9_]*/,
|
||||||
|
|
||||||
|
escape_sequence: $ => choice(
|
||||||
|
$._escape_identity,
|
||||||
|
$._escape_encoded,
|
||||||
|
$._escape_semicolon,
|
||||||
|
),
|
||||||
|
_escape_identity: $ => /\\[^A-Za-z0-9;]/,
|
||||||
|
_escape_encoded: $ => choice('\\t', '\\r', '\\n'),
|
||||||
|
_escape_semicolon: $ => '\;',
|
||||||
|
|
||||||
|
|
||||||
argument: $ => choice(
|
argument: $ => choice(
|
||||||
$.unquoted_argument,
|
$.unquoted_argument,
|
||||||
$.bracket_argument,
|
$.bracket_argument,
|
||||||
),
|
),
|
||||||
|
|
||||||
unquoted_argument: $ => repeat1(/[^ ()#\"\\]/),
|
unquoted_argument: $ => repeat1(
|
||||||
|
choice(
|
||||||
|
/[^ ()#\"\\]/,
|
||||||
|
$.escape_sequence,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
bracket_argument: $ => seq(
|
bracket_argument: $ => seq(
|
||||||
$._bracket_open,
|
$._bracket_open,
|
||||||
|
@ -36,7 +51,7 @@ module.exports = grammar({
|
||||||
command_invocation: $ => seq(
|
command_invocation: $ => seq(
|
||||||
repeat($.space),
|
repeat($.space),
|
||||||
$.identifier,
|
$.identifier,
|
||||||
repeat($.space),
|
repeat($.seperation),
|
||||||
'(',
|
'(',
|
||||||
repeat($.seperation),
|
repeat($.seperation),
|
||||||
optional($.arguments),
|
optional($.arguments),
|
||||||
|
|
|
@ -37,6 +37,48 @@
|
||||||
"type": "PATTERN",
|
"type": "PATTERN",
|
||||||
"value": "[A-Za-z_][A-Za-z0-9_]*"
|
"value": "[A-Za-z_][A-Za-z0-9_]*"
|
||||||
},
|
},
|
||||||
|
"escape_sequence": {
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_escape_identity"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_escape_encoded"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_escape_semicolon"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"_escape_identity": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "\\\\[^A-Za-z0-9;]"
|
||||||
|
},
|
||||||
|
"_escape_encoded": {
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "\\t"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "\\r"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "\\n"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"_escape_semicolon": {
|
||||||
|
"type": "STRING",
|
||||||
|
"value": ";"
|
||||||
|
},
|
||||||
"argument": {
|
"argument": {
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
|
@ -53,8 +95,17 @@
|
||||||
"unquoted_argument": {
|
"unquoted_argument": {
|
||||||
"type": "REPEAT1",
|
"type": "REPEAT1",
|
||||||
"content": {
|
"content": {
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
"type": "PATTERN",
|
"type": "PATTERN",
|
||||||
"value": "[^ ()#\\\"\\\\]"
|
"value": "[^ ()#\\\"\\\\]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "escape_sequence"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"bracket_argument": {
|
"bracket_argument": {
|
||||||
|
@ -191,7 +242,7 @@
|
||||||
"type": "REPEAT",
|
"type": "REPEAT",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "space"
|
"name": "seperation"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,6 +69,11 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "escape_sequence",
|
||||||
|
"named": true,
|
||||||
|
"fields": {}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "line_ending",
|
"type": "line_ending",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
@ -121,7 +126,17 @@
|
||||||
{
|
{
|
||||||
"type": "unquoted_argument",
|
"type": "unquoted_argument",
|
||||||
"named": true,
|
"named": true,
|
||||||
"fields": {}
|
"fields": {},
|
||||||
|
"children": {
|
||||||
|
"multiple": true,
|
||||||
|
"required": false,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "escape_sequence",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "(",
|
"type": "(",
|
||||||
|
@ -139,6 +154,18 @@
|
||||||
"type": "[",
|
"type": "[",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "\\n",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "\\r",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "\\t",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "]",
|
"type": "]",
|
||||||
"named": false
|
"named": false
|
||||||
|
|
1523
src/parser.c
1523
src/parser.c
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue