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

ABNF: silently chokes on dhall.abnf #51

Open
Profpatsch opened this issue Apr 26, 2021 · 5 comments
Open

ABNF: silently chokes on dhall.abnf #51

Profpatsch opened this issue Apr 26, 2021 · 5 comments

Comments

@Profpatsch
Copy link

https://github.com/dhall-lang/dhall-lang/blob/60629b9d198af49984e9f9da337036942147af8b/standard/dhall.abnf

This is the ABNF file for the dhall language, it might not be a fully spec-compliant abnf but when I feed it into kgt:

$ > kgt -l abnf -e svg <./dhall-lang/standard/dhall.abnf
[1]$

it silently exits with a status 1 without producing an error message or any output.

@Profpatsch
Copy link
Author

Same for e.g. -e html5, so it’s probably a parsing issue.

The svg example from the readme works just fine, so I’m reasonably certain I built the executable correctly:

$ result-bin/bin/kgt -l bnf -e svg < result-doc/share/doc/kgt/examples/expr.bnf > expr.svg
[0]$

@katef
Copy link
Owner

katef commented May 9, 2021

You're right that this is a parsing issue; it happens before we get to output. I think this may be the same bug as #11.


; ./build/bin/kgt -l abnf -e svg < examples/dhall.abnf 
112:17: Syntax error: expected production rule separator

line 112 is the valid-non-ascii = line:


; This rule matches all characters that are not:
; 
; * not ASCII
; * not part of a surrogate pair
; * not a "non-character"
valid-non-ascii =
      %x80-D7FF
    ; %xD800-DFFF = surrogate pairs
    / %xE000-FFFD
    ; %xFFFE-FFFF = non-characters
    / %x10000-1FFFD
    ; %x1FFFE-1FFFF = non-characters
    / %x20000-2FFFD

@katef
Copy link
Owner

katef commented May 9, 2021

the unicode character ranges in dhall.abnf are not implemented yet, either:

; echo 'x = %xF0000-FFFFD' | ./build/bin/kgt -l abnf                       
1:5: hex sequence %xF0000-FFFFD out of range: expected %x0..%xff inclusive
1:5: Syntax error

@katef
Copy link
Owner

katef commented May 9, 2021

the lack of error message is a bug. unfortunately I can't reproduce that! could you try to cut that down to a minimal test case please?

pragmatically, if you just want to render this file, I suggest:

  • removing the trailing comments (per ABNF: comments #11)
  • removing the productions with unicode escapes (sorry)
  • dos2unix (dhall.abnf has dos newlines)
  • add a newline after every production (this is required by the abnf spec, annoyingly). e.g. these ones are missing that:
simple-label-first-char = ALPHA / "_"
simple-label-next-char = ALPHANUM / "-" / "/" / "_"
simple-label = simple-label-first-char *simple-label-next-char

@Profpatsch
Copy link
Author

Cool! Thanks for the help. I can’t promise when I’ll come back to this, but maybe I find some time to try out your suggestions this weekend.

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

2 participants