Fork me on GitHub
#instaparse
<
2021-04-23
>
Sigve06:04:27

If i understand correctly, :auto-whitespace :standard inserts <whitespace>? rules. So that for the parser

(def words-and-numbers-auto-whitespace
  (insta/parser
    "sentence = token+
     <token> = word | number
     word = #'[a-zA-Z]+'
     number = #'[0-9]+'"

    :auto-whitespace :standard))
(words-and-numbers-auto-whitespace "abc 123 45 de") and (words-and-numbers-auto-whitespace "abc123 45de") produces the same result. Is there any method of instead inserting non-optional whitespace rules, which in this case would disallow "abc123 45de"`?

sova-soars-the-sora19:04:38

@sigve.nordgaard the desired result is only letters and only numbers together in sequence? You could have tokens-numbers and tokens-letters and a sentence can be tokens-numbers+ | tokens-letters+

sova-soars-the-sora19:04:13

If I have understood the question. That would only allow contiguous digits or contiguous characters, not a mix