From: ludo@gnu.org (Ludovic Courtès)
To: Jan Nieuwenhuizen <janneke@gnu.org>
Cc: guile-devel@gnu.org
Subject: Re: Bison-like source locations in LALR-parser
Date: Wed, 13 Aug 2014 23:01:47 +0200 [thread overview]
Message-ID: <87y4us2jes.fsf@gnu.org> (raw)
In-Reply-To: <87d2c41803.fsf@drakenvlieg.flower> (Jan Nieuwenhuizen's message of "Wed, 13 Aug 2014 21:53:32 +0200")
Hi,
Jan Nieuwenhuizen <janneke@gnu.org> skribis:
> Ludovic Courtès writes:
>
>> I don’t think this is needed. Lexers are expected to use
>> ‘make-lexical-token’ and ‘make-source-location’ from (system base lalr)
>> to preserve source location information.
>
> I hope you're right...and that's what I tried, but I didn't get it
> working. Possibly I need to cook-up a small example.
>
> What I found was that, yes the LEXER has all it needs, but once you
> get to construction rules in the parser; say
>
> (interface-spec
> (interface Identifier lbrace type-list event-list optional-behaviour rbrace) : `(,$1 ,$2 ,$4 ,$5 ,$6))
>
> all it sees is the values, i.e. strings of the tokens that the lexer
> sees. The lexer cannot hand tokens to the parser, AFAICS.
Here’s an example:
http://git.savannah.gnu.org/cgit/guile-rpc.git/tree/modules/rpc/compiler/lexer.l
http://git.savannah.gnu.org/cgit/guile-rpc.git/tree/modules/Makefile.am#n58
http://git.savannah.gnu.org/cgit/guile-rpc.git/tree/modules/rpc/compiler/parser.scm#n101
Note that actually, the ‘location’ produced by Makefile.am does:
(make-lexical-token type (make-source-location ...)
(append value (list (vector line column))))
So the line/column info is also stored alongside the token’s value, and
then access from parser.scm with those cadr calls.
>> Besides, note that lalr.upstream.scm is a copy of the upstream lalr-scm,
>> hosted at <http://code.google.com/p/lalr-scm/>.
>
> Yes...that's looks quit dead. Isn't it? I can try though...
Well, that’s because it’s “finished.” :-)
But yeah, it’s worth trying. Dominique has been responsive and helpful
in the past.
Thanks,
Ludo’.
next prev parent reply other threads:[~2014-08-13 21:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-02 7:58 Bison-like source locations in LALR-parser Jan Nieuwenhuizen
2014-08-02 7:58 ` [PATCH 1/2] LALR-parser: provide bison-like location constructs @1 ... @n Jan Nieuwenhuizen
2014-08-02 7:58 ` [PATCH 2/2] LALR-parser: transparent source locations using source-proprerties Jan Nieuwenhuizen
2014-08-11 18:21 ` Bison-like source locations in LALR-parser Ludovic Courtès
2014-08-13 19:53 ` Jan Nieuwenhuizen
2014-08-13 21:01 ` Ludovic Courtès [this message]
2014-10-05 10:27 ` Bison-like source locations in LALR-parser -- upstream update Jan Nieuwenhuizen
2014-12-02 20:27 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y4us2jes.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=guile-devel@gnu.org \
--cc=janneke@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).