Add special lexing for regexes after `=~`
This commit is contained in:
parent
0d9f854862
commit
c7e42b8e96
|
@ -18,22 +18,35 @@ Words with special characters
|
||||||
echo {o[k]}
|
echo {o[k]}
|
||||||
echo }}}
|
echo }}}
|
||||||
echo ]]] ===
|
echo ]]] ===
|
||||||
[[ "35d8b" =~ ^[0-9a-fA-F] ]] || echo {nomatch}
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
(program
|
(program
|
||||||
(command (command_name (word)) (concatenation (word) (word)))
|
(command (command_name (word)) (concatenation (word) (word)))
|
||||||
(command (command_name (word)) (word))
|
(command (command_name (word)) (word))
|
||||||
(command (command_name (word)) (word) (word))
|
(command (command_name (word)) (word) (word)))
|
||||||
(list
|
|
||||||
(bracket_command
|
=============================
|
||||||
(string)
|
The regex operator
|
||||||
(word)
|
=============================
|
||||||
(concatenation (word) (word)))
|
|
||||||
(command
|
[[ "35d8b" =~ ^[0-9a-fA-F] ]]
|
||||||
(command_name (word))
|
[[ $CMD =~ (^|;)update_terminal_cwd($|;) ]]
|
||||||
(concatenation (word)))))
|
[[ ! " ${completions[*]} " =~ " $alias_cmd " ]]
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(program
|
||||||
|
(bracket_command
|
||||||
|
(string)
|
||||||
|
(regex))
|
||||||
|
(bracket_command
|
||||||
|
(simple_expansion (variable_name))
|
||||||
|
(regex))
|
||||||
|
(bracket_command
|
||||||
|
(word)
|
||||||
|
(string (expansion (subscript (variable_name) (word))))
|
||||||
|
(string (simple_expansion (variable_name)))))
|
||||||
|
|
||||||
=============================
|
=============================
|
||||||
Simple variable expansions
|
Simple variable expansions
|
||||||
|
|
20
grammar.js
20
grammar.js
|
@ -179,10 +179,20 @@ module.exports = grammar({
|
||||||
$._statement
|
$._statement
|
||||||
)),
|
)),
|
||||||
|
|
||||||
bracket_command: $ => choice(
|
bracket_command: $ => {
|
||||||
seq('[', repeat1($._expression), ']'),
|
const contents = repeat1(choice(
|
||||||
seq('[[', repeat1($._expression), ']]')
|
$._expression,
|
||||||
),
|
seq('=~', choice(
|
||||||
|
$.regex,
|
||||||
|
$._expression
|
||||||
|
))
|
||||||
|
))
|
||||||
|
|
||||||
|
return choice(
|
||||||
|
seq('[', contents, ']'),
|
||||||
|
seq('[[', contents, ']]')
|
||||||
|
)
|
||||||
|
},
|
||||||
|
|
||||||
// Commands
|
// Commands
|
||||||
|
|
||||||
|
@ -383,6 +393,8 @@ module.exports = grammar({
|
||||||
seq('\\', noneOf('\\s'))
|
seq('\\', noneOf('\\s'))
|
||||||
))),
|
))),
|
||||||
|
|
||||||
|
regex: $ => /\S+/,
|
||||||
|
|
||||||
_terminator: $ => choice(';', ';;', '\n', '&')
|
_terminator: $ => choice(';', ';;', '\n', '&')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue