Package: cl-abnf Version: 20200229.gitba1fbb1-1 Forwarded: https://github.com/dimitri/cl-abnf/issues/7
I tried using the cl-abnf to verify a ABNF grammar, but it proved to not work. I got my artificial idiocy LLM to write up the details: # cl-abnf Bug: `range-sep` Rule Referenced But Never Defined ## Summary The `cl-abnf` library defines a `hex-range` rule that references `range-sep`, but `range-sep` is never defined in the library. This causes `parse-abnf-grammar` to fail with an undefined rule error when parsing any ABNF grammar. ## Environment - **Package**: cl-abnf - **Version**: 20200229.gitba1fbb1-1 (Debian) - **Upstream**: https://github.com/tapoueh/cl-abnf - **Author**: Dimitri Fontaine <[email protected]> ## Reproduction Load cl-abnf and attempt to parse any ABNF grammar: ```lisp (require 'asdf) (asdf:load-system :abnf) (use-package 'abnf) ;; This fails with an undefined rule error: (parse-abnf-grammar "rule = \"test\"" "rule" :junk-allowed nil) ``` ## Root Cause In `abnf.lisp` line 318, the `hex-range` rule references `range-sep`: ```lisp (defrule hex-range (and hexdigits range-sep hexdigits) ...) ``` However, `range-sep` is never defined anywhere in the library. The RFC 5234 ABNF specification defines `range-sep` as: ```abnf range-sep = "-" ``` This rule is part of the core ABNF syntax rules that `cl-abnf` should define internally for parsing ABNF grammars. ## Impact Any attempt to parse an ABNF grammar with `parse-abnf-grammar` will fail, as the library cannot resolve the `range-sep` reference. This effectively renders the library unusable for its intended purpose of parsing ABNF grammars. ## Workaround Define the missing rule before parsing any grammar: ```lisp (eval '(abnf:defrule range-sep "-" (:constant :range-sep))) ``` This must be evaluated in the `abnf` package before calling `parse-abnf-grammar`. ## Expected Behavior The library should define all core ABNF rules internally, including `range-sep`, so that `parse-abnf-grammar` works out of the box without requiring manual rule definitions. ## Suggested Fix Add the missing rule definition to `abnf.lisp`: ```lisp (defrule range-sep "-" (:constant :range-sep)) ``` This should be placed alongside the other core rules in the library. ## References - RFC 5234 Section 2.1: https://datatracker.ietf.org/doc/html/rfc5234#section-2.1 - cl-abnf repository: https://github.com/tapoueh/cl-abnf -- Happy hacking Petter Reinholdtsen

