diff --git a/Makefile.am b/Makefile.am index 44377e867..024d8bd51 100644 --- a/Makefile.am +++ b/Makefile.am @@ -76,7 +76,8 @@ EXTRA_DIST += default.nix flake.nix flake.lock shell.nix build-aux/pkg.nix EXTRA_DIST += package.json # imported by both Nix and Docker EXTRA_DIST += $(MANUAL) $(FIGURES) EXTRA_DIST += src/embed.rs.in -EXTRA_DIST += sil.abnf +EXTRA_DIST += sil.abnf sil.ebnf build-aux/rfc-5234-core.abnf +EXTRA_DIST += sil.c sil.h sil.js sil.py BUILT_SOURCES = $(BUILT_LUA_SOURCES) Makefile-distfiles @@ -87,6 +88,23 @@ include $(top_srcdir)/build-aux/rust_boilerplate.mk Makefile-distfiles: $(wildcard .version .tarball-version) | $(LUAMODLOCK) $(SHELL) build-aux/list-dist-files.sh > $@ +BUILT_SOURCES += sil.ebnf +sil.ebnf: sil.abnf + $(EBNF_CONVERT) -f none $< | + $(SED) -E '1,2d;4,$$s/^([a-z])/\n\1/' > $@ + +BUILT_SOURCES += sil.c sil.h +sil.c sil.h: sil.abnf build-aux/rfc-5234-core.abnf + $(APG_C) -i <(cat $^) -o $(basename $@) + +BUILT_SOURCES += sil.js +sil.js: sil.abnf build-aux/rfc-5234-core.abnf + $(APG_JS) -i <(cat $^) -o $@ + +BUILT_SOURCES += sil.py +sil.py: sil.abnf build-aux/rfc-5234-core.abnf + $(APG_PY) -i <(cat $^) -o $@ + if EMBEDED_RESOURCES _EMBEDED_SOURCES = src/embed.rs src/embed-includes.rs nodist_sile_SOURCES = $(_EMBEDED_SOURCES) diff --git a/build-aux/rfc-5234-core.abnf b/build-aux/rfc-5234-core.abnf new file mode 100644 index 000000000..1d1a99b8d --- /dev/null +++ b/build-aux/rfc-5234-core.abnf @@ -0,0 +1,19 @@ +; Augmented BNF for Syntax Specifications: ABNF +; RFC-5234 Core Rules + +ALPHA = %x41-5A / %x61-7A +BIT = "0" / "1" +CHAR = %x01-7F +CR = %x0D +CRLF = CR LF +CTL = %x00-1F / %x7F +DIGIT = %x30-39 +DQUOTE = %x22 +HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F" +HTAB = %x09 +LF = %x0A +LWSP = *(WSP / CRLF WSP) +OCTET = %x00-FF +SP = %x20 +VCHAR = %x21-7E +WSP = SP / HTAB diff --git a/configure.ac b/configure.ac index 5d221d056..dd0ce5c54 100644 --- a/configure.ac +++ b/configure.ac @@ -211,12 +211,16 @@ AM_COND_IF([DEPENDENCY_CHECKS], [ ]) AM_COND_IF([DEVELOPER], [ + AX_PROGVAR([apg_c], [apg-c]) + AX_PROGVAR([apg_js], [apg-js]) + AX_PROGVAR([apg_py], [apg-py]) AX_PROGVAR([busted]) AX_PROGVAR([cmp]) AX_PROGVAR([curl]) AX_PROGVAR([delta]) AX_PROGVAR([diff]) AX_PROGVAR([docker]) + AX_PROGVAR([ebnf_convert], [ebnf-convert]) AX_PROGVAR([git]) AX_PROGVAR([grep]) AX_PROGVAR([head]) diff --git a/documentation/c03-input.sil b/documentation/c03-input.sil index 525a74c2c..0fd928fbc 100644 --- a/documentation/c03-input.sil +++ b/documentation/c03-input.sil @@ -234,8 +234,8 @@ However, in some cases the environment form of the command will be easier to rea The official grammar for the SIL flavor is the LPEG reference implementation. That being said the reference implementation has some idiosyncrasies and is not the easiest to read. -For convenience an ABNF grammar is also provided in the source tree, see \code{sil.abnf}. -This grammar does not completely express the language as it cannot express the way SIL can embed other syntaxes, but it is a decent approximation. +For convenience ABNF and EBNF format grammars are also provided in the source tree, see \code{sil.abnf} and \code{sil.ebnf}. +These grammars do not completely express the language as they cannot express the way SIL can embed other syntaxes, but it is a decent approximation. The intent behind many of the syntax choices is to make it easy to have parity with XML flavors. This means limiting commands to valid XML identifiers (e.g. starting with an ASCII letter, not a digit or special character), requiring a single top level command as the document, and so forth.