yazz.com
yazz.com

Reputation: 58806

How to parse > character in Clojure Instaparse?

I am trying to parse the > character in Clojure Instaparse. I have tried |> and |\> but the parser doesn't seem to recognize any of these. Does anyone know the correct syntax?

Upvotes: 1

Views: 163

Answers (1)

cfrick
cfrick

Reputation: 37063

You would just handle them as strings. E.g.:

((insta/parser 
   "S = '<' tag '>'
   tag = #'\\w+'
   ") "<html>")
; [:S "<" [:tag "html"] ">"]

In instaparse, you can use angle brackets <> to hide parsed elements, suppressing them from the tree output.

((insta/parser 
   "S = <'<'> tag <'>'>
   tag = #'\\w+'
   ")  "<html>")
; [:S [:tag "html"]]

Upvotes: 5

Related Questions