I'm a relative Racket newbie, and I've just enjoyed *Beautiful Racket*. I am working on a Racket implementation of a simple assembler (for the Hack VM in the NAND2Tetris course).
I have a partial implementation up and running using #lang lines. I would like to add a more traditional command-line interface, so I can (eventually) say: hackasm foo.asm on a file without a #lang line. My code is available at https://github.com/rrthomas/hackasm Here's the nub of the problem: I can't work out how to call the language evaluator "manually". I have implemented the language as a dialect, so that the "main.rkt" module is "free" to be used for the command-line interface. (Perhaps this can be fixed too, that would be nice!) A typical assembler file might start like this: #lang hackasm/asm @2 D=A @3 When I run this file (e.g. in DrRacket), I get some output as expected: 0000000000000010 1110110000010000 0000000000000011 (The assembler outputs ASCII-encoded binary!) The contents of my main.rkt looks like this: #lang br/quicklang (require "parser.rkt" "tokenizer.rkt" (submod "asm.rkt" reader)) (module+ main (require racket/cmdline) (let ((filename (command-line #:program "hackasm" ; #:args (filename) filename))) (read-syntax filename (open-input-file filename)))) So far, all I've worked out how to do is run the language's read-syntax function (imported from parser.rkt), and thereby return the parsed syntax object as the result. What I'd like to do is call the evaluator on the parse tree, but after a lot of scratching my head over the Racket documentation and search results, I cannot work out how to do that. I presume the code should look something like: (eval (??? (read-syntax filename (open-input-file filename)))) where in the end I'm eval-ing a form, and where ??? represents something that turns the syntax object into a runnable module. Apologies for the length of this post (I was unsure how I could make it shorter), and thanks in advance for any help! -- https://rrt.sc3d.org -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CAOnWdohy31fHyvUd9rbY8tZFLJKUpevgnZ8jPH2-5_QtSFm%2BhA%40mail.gmail.com.

