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

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.

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.

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
.

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:

Anyway, hopefully the above info helps @wwall

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?

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

thanks

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

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.

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

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

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

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

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?