Skip to content

Commit

Permalink
[eggex] Reject an invalid pattern like / ! /
Browse files Browse the repository at this point in the history
This was an error/typo in the grammar.

Also remove incomplete implementation of / ! %boundary /.  ERE doesn't
have any negated "zero-width assertions".

Addresses #1225.
  • Loading branch information
Andy C committed Jul 11, 2022
1 parent a8ba3f1 commit fd3686a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions oil_lang/grammar.pgen2
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,9 @@ re_atom: (
# %begin or %end
| Expr_Symbol
| class_literal
# !digit or ~ %boundary or ![a-f]
| '!' [Expr_Name | Expr_Symbol | class_literal]
# !digit or ![a-f]. Note ! %boundary could be \B in Python, but ERE
# doesn't have anything like that
| '!' (Expr_Name | class_literal)
# Splice another expression
| '@' Expr_Name
# any %start %end are preferred
Expand Down
6 changes: 6 additions & 0 deletions test/parse-errors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,12 @@ json write (x) {
regex_literals() {
set +o errexit

_oil-parse-error 'var x = / ! /'
_oil-should-parse 'var x = / ![a-z] /'
_oil-should-parse 'var x = / !d /'

_oil-parse-error 'var x = / !! /'

# missing space between rangfes
_oil-parse-error 'var x = /[a-zA-Z]/'
_oil-parse-error 'var x = /[a-z0-9]/'
Expand Down

0 comments on commit fd3686a

Please sign in to comment.