-
Notifications
You must be signed in to change notification settings - Fork 9
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
Parsing BNF? #15
Comments
Your EBNF uses angle brackets around production symbols (e.g.,
(The For reference, do you have a reference for an EBNF variant that includes the angle brackets around the symbols? |
I don't. I'm guessing they are BNF that people are trying to parse as EBNF. Does that make sense? |
The grammar uses too many extended features to be straight BNF (e.g., support for |
I'm running down a couple of more errors related to changes, but there are some issues with the EBNF example in any case:
The resulting parsed grammar is the following: (
(rule quoted_string (seq quote (plus (alt unescaped_char escaped_char)) quote))
(rule escaped_char (seq escape (alt '"' "/" "b" "f" "n" "r" "t" unicode escape)))
(rule escaped_literal (alt escaped_char (seq escape "`")))
(rule unescaped_char
(alt digit letter " " "!" "#" "$" "%" "&" "'" "(" ")" "*+" "," "-" "." "/"
":" ";" "<" ">" "?" "@" "[" "]" "^" "_" "`" "{" "|" "}" "~" ))
(rule unescaped_literal
(alt digit letter " " "!" "#" "$" "%" "&" "'" "(" ")" "*+" "," "-" "." "/"
":" ";" "<" ">" "?" "@" "[" "]" "^" "_" "{" "|" "}" "~" ))
(rule unicode (seq "u" digit digit digit digit))
(rule escape (seq "\\"))
(terminal digit (range "0-9"))
(rule letter (alt (range "A-Z") (range "a-z") "_"))
(rule quote (seq '"'))
(rule json_value
(alt json_array json_boolean json_null json_number json_object json_string))
(rule json_null (seq "null"))
(rule json_boolean (alt "true" "false"))
(rule json_number
(seq
(opt "-")
(alt "0" (seq (range "1-9") (star (range "0-9"))))
(opt (seq "." (plus (range "0-9"))))
(opt (seq "e" (alt "-" "+") (plus (range "0-9"))))) )
(rule json_array
(seq ws "[" (opt (seq ws json_value ws (star (seq "," ws json_value ws)))) "]" ws))
(rule json_object
(seq ws "{" ws (opt (seq member ws (star (seq "," ws member ws)))) "}" ws))
(rule json_string (seq quote (star (alt unescaped_literal escaped_literal)) quote))
(rule member (seq quoted_string ws ":" ws json_value))
(rule ws (star " "))) I'll have an update the the development branch tomorrow, and I'll ask you to check it for yourself before I release the gem. |
Please give the version of the gem on the develop branch a test to see if it solves your problems, and I'll release an update to the gem. (BTW, you're correct that the original BNF grammar used angle brackets around rule symbols, which EBNF does not. So, adding this capability provides greater compatibility. However, there is currently no provision for using this when serializing a grammar back to EBNF). |
Sorry, I don't have an easy way to test this right now as I went a different direction due to this blocker and I didn't want to rely on a quick fix from you. You can add that linked .ebnf as a test case if you wish. |
I have used it as a test case, but note the errors I reported in that file. |
I'm trying to parse the BNF/EBNF found here:
https://gist.githubusercontent.com/springcomp/e72d09e3a8f06e8d711751c3d1ee160e/raw/c58887a2f6c6f41de7a66a472e7c708fa6f64429/JSON.ebnf
It appears to parse fine with a BNF Playground website I found but I get the following error when I use the
ebnf
gem:Any tips?
The text was updated successfully, but these errors were encountered: