5

How do you get instaparse to skip whitespace between tokens?

(I could of course define whitespace as a token in its own right and insert it between all the elements on the right hand side of every rule, but I'm dealing with a grammar that has over three hundred rules, and hoping for a way to say it once rather than three hundred times.)

rwallace
  • 31,405
  • 40
  • 123
  • 242

1 Answers1

9

You can pass an optional parameter to turn on auto-whitespace:

(doc insta/parser)
-------------------------
instaparse.core/parser
([grammar-specification & {:as options}])
   :auto-whitespace (:standard or :comma)
   or
   :auto-whitespace custom-whitespace-parser
Timothy Pratley
  • 10,586
  • 3
  • 34
  • 63