I want to parse some s-expression with position information by parser-tools
(require parser-tools/lex
(prefix-in : parser-tools/lex-sre))
(define-empty-tokens symbol
(|(| |)|))
(define-tokens datum
(ID
STR
NUM))
(define-empty-tokens end (EOF))
(define l
(lexer-src-pos
[(eof) (token-EOF)]
["(" (token-|(|)]
[")" (token-|)|)]
[(:+ alphabetic)
(token-ID lexeme)]
[(:seq "\"" (:* (:~ #\")) "\"")
(token-STR lexeme)]
[(:+ numeric)
(token-NUM lexeme)]
[whitespace (return-without-pos (l input-port))]))
But what I get from the following code only has offset
in position, line
and col
are #f
(define f "test.ss")
(parameterize ([file-path f]
[current-input-port (open-input-file f)])
(define (next) (l (current-input-port)))
(println (next)))