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

Ebnf & parser stuff #1978

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down
19 changes: 19 additions & 0 deletions build-aux/rfc-5234-core.abnf
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
4 changes: 2 additions & 2 deletions documentation/c03-input.sil
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading