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

 
 

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

Submitted by:  None
Submitted on:  Thu 18 Nov 2010 09:10:36 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Open

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission 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>
Project 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>
Project 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>
Project 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>
Project 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>
Project 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>
Project 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>
Project 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 File(s):
   
   
Comment:
   

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

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 11 Sep 2011 09:54:45 PM UTCtampeAttached File-=>Added sxml-match.ss.2.diff, #23968
    Mon 05 Sep 2011 01:40:03 PM UTCtampeAttached File-=>Added sxml-match.ss.diff, #23945
      Carbon-Copy-=>Added -unavailable-

    Back to the top


    Powered by Savane 3.1-cleanup