This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-26
Channels
- # announcements (1)
- # babashka (106)
- # beginners (11)
- # biff (7)
- # calva (16)
- # clj-kondo (40)
- # clj-on-windows (5)
- # clj-yaml (10)
- # clojars (4)
- # clojure (37)
- # clojure-austin (22)
- # clojure-australia (1)
- # clojure-europe (40)
- # clojure-nl (1)
- # clojure-norway (10)
- # clojure-spec (6)
- # clojure-uk (6)
- # clojurescript (13)
- # conjure (11)
- # cursive (14)
- # datalevin (8)
- # datascript (5)
- # emacs (39)
- # events (1)
- # fulcro (55)
- # gratitude (4)
- # holy-lambda (2)
- # humbleui (9)
- # instaparse (1)
- # lsp (3)
- # malli (12)
- # meander (2)
- # membrane (7)
- # nbb (1)
- # off-topic (16)
- # pathom (9)
- # releases (3)
- # sci (14)
- # shadow-cljs (25)
Hello, I have defined a grammar [1] to parse Java stacktrace with Instaparse. The grammar seems to work if I pass well formed input to it. What I would like to do next, is use the grammar to also parse input that has "garbage" at the beginning or the end of the input string. So I would go from something like this:
S = exception causes
exception = ...
causes = ...
to something like this:
S = <garbage?> exception causes <garbage?>
exception = ...
causes = ...
Now, the issue I am facing is how to define <garbage>
. I tried to define it as #[\s\S]*
but I believe it is too greedy and it messes up my grammar. For example, sometimes parsing succeeds with garbage, but most of the input is eaten by <garbage>
and not by my actual stacktrace grammar.
I'm staring to wonder if I actually should include the <garbage> into my grammar at all, or use some other functionality of Instaparse. I saw I can use insta/parses
to get access to all parses tried so far, but they are quite a lot, and I am not sure which one to pick (I guess it depends on my application).
How do you deal with garbage, or rules that are too greedy in Instaparse?
Thanks for your help.
[1] https://github.com/r0man/orchard/blob/stacktrace-at-point/resources/orchard/stacktrace/parser/java.bnf