@aengelberg , I am trying instaparse against an IETF abnf (https://tools.ietf.org/html/rfc7950 ). I am getting the error Parse error at line 92, column 44: < URI in RFC 3986 >
and this is what I see at that location
uri-str = < a string that matches the rule > < URI in RFC 3986 >
< a string that matches the rule >
isn't valid BNF. In that spec, it is used for prose that can only be understood by humans.
In Instaparse we use <abc>
completely differently, used to refer to the "hidden" version of the non-terminal abc
.
thank you @aengelberg . I made a change and the parsing moved forward. Now, I am getting an error (in the last few pages of the grammar file, So, I am hoping the grammar is holding up well so far)
CompilerException java.lang.RuntimeException: Error parsing grammar specification: Parse error at line 915, column 32: action-keyword = %s"action"
I think the ietf doc wants to use 'non case sensitive' form.
I don't think %s
is valid ABNF per the spec, though I see what it's getting at, and it wouldn't be too hard to implement.
If you're ok with case insensitive, you could just do "action"
@aengelberg for now, I removed %s and moved on. It is getting close to the end of the file, but, I have this error :
If you really want case sensitive, you could translate it to decimal or hex and use %d
/ %x
You're going to want :input-format :abnf
if you haven't set that already btw
CompilerException java.lang.RuntimeException: a occurs on the right-hand side of your grammar, but not on the left,
I am invoking , like so,
(def my-parser (insta/parser (http://clojure.java.io/resource "my.abnf") :input-format :abnf :trace true))
But, this time, I don't know which particular text is the culprit.
hmm.
Only thing I can think of is there is a loose a
or A
somewhere...
Or it's one of the < a string that matches the rule >
and the a
is the first of many invalid things in that expression.
Let me see. I removed those kind of usages. May be there is still something lurking ..
@aengelberg .. great . that is the issue. one such usage got left out. I changed it, now, that parsing is completing without error. Thank you.
sweet
np
I am not sure about the change I made (I dont know much about grammars), though .. I changed the text from yang-version-arg-str = < a string that matches the rule > < yang-version-arg > to yang-version-arg-str = yang-version-arg yang-version-arg = "1.1"
if that is correct, I wonder why the ietf folks did not do the same. As it is , the ietf abnf is not parseable, right.
I think some grammars are written with the intention of helping humans to write programs, rather than to be fed to parser generators like Instaparse.
So they don't feel the need to exactly follow the ABNF spec.