-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to turn off "NOT" statements generated during negative lookahead #116
Comments
Figured this out! I had forgotten to include whitespace inside the negative lookahead along with the reserved keywords. |
Sorry for the churn, but this option would still be nice. It is coming up in other situations and being able to turn off all the reserved keyword spam would be really nice. |
Can you show me an example of the verbose error messages you're seeing, just so I can get a better sense for what you're dealing with? Thanks. |
A contrived example: (ns example
(:refer-clojure :exclude [cat])
(:require [instaparse.core :as insta]
[instaparse.combinators :refer :all]))
(def s "abcdef")
(def grammar
{:word (cat (neg (nt :forbidden)) (regexp "[a-z]+"))
:forbidden (->> (for [i s j s] (str i j))
(map string)
(apply alt))})
(def parse
(insta/parser grammar :start :word)) And the weird error message. It's pretty long and the ordering of the lines don't quite make sense to me either. =>(parser "ab")
Parse error at line 1, column 1:
ab
^
Expected one of:
"ff"
"fe"
"fd"
"fc"
"fb"
"fa"
"ef"
"ee"
"ed"
"ec"
"eb"
"ea"
"df"
"de"
"dd"
"dc"
"db"
"da"
"cf"
"ce"
"cd"
"cc"
"cb"
"ca"
"bf"
"be"
"bd"
"bc"
"bb"
"ba"
"af"
"ae"
"ad"
"ac"
NOT forbidden
"aa" |
OK, thanks for the explanation. The reason why it prints this way is fairly subtle, but I understand what is going on. It's not a trivial fix, but next time I have an opportunity to work on instaparse, my plan is to overhaul the way that negative lookahead is processed, and when I do, this problem will go away. |
Thank you! |
I have a grammar with about 50 reserved keywords. Sometimes when I get a parse error now, I get an error message that I have to scroll up 50 lines of reserved keywords to understand. Is there a way of turning off the NOT part of the parse error message?
The text was updated successfully, but these errors were encountered: