emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#37849: closed (composable character alternatives in rx)


From: GNU bug Tracking System
Subject: bug#37849: closed (composable character alternatives in rx)
Date: Fri, 13 Dec 2019 12:37:02 +0000

Your message dated Fri, 13 Dec 2019 13:35:42 +0100
with message-id <address@hidden>
and subject line Re: bug#37849: composable character alternatives in rx 
has caused the debbugs.gnu.org bug report #37849,
regarding composable character alternatives in rx
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden.)


-- 
37849: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=37849
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: composable character alternatives in rx Date: Mon, 21 Oct 2019 12:24:21 +0200
Now that rx is user-extendible, some holes are showing. Example (from 
python.el):

      (simple-operator      . ,(rx (any ?+ ?- ?/ ?& ?^ ?~ ?| ?* ?< ?> ?= ?%)))
      ;; FIXME: rx should support (not simple-operator).
      (not-simple-operator  . ,(rx
                                (not
                                 (any ?+ ?- ?/ ?& ?^ ?~ ?| ?* ?< ?> ?= ?%))))

(This code uses the old rx-constituents mechanism, but the point applies 
equally to new-style definitions.)
More generally, there is currently no way to:

(1) Get the complement of a defined (any ...) form
(2) Get the union of two defined (any ...) forms
(3) Get the intersection of two defined (not (any ...)) forms

(1), which the example above was about, could be solved by expanding 
definitions inside 'not'. This is a step away from the principle that 
user-defined things are only allowed where general rx forms are, but perhaps 
tolerable. Proposed patch attached.

(2) can be solved by expanding definitions inside 'any', and allowing 'any' 
inside 'any' (flattening). Not sure I like this.

An alternative is to ensure that (or (any X) (any Y)) -> (any X Y), but then we 
either need to allow 'or' inside 'not', or add an intersection operator:

  (intersect (not (any X)) (not (any Y)) -> (not (any X Y))

We could also make 'not' variadic, turning it into complement-of-union:

  (not (any A) (any B)) -> (not (any A B))

Olin Shivers's SRE has a complete and closed set of operations on character 
sets (https://scsh.net/docu/post/sre.html). That would be principled and 
perhaps useful, but difficult to do fully in rx because not all such 
expressions can be rendered into Emacs regexps. Nothing prevents us from making 
a partial implementation, however.

Attachment: 0001-Expand-rx-definitions-inside-not.patch
Description: Binary data


--- End Message ---
--- Begin Message --- Subject: Re: bug#37849: composable character alternatives in rx Date: Fri, 13 Dec 2019 13:35:42 +0100
As suggested by Stefan Monnier, 'union' was replaced with plain 'or' for 
character sets as well.

A minor usability improvement has been pushed to master as well: characters and 
single-char strings no longer have to be wrapped in (any...), so (not (any ?a)) 
can now be written (not ?a).



--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]