Problems about parser-tools/lex

I've been writing a parser for a compiler and wish to trace the generated syntax objects' source locations. The documentation told me to simply replace lexer with lexer-src-pos. Doing so does make the procedure produce position-token, but all the line and col fields of positions are set to #f. I've also tried an example distributed with parser-tools package: calc. The results are the same:

<pkgs>/parser-tools-lib/parser-tools/examples/calc> (calcl (open-input-string "1"))
(position-token (token 'NUM 1) (position 1 #f #f) (position 2 #f #f))
<pkgs>/parser-tools-lib/parser-tools/examples/calc>

What should I do to let it count lines automatically?

It sounds like your port doesn’t have line/column counting. Have you tried using port-count-lines! on it?

Following is from the documentation of lexer:

Since the lexer gets its source information from the port, use port-count-lines! to enable the tracking of line and column information. Otherwise, the line and column information will return #f.

Yes, it was the problem. Thanks for your timely reply.