This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-09
Channels
- # announcements (14)
- # architecture (42)
- # babashka (23)
- # beginners (37)
- # biff (8)
- # calva (2)
- # cider (3)
- # clara (42)
- # clerk (14)
- # clojure (55)
- # clojure-brasil (3)
- # clojure-dev (5)
- # clojure-europe (18)
- # clojure-hungary (88)
- # clojure-losangeles (3)
- # clojure-nl (1)
- # clojure-norway (66)
- # clojure-uk (9)
- # clojurescript (16)
- # core-logic (16)
- # datomic (6)
- # fulcro (32)
- # hyperfiddle (25)
- # instaparse (12)
- # joyride (2)
- # lsp (13)
- # malli (15)
- # off-topic (50)
- # polylith (11)
- # portal (3)
- # re-frame (2)
- # reitit (2)
- # sci (8)
- # shadow-cljs (16)
- # tools-deps (13)
- # xtdb (5)
Hi, I’m having a weird issue with instaparse. I’ve written a grammar using EBNF. When parsing moderately long (~200 lines) documents using that grammar, if the document has an error then Instaparse will go into an infinite loop, but only if the document uses DOS line endings. Huh? If the document uses UNIX line endings, then Instaparse reports the error.
EOL is part of the syntax of the grammar, and I have defined a terminal ('\r\n' | '\n' | '\r' | #"$")
.
There’s got to be something wrong with my grammar, and I want to fix that. But, it seems odd that I’m able to drop Instaparse into an infinite loop with only changing the line endings.
Anyone have any ideas where I should start to look to produce a simpler test case? Thanks 🙏
So it infinite loops if the input has \r\n
?
Not exactly. Infinite loops if the document has \r\n
and the document otherwise has a parse error.
I think #"$"
might be dicey because it will detect the end of a line, not consume it (because it parses zero characters), meaning you could parse infinite empty lines in a row
Ahhh… I’m trying to match end of input as the same as an end of line
Also, $ detects the end of a line, not the end of the file
\z
instead?
Yeah, that seems closer to what you want
Thanks! I’ll give it a try. And see if I can produce something to repro the infinite loop with that and without that change
I'd still be a little concerned at the potential for matching infinite EOF's
OK. I see what you mean. I’ll have a think about a different way of expressing this
It's possible you don't need to explicitly match on EOF, because instaparse will only consider a parse valid if it consumes the whole string