unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Nyacc question: where are the actions bound?
@ 2020-03-08 10:14 tomas
  2020-03-08 15:10 ` Matt Wette
  2020-07-30 13:50 ` Nyacc question: " Matt Wette
  0 siblings, 2 replies; 10+ messages in thread
From: tomas @ 2020-03-08 10:14 UTC (permalink / raw)
  To: guile-user

[-- Attachment #1: Type: text/plain, Size: 1606 bytes --]

Hi,

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
    (lalr-spec
     (start my-file)
     (grammar
      (my-file
       (elt-list))
      ;; more productions, calling out to ($$... collect)
      (name
       ($ident)))))
  
  (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)))
  (parse)
#+end_source

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 #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-08-03 23:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-08 10:14 Nyacc question: where are the actions bound? tomas
2020-03-08 15:10 ` Matt Wette
2020-03-09  9:07   ` tomas
2020-03-14 11:59   ` Nyacc question: [found] " tomas
2020-03-14 14:31     ` Matt Wette
2020-03-14 15:47       ` tomas
2020-07-30 13:50 ` Nyacc question: " Matt Wette
2020-07-30 17:17   ` tomas
2020-08-03 20:42   ` tomas
2020-08-03 23:37     ` Matt Wette

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