wwall
2021-5-27 13:52:58

Hello. Can anybody help me? i need help with define-syntax code here https://pastebin.com/tPjjPRxY

i need macros which convert (define bsl-lang1 [lexer-src-pos (lex-Keyword ("И" "And" and )) ]) into (define bsl-lang1 [lexer-src-pos [(lex-ci "И") (token-ANDlexeme (string=? lexeme "И") 'Ru)] [(lex-ci "And") (token-AND lexeme (string=? lexeme "And") 'En)] ])


massung
2021-5-27 14:00:53

Well, the real tricky part is the final language symbol. It’s not located anywhere in the input but the macro is somehow supposed to know what language each string is.


massung
2021-5-27 14:07:32

Assuming you can change it around a bit, something like this might get you going a bit: (define-syntax (lex-keyword stx) (syntax-case stx () [(_ predicate (grapheme lang) ...) #'([(lex-ci grapheme) (predicate lexeme (string=? lexeme grapheme) lang)] ...)])) (lex-keyword token-AND ("И" 'Ru) ("And" 'En)) I don’t know if the last and symbol in your example is supposed to turn into token-AND or if it’s used for something else, so replaced it with predicate at the start so ... could be used into the syntax case match.


sorawee
2021-5-27 14:09:16

Since lexer-src-pos is a macro and it won’t cooperate with your lex-Keyword, I think you need to also define your own lexer-src-pos.


massung
2021-5-27 14:10:46

Not quite sure how that works since lexer-src-pos is an output of itself, unless it handles multiple input cases very carefully :slightly_smiling_face:


massung
2021-5-27 14:11:16

Anyway, hopefully the above info helps @wwall


massung
2021-5-27 19:06:01

I’m trying to use browser/external for the send-url function, which is fine on my local machine, but when I try to use it on my EC2 instance it dies because libcairo, etc. are not installed.

I’m basically building a tool where it can used used as a CLI and one of the options is to serve a website, in which case I don’t need the send-url function, but otherwise I do. Not sure how to get around this?


samth
2021-5-27 19:19:57

I think you want to use net/sendurl instead of browser/external


massung
2021-5-27 19:21:05

thanks


capfredf
2021-5-27 21:24:24

@robby I am wondering if the way that the contract system treats prefab structures should be more or less the same as how TR does: (module untyped1 racket (provide (contract-out (struct foo ([i number?])))) (struct foo (i) #:prefab)) (module untyped2 racket (require (submod ".." untyped1)) (foo 10) (foo "hi") ;; contract violation expected: number? given: "hi" (foo-i #s(foo "hi")) ;; foo-i: broke its own contract ) (module typed typed/racket (struct foo ([i : Number]) #:prefab) (foo 10) (foo "hi") ;; Type Error: Expected: Number, Given: String (foo-i #s(foo "hi")) ;; type checks, because foo-i is a (All (X) (-> (Prefab foo X) X)) ) (require 'untyped2) (require 'typed)


philip.mcgrath
2021-5-27 21:26:48

You could also do something like (lazy-*require* [browser/external (send-url)]). I do exactly this in the command that starts the http://digitalricoeur.org\|digitalricoeur.org server.


robby
2021-5-27 22:33:02

I think you’re saying that, in the case that foo is bound via a #:prefab struct declaration that the contract-out declaration shouldn’t introduce foo-i like this: (contract-out [foo-i (-> foo? number?)]) but instead like this: (contract-out [foo-i (-> foo? any/c)]) If I’m getting that right, I’m not sure that that would be an improvement, even leaving aside the backwards compatibility issues. (I’m not generally up to date in general; please @ me if I miss a reply and my apologies in advance.)


massung
2021-5-27 22:33:27

learn somethign new every day! that’s a nice tip!


hazel
2021-5-27 23:00:08

I mean I’m not asking for the hash itself to be sorted, I’m asking for the resulting sequence to be sorted


notjack
2021-5-28 01:44:08

there isn’t much difference, functionally, if you’re trying to avoid sorting the keys yourself first with a separate sort expression


robbert.gurdeepsingh
2021-5-28 06:16:16

I’d like to combine racklog with redex, but for that I need to call (%which (a b c d) (%= term1 term2))) where term1 and term2 are calcualted and a b c d is a calculated list of varaibles derived from term1 and term2 , what is the best way to do this?