public inbox for
 help / color / mirror / Atom feed
From: Arvydas Silanskas <>
To: kawa mailing list <>
Subject: When/how during compilation are bindings attached?
Date: Sun, 15 Nov 2020 02:57:31 +0200	[thread overview]
Message-ID: <> (raw)

I'm working with tracking of definition place for identifiers. For some
reason, found identifiers don't have binding information attached, do you
have insight why that could be? Here is standalone snippet (mostly based on
LSP in kawa source tree)

import gnu.expr.Compilation;
import gnu.expr.ExpExpVisitor;
import gnu.expr.Expression;
import gnu.expr.ReferenceExp;
import gnu.text.SourceMessages;
import kawa.standard.Scheme;

import java.util.Arrays;

public class TestModuleBinding {

    public static void main(String[] args) throws IOException {
        var source = new String[]{
                "(define (a) 1)",
        var sourceCode ="\n"));
        int line = 2;
        int col = 2;
        var language = Scheme.getR7rsInstance();
        var inPort = CharArrayInPort.make(sourceCode);
        var sourceMessages = new SourceMessages();
        Compilation compilation = language.parse(inPort, sourceMessages,

        class FindDecl extends ExpExpVisitor<Void> {

            protected Expression visitReferenceExp(ReferenceExp exp, Void
ignored) {
                var expLine = exp.getLineNumber();
                var expCol = exp.getColumnNumber();
                if (line == expLine && col == expCol) {
                    if (!exp.getName().equals("a"))
                        throw new RuntimeException("Expected 'a'");
                    if (exp.getBinding() == null)
                        throw new RuntimeException("Expected non-null
                return super.visitReferenceExp(exp, ignored);
        FindDecl fd  = new FindDecl();
        var module = compilation.getModule();
        fd.visit(module, null);


             reply	other threads:[~2020-11-15  0:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-15  0:57 Arvydas Silanskas [this message]
2020-11-15  2:42 ` Per Bothner
2020-11-15  8:59   ` Arvydas Silanskas

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='' \ \ \

* 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).