guile-user
[Top][All Lists]
Advanced

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

Re: parse-tree-il rejects '(define ...)


From: Mark H Weaver
Subject: Re: parse-tree-il rejects '(define ...)
Date: Thu, 17 Sep 2015 22:36:57 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Matt Wette <address@hidden> writes:

> This is guile 2.0.11. 
>
> I think I’m following what is in the reference manual. 
>
> Any clue what the problem is? — Matt
>
> scheme@(guile-user)> (define t1 '(begin (define (toplevel x) 1)))
>
> scheme@(guile-user)> (parse-tree-il t1)
>
> ERROR: In procedure scm-error:
>
> ERROR: unrecognized tree-il (define (toplevel x) 1)

There are two problems here:

* You cannot have a bare '1' like that.  It must instead be (const 1).

* The second operand to 'define' should just be the symbol, not
  (toplevel <symbol>).  The manual was incorrect about this; it is now
  fixed in commit 4fd7ad6f85c0c83f4ba329c491838ade813beb8a.

So the example above should be: (begin (define x (const 1)))

More generally, to see what kind of syntax to pass to 'parse-tree-il',
use 'compile' to convert to tree-il and then 'unparse-tree-il', like
this:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> ,use (system base compile)
scheme@(guile-user)> ,use (language tree-il)
scheme@(guile-user)> (compile '(define x 1) #:from 'scheme #:to 'tree-il #:env 
(current-module))
$1 = #<tree-il (define x (const 1))>
scheme@(guile-user)> (unparse-tree-il $1)
$2 = (define x (const 1))
scheme@(guile-user)> (parse-tree-il $2)
$3 = #<tree-il (define x (const 1))>
--8<---------------cut here---------------end--------------->8---

      Mark



reply via email to

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