problems in free-identifier=? while running r6rs-infix

Create issue
Issue #34 wontfix
Former user created an issue

Ciao,

I am trying to make R6RS Infix run under Sagittarius 0.5.3 on a x84_64-unknown-linux-gnu. The package includes .sagittarius.sls libraries. After package configuration, running "make srun" will run "sash" with a system environment that allows loading the uninstalled libraries with "(import (infix pratt))" and "(import (infix lalr)".

Basically the package works, only some tests (marked by comments in "tests/infix-test/tests.sls") do not work; for example:

(infix 'a eq? 'a)

Specifically, all the tests for which the parser (in the function "flatten") has to compare the identifiers QUOTE, QUASIQUOTE, etc from the input form with the same imported in the library environment fail; the failing code is:

    (define (flatten stx synner)
      ;;Given a syntax object STX representing an input expression: decompose it into
      ;;a flat  list of  raw tokens  and return the  list holding  the raw  tokens in
      ;;reverse  order.  We  expect the  list  to contain:  atoms as  defined by  the
      ;;function  ATOM?;   identifiers;  the   characters  open   parenthesis,  close
      ;;parenthesis and comma.
      ;;
      (syntax-case stx (begin quote quasiquote syntax quasisyntax unquote)
    (() '())
    ((quote . ?stuff)
     stx)
    ((quasiquote . ?stuff)
     stx)
    ((syntax . ?stuff)
     stx)
    ((quasisyntax . ?stuff)
     stx)
    ((unquote . ?stuff)
     (append (flatten #'?stuff synner)
         (list #\,)))
    ((begin . ?stuff)
     stx)

these SYNTAX-CASE clauses fail to match the literal identifiers.

Comments (6)

  1. Takashi Kato repo owner

    Thank you for reporting.

    I've checked the r6rs-infix and my conclusion is that it may be a bug of r6rs-infix library. The library expects, I think, out of R6RS scope behaviour. As far as I've checked the expression you mentioned needs to be parsed as following by tokenise procedure after flatten;

    ;; Checked with Ypsilon and Chez. The result is from Ypsilon
    (LPAREN . ()
    (NUM . #<syntax (#<syntax quote> #<syntax a>)>)
    (EQ . #<syntax eq?>)
    (NUM . #<syntax (#<syntax quote> #<syntax a>)>)
    (RPAREN . ))
    

    However, the tokenise procedure expects 'a to be parsed as a non identifier. I believe R6RS doesn't specify this and if a implementation uses Andre van Tonder's expander, e.g. nmosh, then it would fail. (Actually, it failed on nmosh as well with the same reason.)

    I am planning to change macro expander in near future to be more compliant with R6RS. In that change this may be resolved.

  2. Marco Maggi

    You are right, I have misdiagnosed the problem which is this: syntax objects can be both wrapped and unwrapped; when #'(quote a) is fully unwrapped it is a list. Indeed this is an error in Infix, which I have fixed now.

  3. Takashi Kato repo owner

    Currently Sagittarius' macro system is as good as R6RS compliant. So changing its style, like psyntax, won't be needed for now.

  4. Log in to comment