guile-user
[Top][All Lists]
Advanced

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

Re: lalr parser: on Bison-like source locations


From: Nala Ginrut
Subject: Re: lalr parser: on Bison-like source locations
Date: Tue, 28 Oct 2014 18:11:36 +0800

Thanks for reply!
I wonder if Guile master has updated to the latest lalr-scm, since I
can't see the expected result.
If the answer is no, I have to request for it, it's important for our
multi-lang hacking.

Thanks!

On Mon, Oct 27, 2014 at 4:11 AM, Jan Nieuwenhuizen <address@hidden> wrote:
> Hi,
>
> Saw your question on irc.
>
> Attached is a modification on your `simple' language that demonstrates
> transparent source locations.
>
> The explicit, Bison-like locations work just like they do in Bison...eg
> something like:
>
>     ;; helper
>     (define (note-location ast loc)
>       (when (supports-source-properties? ast)
>           (set-source-property! ast 'loc loc))
>       ast)
>
>   (define (make-parser)
>     (lalr-parser
>     ;; ...
>     ;; production rules
>     (variable
>      (type Identifier = expression semicolon) : `(variable ,$2 ,$1 
> ,(note-location `(expression ,$4) @3))
>      (Identifier dot Identifier Identifier = expression semicolon) : 
> `(variable ,$4 (type ,$3 ,$1) ,(note-location `(expression ,$6) @5)))
>
> Does that answer your question?
>
> Greetings, Jan
>
>
>
> --
> Jan Nieuwenhuizen <address@hidden> | GNU LilyPond http://lilypond.org
> Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl
>



reply via email to

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