bugGuile - Bugs: bug #31691, Ellipsis not supported in nested...

 
 

bug #31691: Ellipsis not supported in nested `sxml-match' forms [1.9.13]

Submitter:  None
Submitted:  Thu 18 Nov 2010 09:10:36 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sun 11 Sep 2011 09:54:45 PM UTC, comment #7: 

I suspect that this bug is a feature request.

Anyway I coded another solution which sematics is more exact.
The idea is to quote ... and each match will remove one of the quotes around .... So now this works,

(sxml-match '(a (b (c 1) (c 2 3)) (b (c 4)) (b (c 5)))
 ((a ,x ...)
    (list (sxml-match x
               ((b ,y '...)
                   (list (sxml-match y
                            ((c ,z ''...) z)) '...))) ...)))

$1 = (((1) (2 3)) ((4)) ((5)))

attached is a git diff of the code.

the bad thing with this code is that it's not possible to output
the '... symbol.

/Stefan

(file #23968)

Stefan Israelsson Tampe <tampe>
Group Member
Tue 06 Sep 2011 09:27:26 PM UTC, comment #6: 

Hmm, that seems a bit hackish.  :-)

(ice-9 match) has `___' as an alternate syntax for `...' in situations where the latter cannot be used.  Maybe we should just do that?

Ludovic Courtès <civodul>
Group administrator
Mon 05 Sep 2011 01:40:03 PM UTC, comment #5: 

Ok here is a patch if it encounters a form like
 x ... in the output part of sxml-match it will check if there exists an ellipsis variable inside x. If there doesn't exist any it will not try to expand the ellipsis, but instead keep it verbatrim.

So the subsequent matches must not use previous pattern
variables inside their patterns for this to work.

/Stefan

(file #23945)

Stefan Israelsson Tampe <tampe>
Group Member
Fri 02 Sep 2011 05:17:35 PM UTC, comment #4: 

It does sound like a useful feature.  Stefan, can you post the patch here?  Would you mind mailing it to Jim as well, to see what he thinks?

Thanks,

andy

Andy Wingo <wingo>
Group administrator
Fri 15 Jul 2011 11:36:22 AM UTC, comment #3: 

First, upstream doc's for sxml-match indicates that ellipsis
in the body is not allowed and then the the Bug would be moot
because the spec does not allow the example below.

On the other hand allowing the code below is a useful feature and
I have a patch that introduce this new feature. On the other hand
this means that guile code using sxml-match would not work on other platforms with the upstream version.

Best is possible to contact Jim Bender to include this as a feature.

The solution is to allow ellipsis in the body in the following way:
if we encounter (p ... . l) then p is investigated to see if there are any variables that comes from an ellipsis in the matcher. If we find that there exists such variables the ellipsis will not be used for expansion paths in the macro and it will be untouched.

Stefan Israelsson Tampe <tampe>
Group Member
Fri 19 Nov 2010 04:41:44 PM UTC, comment #2: 

I can't seem to find Jim's mail; perhaps Ludovic would be willing to take a look at it :)

Andy Wingo <wingo>
Group administrator
Fri 19 Nov 2010 04:28:48 PM UTC, comment #1: 

Yeah, I have no idea. Maybe Jim Bender would be interested in this one; I'll forward the message.

Andy Wingo <wingo>
Group administrator
Thu 18 Nov 2010 09:10:36 AM UTC, original submission:  

This fails:

#v+
scheme@(guile-user)> (sxml-match '(foo (bar 1 2 3)) ((foo ,x ...) (sxml-match (car x) ((bar ,y ...) y))))
While compiling expression:
ERROR: bad pattern syntax (symbol not allowed in this context)
Exception during displaying of error: misc-error
#v-

... whereas in non-nested position ellipsis obviously works:

#v+
scheme@(guile-user)> (define (match-bar x) (sxml-match x ((bar ,y ...) y)))
scheme@(guile-user)> (sxml-match '(foo (bar 1 2 3)) ((foo ,x ...) (sxml-match (car x) (,(match-bar -> y) y))))
$1 = (1 2 3)
#v-

Has to do with `...' not specified as a literal in the `sxml-match' macros...

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #23968:  sxml-match.ss.2.diff added by tampe (2KiB - text/x-patch)
file #23945:  sxml-match.ss.diff added by tampe (2KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by civodul (Posted a comment)
  • -email is unavailable- added by tampe (jim bender is the original author of sxml-match.ss)
  • -email is unavailable- added by tampe (Posted a comment)
  • -email is unavailable- added by wingo (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-09-11 tampe Attached File- Added sxml-match.ss.2.diff, #23968
    2011-09-05 tampe Attached File- Added sxml-match.ss.diff, #23945
        Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code