Providing source annotated expressions to psyntax

Asked by leppie on 2007-12-20

Hi

I have been following the recent changes you have brought to Ikarus to provide source annotated expressions to the expander. Having looked through the source, the only thing on psyntax's side is the no-source macro in the expander.

I would like to know, if it is possible already, how to provide this info to the expander.

Thanks

leppie

Question information

Language:
English Edit question
Status:
Solved
For:
r6rs-libraries Edit question
Assignee:
No assignee Edit question
Solved by:
leppie
Solved:
2007-12-23
Last query:
2007-12-23
Last reply:
2007-12-23
leppie (leppie) said : #1

OK, I see there is quite a lot of changes in the expander. I will try work out the annotation 'stubs' in compat.ss.

Abdulaziz Ghuloum (aghuloum) said : #2

The current psyntax from the Ikarus source consumes the source
annotations to produce better error messages. However, it does not
yet propagate that information down to the generated code (e.g. the
various build-* functions). This will come once I figure out how to
get Ikarus (the compiler) to deal with them.

To make use of this functionality, your reader should produce fully
annotated expressions. Well, what does that mean?

Think about an annotated expression as a record with three fields: as
expression, source information, and a stripped expression.

* The expression field is an s-expression whose subparts may
themselves be annotations.
* The source information field is currently a pair of file-name and
character-position (will be abstracted further later).
* The stripped expression field is a raw s-expression with no
annotations whatsoever.

For example, a symbol foo found in character 213 of file t.ss might
be represented as:
   #[annotation foo (213 . "t.ss") foo]
A symbol bar in character 217 of t.ss would be
   #[annotation bar (217 . "t.ss") bar]
And the list (foo bar) starting from position 212 of the same file
might be represented as:
   #[annotation (#[annotation foo (213 . "t.ss") foo] #[annotation
bar (217 . "t.ss") bar]) (212 . "t.ss") (foo bar)]

The primitives you need to supply are basically the predicate
annotation?, and the three accessor functions annotation-stripped,
annotation-source, and annotation-expression. These procedures are
currently exported in the (ikarus) library so you can experiment with
them along with the read-annotated procedure (just like read, but
returns an annotation struct).

If you don't want to use the annotations facility for now, you can
just let annotation? return #f for all input and the other functions
will never be called by the expander.

Hope this helps.

Aziz,,,

leppie (leppie) said : #3

> If you don't want to use the annotations facility for now, you can
> just let annotation? return #f for all input and the other functions
> will never be called by the expander.

Almost correct, it seems the library manager calls read-annotated, but it is sufficient to define it as 'read'.

Now to figure it out :)

Thanks

leppie

PS: Keeping this open till I can add some useful implementation information (if needed).

leppie (leppie) said : #4

I have given up for now, as I cannot seem to reliably bind these for the bootstrap as I want to deal with these internally.

Not sure if I am just being daft :).

Abdulaziz Ghuloum (aghuloum) said : #5

On Dec 22, 2007, at 5:06 AM, leppie wrote:

> I have given up for now, as I cannot seem to reliably bind these
> for the
> bootstrap as I want to deal with these internally.

Sorry. I didn't understand what you mean by that sentence.

leppie (leppie) said : #6

I am not sure how to explain. But I will try.

1. Created the stubs, so we dont use it. Run the buildscript (mine is based on the psyntax one, just extended). All works, great.
2. Now modify the stubs to use internal functions (these make use of other predefined internal exposed procs). Run buildscript. All works, great.
3. Now run the buildscript again, and the library manager insists that the internal procedures should be in a file, and it cannot be found. Ungreat.

Any other internals I add that is not required by the build itself, works 100%.

Like I said, maybe I am just being daft (this was at about 4am), I will give it another shot.

leppie (leppie) said : #7

OK, I tried a slightly different way, and now it seems to be working fine.

leppie (leppie) said : #8

OK got it working and it reports correctly :)

IronScheme 1.0.0.0 http://www.codeplex.com/IronScheme Copyright (c) leppie 2007 - R6RS mode - Debug build
> (load "wip.ss")
&who: define
&message: invalid syntax
&syntax: (define foooop)
&source-information: (5,1) - (5,16) wip.ss

Thanks a lot!

Abdulaziz Ghuloum (aghuloum) said : #9

On Dec 23, 2007, at 2:12 PM, leppie wrote:

> IronScheme 1.0.0.0 http://www.codeplex.com/IronScheme Copyright (c)
> leppie 2007 - R6RS mode - Debug build
>> (load "wip.ss")
> &who: define
> &message: invalid syntax
> &syntax: (define foooop)
> &source-information: (5,1) - (5,16) wip.ss
>
> Thanks a lot!

Wow! That does look like it works. :-)
Keep up the good work. You're my only customer as far as I can tell.