# Example of a lang lexer that returns a \`dont-stop\` struct?

**URL:** https://racket.discourse.group/t/example-of-a-lang-lexer-that-returns-a-dont-stop-struct/438
**Category:** Questions & Answers
**Created:** [December 17, 2021, 4:52pm UTC](https://racket.discourse.group/t/example-of-a-lang-lexer-that-returns-a-dont-stop-struct/438 "2021-12-17T16:52:50Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![greghendershott](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/greghendershott/32/98_2.png) [@greghendershott](https://racket.discourse.group/u/greghendershott)
#### Post date: [December 17, 2021, 4:52pm UTC](https://racket.discourse.group/t/example-of-a-lang-lexer-that-returns-a-dont-stop-struct/438/1 "2021-12-17T16:52:50Z")

</div>

A lang's [module lexer can return a `dont-stop` `struct`](https://docs.racket-lang.org/syntax-color/index.html#%28def._%28%28lib._syntax-color%2Flexer-contract..rkt%29._dont-stop%29%29).

I would like to test my handling of that. But so far (with e.g. langs `racket`, `rhombus`, and `scribble/manual`) I'm never seeing a `dont-stop`.

1. What's an example of such a `#lang`?
2. What's some minimal example program in that `#lang` eliciting the `dont-stop` value?

---

<div class="post-metadata">

### Author: ![mflatt](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/mflatt/32/6_2.png) [@mflatt](https://racket.discourse.group/u/mflatt)
#### Post date: [August 10, 2023, 4:06pm UTC](https://racket.discourse.group/t/example-of-a-lang-lexer-that-returns-a-dont-stop-struct/438/2 "2023-08-10T16:06:45Z")

</div>

I don't know whether this question is still relevant, but here's a small example using the shrubbery lexer:

```scheme
(require shrubbery/syntax-color)
(define in (open-input-string "@/{}")) ;; extra "/" would change "@" treatment
(shrubbery-lexer in 0 #f)
;; last result is `(dont-stop '#s(pending-backup-mode 1 initial))

```

The shrubbery lexer produces backup and `dont-stop` information somewhat defensively, I think, so it's not the best example of when backup and `dont-stop` are needed. But in the case above, I'm pretty sure `dont-stop` and backup really are needed.

---

<div class="post-metadata">

### Author: ![greghendershott](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/greghendershott/32/98_2.png) [@greghendershott](https://racket.discourse.group/u/greghendershott)
#### Post date: [August 11, 2023, 8:26pm UTC](https://racket.discourse.group/t/example-of-a-lang-lexer-that-returns-a-dont-stop-struct/438/3 "2023-08-11T20:26:36Z")

</div>

Thanks for the example.

I'd need to reload my brain both wrt the color-lexer details as well as rhombus, so meanwhile if I may ask a dumb surface-level question:

In something like

```scheme
#lang rhombus
@/{}

```

would you expect the `@` to be tokenized as "at", `/` as "operator", and `{}` as "parenthesis", and colored as such in an editor?

Whereas in

```scheme
#lang rhombus
@//{}

```

that's an s-expression comment, with `@//` as "comment", and `{}` as "parenthesis" with a comment flag (e.g. draw in paren color but dim/faded)?

* * *

(That's what I'm seeing on my `hash-lang` branch and using its `racket-hash-lang-mode` in Emacs.

Of course, even if that's the desired end-user behavior, that doesn't necessarily mean I'm handling `dont-stop` optimally. IIRC I was also erring on the side of being defensive. So, someday when I have time to reload my brain, I'll dig into this again.)

* * *

p.s. Token types `at` and `operator` seem new since I last looked at the color-lexer docs. Last I looked, this seemed documented as a fixed set. Maybe now it's changed to an open-ended set, and the user just maps these in their tool -- if so, that makes sense, and I can handle that accordingly.

---

<div class="post-metadata">

### Author: ![greghendershott](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/greghendershott/32/98_2.png) [@greghendershott](https://racket.discourse.group/u/greghendershott)
#### Post date: [August 13, 2023, 2:26pm UTC](https://racket.discourse.group/t/example-of-a-lang-lexer-that-returns-a-dont-stop-struct/438/4 "2023-08-13T14:26:02Z")

</div>

> [@greghendershott](#):
>
> p.s. Token types `at` and `operator` seem new since I last looked at the color-lexer docs. Last I looked, this seemed documented as a fixed set. Maybe now it's changed to an open-ended set, and the user just maps these in their tool -- if so, that makes sense, and I can handle that accordingly.

I was recalling [the docs for `racket-lexer`](https://docs.racket-lang.org/syntax-color/Racket_Lexer.html). But other lexers can return a symbol from a different set -- and in fact it can now be a hash-table to allow expressing token type as well as other attributes like "comment?".

So it's open; always has been.

---

<div class="post-metadata">

### Author: ![mflatt](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/mflatt/32/6_2.png) [@mflatt](https://racket.discourse.group/u/mflatt)
#### Post date: [August 18, 2023, 12:39pm UTC](https://racket.discourse.group/t/example-of-a-lang-lexer-that-returns-a-dont-stop-struct/438/5 "2023-08-18T12:39:43Z")

</div>

Just to confirm, shrubbery `@/{}` should be tokenized as "at" then "operator" then "parenthesis", while `@//{}` is indeed "comment" plus "parentheses" with a comment flag. And, yes, my understanding is that the set of type symbols is open, while some symbols are specifically recognized by `color:text%`.
