Did you not enable line counting with port-count-lines! as instructed by the documentation:
"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." ? Jay 2011/5/24 Johnny Morrice <[email protected]>: > Hi list, > > I'm trying to build a lexer with lexer-src-pos from parser-tools/lex. > > I've written some unit tests which use pipes to provide an input port > to the lexer. > > My problem is that the lexer does not seem to report the correct > line numbers. Apparently, the line number is #f. > > I don't understand what I'm doing wrong. > > If I run this through racket v5.1.1: > > #lang racket > > (require parser-tools/lex) > > (define no-pos-lexer > (lexer-src-pos > [any-char lexeme])) > > (let-values ([(i o) (make-pipe)]) > (display "$" o) > (let* ([no-pos-token (no-pos-lexer i)] > [no-pos (position-token-start-pos no-pos-token)]) > (printf "Token ~a at line ~a, column ~a\n" > (position-token-token no-pos-token) > (position-line no-pos) > (position-col no-pos)))) > > It outputs: > Token $ at line #f, column #f > > But I would like it to output: > Token $ at line 1, column 1 > > Where am I going wrong? > > Thanks > Johnny > _________________________________________________ > For list-related administrative tasks: > http://lists.racket-lang.org/listinfo/users > -- Jay McCarthy <[email protected]> Assistant Professor / Brigham Young University http://faculty.cs.byu.edu/~jay "The glory of God is Intelligence" - D&C 93 _________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users

