# Parser-tools output position token's position only has offset?

**URL:** <https://racket.discourse.group/t/parser-tools-output-position-tokens-position-only-has-offset/625>\
**Category:** Questions & Answers\
**Created:** [January 26, 2022, 6:47am UTC](https://racket.discourse.group/t/parser-tools-output-position-tokens-position-only-has-offset/625 "2022-01-26T06:47:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dannypsnl](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/dannypsnl/32/917_2.png) [@dannypsnl](https://racket.discourse.group/u/dannypsnl)\
**Post date:** [January 26, 2022, 6:47am UTC](https://racket.discourse.group/t/parser-tools-output-position-tokens-position-only-has-offset/625/1 "2022-01-26T06:47:25Z")

</div>

I want to parse some s-expression with position information by `parser-tools`

```scheme
(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`

```scheme
(define f "test.ss")
(parameterize ([file-path f]
               [current-input-port (open-input-file f)])
  (define (next) (l (current-input-port)))
  (println (next)))

```

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [January 26, 2022, 8:01am UTC](https://racket.discourse.group/t/parser-tools-output-position-tokens-position-only-has-offset/625/2 "2022-01-26T08:01:07Z")

</div>

You need to enable line counting with `port-count-lines!`.

[https://docs.racket-lang.org/reference/linecol.html](https://docs.racket-lang.org/reference/linecol.html)

---

<div class="post-metadata">

**Author:** ![dannypsnl](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/dannypsnl/32/917_2.png) [@dannypsnl](https://racket.discourse.group/u/dannypsnl)\
**Post date:** [January 26, 2022, 9:25am UTC](https://racket.discourse.group/t/parser-tools-output-position-tokens-position-only-has-offset/625/3 "2022-01-26T09:25:44Z")

</div>

oh wow, this is an unexpected place......

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [January 26, 2022, 12:04pm UTC](https://racket.discourse.group/t/parser-tools-output-position-tokens-position-only-has-offset/625/4 "2022-01-26T12:04:24Z")

</div>

The documentation of `lexer` also mentions it, but it is easy to overlook since it's mentioned in the end  
of a long paragraph.

 ![image](https://global.discourse-cdn.com/free1/uploads/racket/original/1X/51be6e23da3eb9167f2868de93ca69e5e799dde4.png)
