[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lalr parser: on Bison-like source locations
From: |
Jan Nieuwenhuizen |
Subject: |
lalr parser: on Bison-like source locations |
Date: |
Sun, 26 Oct 2014 21:11:06 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
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
simple.scm
Description: Binary data
spec.scm
Description: Binary data
--
Jan Nieuwenhuizen <address@hidden> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.nl
- lalr parser: on Bison-like source locations,
Jan Nieuwenhuizen <=