[Top][All Lists]

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

Nyacc question: where are the actions bound?

From: tomas
Subject: Nyacc question: where are the actions bound?
Date: Sun, 8 Mar 2020 11:14:45 +0100
User-agent: Mutt/1.5.21 (2010-09-15)


I'm playing around with Nyacc: I found a first little use case
to get my feet wet.

First of all, than you, Matt, for this impressive package.

Shamelessly stolen from the minimal example, playground looks
roughly like this:

#+begin_source scheme
  (use-modules (nyacc lalr))
  (use-modules (nyacc lex))
  (use-modules (nyacc parse))
  ;; to be used in some ($$ ...) actions:
  (define (collect arg) (display arg))
  (define my-grammar
     (start my-file)
      ;; more productions, calling out to ($$... collect)
  (define mach (make-lalr-machine aq-grammar))
  (define mtab (lalr-match-table mach))
  (define gen-lexer (make-lexer-generator mtab))
  (define raw-parse (make-lalr-parser mach))
  (define (parse) (raw-parse (gen-lexer)))

So I defined some function =collect= which will be called from
actions in the grammar.

My question is: where is the stuff resolved which is mentioned
in grammar actions? My first experiments indicate that it's
looked up at (module) top level, as if (grammar ...) greedily
weaved that in at compile time.

My idea would be to (pre-) define a grammar and to exchange
the actions later as needed. Or would I have to re-define the
grammar whenever I change my mind about actions?

Note that I'm still very much in exploratory mode: "you're
holding it wrong" would be a perfectly adequate answer, as
would be "your mumblings are pretty unintelligible" :-)

Cheers & thanks
-- tomás

Attachment: signature.asc
Description: Digital signature

reply via email to

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