Allow regexes after '==', not just '=~'

This commit is contained in:
Max Brunsfeld 2018-03-01 14:15:29 -08:00
parent 30844a0381
commit 87a832d94e
5 changed files with 72190 additions and 71704 deletions

View File

@ -95,7 +95,6 @@ fi
(if_statement
(bracket_command
(string (command_substitution (command (command_name (word)))))
(word)
(raw_string))
(command (command_name (word)) (word))))

View File

@ -196,10 +196,10 @@ module.exports = grammar({
$.command_name,
repeat(choice(
$._expression,
seq('=~', choice(
$.regex,
$._expression
))
seq(
choice('=~', '=='),
choice($.regex, $._expression)
)
)),
repeat(choice(
$.file_redirect,
@ -213,10 +213,10 @@ module.exports = grammar({
bracket_command: $ => {
const args = repeat1(choice(
$._expression,
seq('=~', choice(
$.regex,
$._expression
))
seq(
choice('=~', '=='),
choice($.regex, $._expression)
)
))
return seq(
@ -427,8 +427,8 @@ module.exports = grammar({
seq('\\', noneOf('\\s'))
))),
regex: $ => /([^\s]|\\.)+/,
regex_without_right_brace: $ => /([^\s}]|\\.)+/,
regex: $ => /([^"\s]|\\.)([^\s]|\\.)*/,
regex_without_right_brace: $ => /([^"\s}]|\\.)([^\s}]|\\.)*/,
_terminator: $ => choice(';', ';;', '\n', '&')
}

View File

@ -1,5 +1,4 @@
examples/bash-it/plugins/available/git.plugin.bash
examples/bash-it/plugins/available/fzf.plugin.bash
examples/bash-it/plugins/available/extract.plugin.bash
examples/bash-it/plugins/available/less-pretty-cat.plugin.bash
examples/bash-it/plugins/available/z_autoenv.plugin.bash
@ -42,7 +41,6 @@ examples/bash-it/lib/search.bash
examples/bash-it/test_lib/bats-support/src/lang.bash
examples/bash-it/test_lib/bats-support/src/output.bash
examples/bash-it/test_lib/bats-assert/src/assert.bash
examples/bash-it/test_lib/bats-core/test/test_helper.bash
examples/bash-it/test_lib/bats-file/src/temp.bash
examples/bash-it/themes/hawaii50/hawaii50.theme.bash
examples/bash-it/themes/iterate/iterate.theme.bash

40
src/grammar.json vendored
View File

@ -696,11 +696,20 @@
},
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "=~"
},
{
"type": "STRING",
"value": "=="
}
]
},
{
"type": "CHOICE",
"members": [
@ -770,11 +779,20 @@
},
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "=~"
},
{
"type": "STRING",
"value": "=="
}
]
},
{
"type": "CHOICE",
"members": [
@ -817,11 +835,20 @@
},
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "=~"
},
{
"type": "STRING",
"value": "=="
}
]
},
{
"type": "CHOICE",
"members": [
@ -1488,9 +1515,18 @@
"type": "STRING",
"value": "$"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "string"
},
{
"type": "SYMBOL",
"name": "raw_string"
}
]
}
]
},
@ -1801,11 +1837,11 @@
},
"regex": {
"type": "PATTERN",
"value": "([^\\s]|\\\\.)+"
"value": "([^\"\\s]|\\\\.)([^\\s]|\\\\.)*"
},
"regex_without_right_brace": {
"type": "PATTERN",
"value": "([^\\s}]|\\\\.)+"
"value": "([^\"\\s}]|\\\\.)([^\\s}]|\\\\.)*"
},
"_terminator": {
"type": "CHOICE",

143815
src/parser.c vendored

File diff suppressed because it is too large Load Diff