kgt icon indicating copy to clipboard operation
kgt copied to clipboard

ABNF: silently chokes on dhall.abnf

Open Profpatsch opened this issue 4 years ago • 5 comments

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 avatar Apr 26 '21 22:04 Profpatsch

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]$

Profpatsch avatar Apr 26 '21 22:04 Profpatsch

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 avatar May 09 '21 05:05 katef

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 avatar May 09 '21 05:05 katef

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

katef avatar May 09 '21 05:05 katef

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.

Profpatsch avatar May 14 '21 15:05 Profpatsch