Search code examples
racketinterpreterpostfix-notation

read-syntax function for postfix interpreter in racket


I write a read-syntax function but ı get this error. my read-syntax function is this:

(define (read-syntax path port)
  (for([line (port->lines port)])
    (parse-line line)))

The error is this:

Module Language: only a module expression is allowed, either
#lang <language-name>
or
(module <name> <language> ...)

Solution

  • Each racket file is a module.

    The file must start with defining the module.

    The easy starting way is to have

    #lang racket
    

    as the first line of your module.

    Description of this is in the Racket Guide https://docs.racket-lang.org/guide/intro.html