Skip to content
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

* before #156

Closed
Pitometsu opened this issue Mar 11, 2017 · 8 comments
Closed

* before #156

Pitometsu opened this issue Mar 11, 2017 · 8 comments

Comments

@Pitometsu
Copy link

BNF from RFC https://www.ietf.org/rfc/rfc2396.txt throw lot of errors.

@arrdem
Copy link

arrdem commented Mar 11, 2017

Yeah, Instaparse doesn't support this RFC's strange leading n*.... notation for N or more repetitions. The traditional notation for this would be ....{n,}. It actually doesn't look like Instaparse supports that either. Skimming the RFC however it looks like most of the leading * notation could be refactored using *? or +?.

@Pitometsu
Copy link
Author

Yes, I replaced *() by ()* and 1*() by ()+. I hope, it's correct. Just put it here in case you want to add that notation as well.

@Engelberg
Copy link
Owner

Engelberg commented Mar 11, 2017 via email

@Pitometsu
Copy link
Author

Pitometsu commented Mar 14, 2017

But with :input-format :abnf I have error with that bnf from rfc:

   Error parsing grammar specification: Parse error at line 1, column 31:
   URI-reference = [ absoluteURI | relativeURI ] [ '#' fragment ] ^ Expected one
   of: ] / #"#\"[^\"\\]*(?:\\.[^\"\\]*)*\"(?x) #Double-quoted regexp"
   #"#'[^'\\]*(?:\\.[^'\\]*)*'(?x) #Single-quoted regexp" !  & % ' " [ < (
   #"[a-zA-Z][-a-zA-Z0-9]*(?x) #identifier" * #"[0-9]"

I there type in rfc abnf?

@Engelberg
Copy link
Owner

ABNF doesn't support the | character, which is in the grammar.

There are a lot of subtle variations in grammars, and I think the problems you are running into stem from the fact that this particular spec uses a hybrid of notations from EBNF and ABNF.

If you're looking for ABNF for URI, you might get farther with this as your starting point:
https://tools.ietf.org/html/rfc3986#page-49

@Engelberg
Copy link
Owner

Actually, there's already a tested URI spec in the test/data directory of instaparse.

@Engelberg
Copy link
Owner

If you're working on ABNF extensively, see issue #136

As one user pointed out, a lot of ABNF grammars are actually ambiguous and assume left-to-right processing, but instaparse process alternatives right-to-left. I'll likely be changing this in the next major point release of instaparse for better handling of these grammars that make this assumption.

@Pitometsu
Copy link
Author

@Engelberg thanks a lot for suggestions. So, closing the issue for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants