-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
107 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
; Formal grammar definition for SIL (SILE Input Language) files | ||
; | ||
; Based on RFC 5234 (Augmented BNF for Syntax Specifications: ABNF) | ||
; Uses RFC 7405 (Case-Sensitive String Support in ABNF) | ||
|
||
; A master document can only have one top level content item, but we allow | ||
; loading of fragments as well which can have any number of top level content | ||
; items, hence valid grammar can be any number of content items. | ||
document = *content | ||
|
||
; Top level content can be any sequence of these things | ||
content = environment | ||
content =/ comment | ||
content =/ text | ||
content =/ braced_content | ||
content =/ command | ||
|
||
; Environments come in two flavors, raw passthrough and regular. The difference | ||
; is what is allowed to terminate them and what escapes are needed for the | ||
; content in the middle. | ||
environment = %s"\begin" [ options ] "{" command-id "}" content %s"\end{" command-id "}" | ||
environment =/ %s"\begin" [ options ] "{" passthrough-command-id "}" passthrough-content %s"\end{" passthrough-command-id "}" | ||
|
||
; Nothing to see here. | ||
comment = "%" utf8-octets CRLF | ||
|
||
; Input strings that are not wrapped in some SILE command. | ||
text = *text-char | ||
|
||
; Input content wrapped in braces can be attatched to a command or just used to | ||
; create a settings wrapper. | ||
braced_content = "{" content "}" | ||
|
||
; As with environments, can be raw passthrough or regular content depending on the command. With raw variants we require contents. | ||
command = "\" command-id [ options ] [ braced_content ] | ||
command =/ "\" passthrough-command-id [ options ] braced-passthrough-content | ||
|
||
; Building blocks | ||
options = "[" parameter *( "," parameter ) "]" | ||
parameter = *1( sil-identifier "=" value) | ||
value = | ||
quoted-value = DQUOTE *( *SP / value / "," ) DQUOTE | ||
s = *WS | ||
any = %x20-7F / valid-non-ascii / tab | ||
|
||
escaped-char = "\\" / "\%" / "\{" / "\}" | ||
|
||
; non-ascii-char = %x80-D7FF / %xE000-10FFFF | ||
text-char = %x0-24 ; omit % | ||
text-char = %x26-5B ; omit \ | ||
text-char =/ %x5D-7A ; omit { | ||
text-char =/ %x7C ; omit } | ||
text-char =/ %x7E-7F ; end of utf8-1 | ||
text-char =/ utf8-2 | ||
text-char =/ utf8-3 | ||
text-char =/ utf8-4 | ||
|
||
letters = ALPHA / "_" | ||
identifier = letters *( letters / DIGIT ) | ||
sil-identifier = 1*( identifier / ":" / "-" ) | ||
command-id = sil-identifier - %s"begin" - %s"end" - passthrough-command-id | ||
passthrough-command-id = %s"ftl" / %s"lua" / %s"math" / %s"raw" / %s"script" / %s"sil" / %s"use" / %s"xml" | ||
|
||
; ASCII isn't good enough for us. | ||
utf8-octets = *utf8-char | ||
utf8-char = utf8-1 / utf8-2 / utf8-3 / utf8-4 | ||
utf8-1 = %x00-7F | ||
utf8-2 = %xC2-DF utf8-tail | ||
utf8-3 = %xE0 %xA0-BF utf8-tail / %xE1-EC 2utf8-tail / %xED %x80-9F utf8-tail / %xEE-EF 2utf8-tail | ||
utf8-4 = %xF0 %x90-BF 2utf8-tail / %xF1-F3 3utf8-tail / %xF4 %x80-8F 2utf8-tail | ||
utf8-tail = %x80-BF |