megavlad
2019-6-14 00:08:19

@megavlad has joined the channel


lexi.lambda
2019-6-14 03:03:16

Not with list alone, but you can use (list* 'a 'b (list 'c 'd)) or (append (list 'a 'b) (list 'c 'd)).


lexi.lambda
2019-6-14 03:16:07

Well, with append, those would just be (append (list 'a 'b) (list 'c 'd) (list 'e 'f)). But you could also use flatten, if none of the subelements are lists.


krismicinski
2019-6-14 03:25:06

I have a kind of silly macro question. I am using @samth’s parser tools. I wanted to define a form that would help me wrap all of a parser’s productions with enclosing source information.

That library provides a parser form (https://docs.racket-lang.org/parser-tools/LALR_1__Parsers.html#%28form._%28%28lib._parser-tools%2Fyacc..rkt%29._parser%29%29). That form expects several clauses. One of those has to be a grammar form, specifying the grammar along with productions for each rule. I wanted to create a macro that would replace grammar and then match against each parser action and wrap it in a specific thunk that added source information. When I tried to do this, the library gave me back (predictably) an error that it expected a grammar form rather than my instrumented-grammar form. Is there a way I could get past this?


krismicinski
2019-6-14 03:25:53

I feel like maybe I could like elaborately treat the code that generates the parser as syntax and then like splice them together manually using quote-syntax and such..


lexi.lambda
2019-6-14 03:55:57

@krismicinski You might find this blog post I wrote a little while ago relevant: https://lexi-lambda.github.io/blog/2018/10/06/macroexpand-anywhere-with-local-apply-transformer/


lexi.lambda
2019-6-14 03:56:49

(I would not necessarily recommend literally using the expand-inside form defined in the blog post, but you might be able to reuse the same techniques.)


lexi.lambda
2019-6-14 03:57:39

Also, I don’t think parser-tools is Sam’s, fwiw.


krismicinski
2019-6-14 05:18:56

ah my mistake, it was his picture on github, but he’s probably mirroring


krismicinski
2019-6-14 05:19:12

@lexi.lambda thanks! Looks great


krismicinski
2019-6-14 05:20:04

wow, yes, this is great.