summaryrefslogtreecommitdiff
path: root/docs/c1/grammar.abnf.txt
diff options
context:
space:
mode:
Diffstat (limited to 'docs/c1/grammar.abnf.txt')
-rw-r--r--docs/c1/grammar.abnf.txt109
1 files changed, 109 insertions, 0 deletions
diff --git a/docs/c1/grammar.abnf.txt b/docs/c1/grammar.abnf.txt
new file mode 100644
index 0000000..ad68a16
--- /dev/null
+++ b/docs/c1/grammar.abnf.txt
@@ -0,0 +1,109 @@
+; Compatible with https://www.quut.com/abnfgen/
+
+; It's unclear whether this grammar is truly complete. It has been
+; verified not to produce text that is rejected by the Zisp parser
+; --except for Unicode escape sequences for surrogate code points--
+; but there may be some text that is accepted by the parser despite
+; not being grammatical according to these rules.
+
+
+Stream = [ Unit *( Blank Unit ) ] *Blank [Trail]
+
+
+Unit = *Blank Datum
+
+Blank = HTAB / LF / %x0b / %x0c / CR / SP / Comment
+
+Trail = SkipLine / SkipUnit / ';' '~' *Blank
+
+
+Datum = BareString / DottedStr / CladDatum / Rune / RuneStr
+ / RuneDotStr / RuneClad / LabelRef / LabelDef / HashStr
+ / HashDotStr / HashClad / QuoteExpr / JoinExpr
+
+Comment = SkipLine LF / SkipUnit Blank
+
+SkipLine = ';' [ SkipLStart *AnyButLF ]
+
+SkipUnit = ';' '~' Unit
+
+SkipLStart = %x00-09 / %x0b-7d / %x7f-ff ; any but LF or '~'
+
+AnyButLF = %x00-09 / %x0b-ff
+
+
+BareString = BareChar *( BareChar / Numeric )
+
+DottedStr = ( '.' / Numeric ) *( '.' / Numeric / BareChar )
+
+CladDatum = '|' *( PipeStrChar / '\' StringEsc ) '|'
+ / '"' *( QuotStrChar / '\' StringEsc ) '"'
+ / '(' List ')'
+ / '[' List ']'
+ / '{' List '}'
+
+Rune = '#' RuneName
+
+RuneStr = '#' RuneName '\' BareString
+
+RuneDotStr = '#' RuneName '\' DottedStr
+
+RuneClad = '#' RuneName CladDatum
+
+LabelRef = '#' '%' Label '%'
+
+LabelDef = '#' '%' Label '=' Datum
+
+HashStr = '#' '\' BareString
+
+HashDotStr = '#' '\' DottedStr
+
+HashClad = '#' CladDatum
+
+QuoteExpr = "'" Datum
+ / '`' Datum
+ / ',' Datum
+
+JoinExpr = Datum RJoinDatum
+ / LJoinDatum NoStartDot
+ / Datum ':' Datum
+ / NoEndDot '.' Datum
+
+
+BareChar = '!' / '$' / '%' / '*' / '/' / '<' / '=' / '>'
+ / '?' / '@' / '^' / '_' / '~' / ALPHA
+
+Numeric = '+' / '-' / DIGIT
+
+PipeStrChar = %x00-5b / %x5d-7b / %x7d-ff ; any but '|' or '\'
+
+QuotStrChar = %x00-21 / %x23-5b / %x5d-ff ; any but '"' or '\'
+
+StringEsc = '\' / '|' / '"' / *( HTAB / SP ) LF *( HTAB / SP )
+ / 'a' / 'b' / 't' / 'n' / 'v' / 'f' / 'r' / 'e'
+ / 'x' 1*( 2HEXDIG ) ';'
+ / 'u' ['0'] 1*5HEXDIG ';'
+ / 'u' '1' '0' 4HEXDIG ';'
+
+List = [ Unit *( Blank Unit ) ] *Blank [Tail] [SkipUnit]
+
+Tail = '&' Unit *Blank
+
+
+RuneName = ALPHA *5( ALPHA / DIGIT )
+
+Label = 1*12( HEXDIG )
+
+
+RJoinDatum = CladDatum / Rune / RuneStr / RuneDotStr / RuneClad
+ / LabelRef / LabelDef / HashStr / HashDotStr / HashClad
+ / QuoteExpr
+
+LJoinDatum = CladDatum / RuneClad / LabelRef / HashClad
+
+NoStartDot = BareString / CladDatum / Rune / RuneStr / RuneDotStr
+ / RuneClad / LabelRef / LabelDef / HashStr / HashDotStr
+ / HashClad / QuoteExpr
+
+NoEndDot = BareString / Rune / RuneStr / RuneClad / LabelRef
+ / HashStr / HashClad