instaparse

If you're not trampolining your parser, why bother getting up in the morning?
wistb 2017-04-03T20:49:14.936237Z

@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 >

wistb 2017-04-03T20:49:56.950845Z

and this is what I see at that location

wistb 2017-04-03T20:49:57.951333Z

uri-str = < a string that matches the rule > < URI in RFC 3986 >

aengelberg 2017-04-03T20:50:37.965820Z

&lt; a string that matches the rule &gt; isn't valid BNF. In that spec, it is used for prose that can only be understood by humans.

aengelberg 2017-04-03T20:51:01.974250Z

In Instaparse we use &lt;abc&gt; completely differently, used to refer to the "hidden" version of the non-terminal abc.

wistb 2017-04-03T21:00:01.169101Z

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)

wistb 2017-04-03T21:00:03.170365Z

CompilerException java.lang.RuntimeException: Error parsing grammar specification: Parse error at line 915, column 32: action-keyword = %s"action"

wistb 2017-04-03T21:00:28.180093Z

I think the ietf doc wants to use 'non case sensitive' form.

aengelberg 2017-04-03T21:24:53.657771Z

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.

aengelberg 2017-04-03T21:26:34.689382Z

If you're ok with case insensitive, you could just do "action"

wistb 2017-04-03T21:26:41.691357Z

@aengelberg for now, I removed %s and moved on. It is getting close to the end of the file, but, I have this error :

aengelberg 2017-04-03T21:26:46.692955Z

If you really want case sensitive, you could translate it to decimal or hex and use %d / %x

aengelberg 2017-04-03T21:26:58.696414Z

You're going to want :input-format :abnf if you haven't set that already btw

wistb 2017-04-03T21:28:41.727778Z

CompilerException java.lang.RuntimeException: a occurs on the right-hand side of your grammar, but not on the left,

wistb 2017-04-03T21:29:16.738141Z

I am invoking , like so,

wistb 2017-04-03T21:29:17.738418Z

(def my-parser (insta/parser (http://clojure.java.io/resource "my.abnf") :input-format :abnf :trace true))

wistb 2017-04-03T21:30:21.758481Z

But, this time, I don't know which particular text is the culprit.

aengelberg 2017-04-03T21:35:20.849012Z

hmm.

aengelberg 2017-04-03T21:35:32.852542Z

Only thing I can think of is there is a loose a or A somewhere...

aengelberg 2017-04-03T21:36:09.862964Z

Or it's one of the &lt; a string that matches the rule &gt;

aengelberg 2017-04-03T21:36:16.865435Z

and the a is the first of many invalid things in that expression.

wistb 2017-04-03T21:37:14.882067Z

Let me see. I removed those kind of usages. May be there is still something lurking ..

wistb 2017-04-03T21:41:32.956121Z

@aengelberg .. great . that is the issue. one such usage got left out. I changed it, now, that parsing is completing without error. Thank you.

aengelberg 2017-04-03T21:41:40.958275Z

sweet

aengelberg 2017-04-03T21:41:42.958798Z

np

wistb 2017-04-03T21:44:13.000564Z

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"

wistb 2017-04-03T21:45:05.015379Z

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.

aengelberg 2017-04-03T21:49:03.081736Z

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.

aengelberg 2017-04-03T21:49:14.084877Z

So they don't feel the need to exactly follow the ABNF spec.