如何在 Clojure Instaparse 中解析 > 字符?

How to parse > character in Clojure Instaparse?

我正在尝试解析 Clojure Instaparse 中的 > 字符。我试过 |>|\> 但解析器似乎无法识别其中任何一个。有人知道正确的语法吗?

您只需将它们作为字符串来处理。例如:

((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"]]