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

56
src/grammar.json vendored
View File

@ -698,8 +698,17 @@
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "=~"
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "=~"
},
{
"type": "STRING",
"value": "=="
}
]
},
{
"type": "CHOICE",
@ -772,8 +781,17 @@
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "=~"
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "=~"
},
{
"type": "STRING",
"value": "=="
}
]
},
{
"type": "CHOICE",
@ -819,8 +837,17 @@
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "=~"
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "=~"
},
{
"type": "STRING",
"value": "=="
}
]
},
{
"type": "CHOICE",
@ -1489,8 +1516,17 @@
"value": "$"
},
{
"type": "SYMBOL",
"name": "string"
"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