File: ebnf-abn.el.html
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
This is part of ebnf2ps package.
This package defines a parser for ABNF (Augmented BNF).
See ebnf2ps.el for documentation.
ABNF Syntax
-----------
See the URL:
https://www.ietf.org/rfc/rfc2234.txt
("Augmented BNF for Syntax Specifications: ABNF").
rulelist = 1*( rule / (*c-wsp c-nl) )
rule = rulename defined-as elements c-nl
; continues if next line starts with white space
rulename = ALPHA *(ALPHA / DIGIT / "-")
defined-as = *c-wsp ("=" / "=/") *c-wsp
; basic rules definition and incremental
; alternatives
elements = alternation *c-wsp
c-wsp = WSP / (c-nl WSP)
c-nl = comment / CRLF
; comment or newline
comment = ";" *(WSP / VCHAR) CRLF
alternation = concatenation
*(*c-wsp "/" *c-wsp concatenation)
concatenation = repetition *(1*c-wsp repetition)
repetition = [repeat] element
repeat = 1*DIGIT / (*DIGIT "*" *DIGIT)
element = rulename / group / option /
char-val / num-val / prose-val
group = "(" *c-wsp alternation *c-wsp ")"
option = "[" *c-wsp alternation *c-wsp "]"
char-val = DQUOTE *(%x20-21 / %x23-7E) DQUOTE
; quoted string of SP and VCHAR without DQUOTE
num-val = "%" (bin-val / dec-val / hex-val)
bin-val = "b" 1*BIT
[ 1*("." 1*BIT) / ("-" 1*BIT) ]
; series of concatenated bit values
; or single ONEOF range
dec-val = "d" 1*DIGIT
[ 1*("." 1*DIGIT) / ("-" 1*DIGIT) ]
hex-val = "x" 1*HEXDIG
[ 1*("." 1*HEXDIG) / ("-" 1*HEXDIG) ]
prose-val = "<" *(%x20-3D / %x3F-7E) ">"
; bracketed string of SP and VCHAR without
; angles
; prose description, to be used as last resort
; Core rules -- the coding depends on the system, here is used 7-bit ASCII
ALPHA = %x41-5A / %x61-7A
; A-Z / a-z
BIT = "0" / "1"
CHAR = %x01-7F
; any 7-bit US-ASCII character, excluding NUL
CR = %x0D
; carriage return
CRLF = CR LF
; Internet standard newline
CTL = %x00-1F / %x7F
; controls
DIGIT = %x30-39
; 0-9
DQUOTE = %x22
; " (Double Quote)
HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F"
HTAB = %x09
; horizontal tab
LF = %x0A
; linefeed
LWSP = *(WSP / CRLF WSP)
; linear white space (past newline)
OCTET = %x00-FF
; 8 bits of data
SP = %x20
; space
VCHAR = %x21-7E
; visible (printing) characters
WSP = SP / HTAB
; white space
NOTES:
1. Rules name and terminal strings are case INSENSITIVE.
So, the following rule names are all equals:
Rule-name, rule-Name, rule-name, RULE-NAME
Also, the following strings are equals:
"abc", "ABC", "aBc", "Abc", "aBC", etc.
2. To have a case SENSITIVE string, use the character notation.
For example, to specify the lowercase string "abc", use:
%d97.98.99
3. There are no implicit spaces between elements, for example, the
following rules:
foo = %x61 ; a
bar = %x62 ; b
mumble = foo bar foo
Are equivalent to the following rule:
mumble = %x61.62.61
If spaces are needed, it should be explicit specified, like:
spaces = 1*(%x20 / %x09) ; one or more spaces or tabs
mumble = foo spaces bar spaces foo
4. Lines starting with space or tab are considered a continuation line.
For example, the rule:
rule = foo
bar
Is equivalent to:
rule = foo bar
Differences Between ABNF And ebnf2ps ABNF
-----------------------------------------
Besides the characters that ABNF accepts, ebnf2ps ABNF accepts also the
underscore (_) for rule name and european 8-bit accentuated characters (from
\240 to \377) for rule name, string and comment.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Defined variables (2)
ebnf-abn-lex | Value returned by ‘ebnf-abn-lex’ function. |
ebnf-abn-token-table | Vector used to map characters to a lexical token. |
Defined functions (7)
ebnf-abn-concatenation | (TOKEN) |
ebnf-abn-element | (TOKEN) |
ebnf-abn-initialize | () |
ebnf-abn-lex | () |
ebnf-abn-parser | (START) |
ebnf-abn-repetition | (TOKEN) |
ebnf-abn-rule | (TOKEN) |