katef / kgt

BNF wrangling and railroad diagrams
BSD 2-Clause "Simplified" License
584 stars 29 forks source link

ABNF: silently chokes on dhall.abnf #51

Open Profpatsch opened 3 years ago

Profpatsch commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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:

Profpatsch commented 3 years ago

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.