File: ebnf-bnf.el.html
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
This is part of ebnf2ps package.
This package defines a parser for EBNF.
See ebnf2ps.el for documentation.
EBNF Syntax
-----------
The current EBNF that ebnf2ps accepts has the following constructions:
; comment (until end of line)
A non-terminal
"C" terminal
?C? special
$A default non-terminal
$"C" default terminal
$?C? default special
A = B. production (A is the header and B the body)
C D sequence (C occurs before D)
C | D alternative (C or D occurs)
A - B exception (A excluding B, B without any non-terminal)
n * A repetition (A repeats at least n (integer) times)
n * n A repetition (A repeats exactly n (integer) times)
n * m A repetition (A repeats at least n (integer) and at most
m (integer) times)
(C) group (expression C is grouped together)
[C] optional (C may or not occurs)
C+ one or more occurrences of C
{C}+ one or more occurrences of C
{C}* zero or more occurrences of C
{C} zero or more occurrences of C
C / D equivalent to: C {D C}*
{C || D}+ equivalent to: C {D C}*
{C || D}* equivalent to: [C {D C}*]
{C || D} equivalent to: [C {D C}*]
The EBNF syntax written using the notation above is:
EBNF = {production}+.
production = non_terminal "=" body ".". ;; production
body = {sequence || "|"}*. ;; alternative
sequence = {exception}*. ;; sequence
exception = repeat [ "-" repeat]. ;; exception
repeat = [ integer "*" [ integer ]] term. ;; repetition
term = factor
| [factor] "+" ;; one-or-more
| [factor] "/" [factor] ;; one-or-more
.
factor = [ "$" ] "\\"" terminal "\"" ;; terminal
| [ "$" ] non_terminal ;; non-terminal
| [ "$" ] "?" special "?" ;; special
| "(" body ")" ;; group
| "[" body "]" ;; zero-or-one
| "{" body [ "||" body ] "}+" ;; one-or-more
| "{" body [ "||" body ] "}*" ;; zero-or-more
| "{" body [ "||" body ] "}" ;; zero-or-more
.
non_terminal = "[!#%&'*-,0-:<>@-Z\\\\\\\\^-z~\\\\240-\\\\377]+".
;; that is, a valid non_terminal accepts decimal digits, letters (upper
;; and lower), 8-bit accentuated characters,
;; "!", "#", "%", "&", "'", "*", "+", ",", ":",
;; "<", ">", "@", "\\", "^", "_", "`" and "~".
terminal = "\\\\([^\\"\\]\\|\\\M-x -~\\240-\\377 ( -~\\240-\\377)\\)+".
;; that is, a valid terminal accepts any printable character (including
;; 8-bit accentuated characters) except `"', as " is used to delimit a
;; terminal. Also, accepts escaped characters, that is, a character
;; pair starting with \ followed by a printable character, for
;; example: \", \\\\.
special = "[^?\\000-\\010\\012-\\037\\177-\\237]*".
;; that is, a valid special accepts any printable character (including
;; 8-bit accentuated characters) and tabs except `?', as `?' is used to
;; delimit a special.
integer = "[0-9]+".
;; that is, an integer is a sequence of one or more decimal digits.
comment = ";" "[^\\n\\000-\\010\\016-\\037\\177-\\237]*" "\\n".
;; that is, a comment starts with the character ; and terminates at end
;; of line. Also, it only accepts printable characters (including 8-bit
;; accentuated characters) and tabs.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Defined variables (2)
ebnf-bnf-lex | Value returned by ‘ebnf-bnf-lex’ function. |
ebnf-bnf-token-table | Vector used to map characters to a lexical token. |
Defined functions (10)
ebnf-bnf-initialize | () |
ebnf-bnf-lex | () |
ebnf-bnf-parser | (START) |
ebnf-exception | (TOKEN) |
ebnf-factor | (TOKEN) |
ebnf-no-non-terminal | (NODE) |
ebnf-production | (TOKEN) |
ebnf-repeat | (TOKEN) |
ebnf-term | (TOKEN) |
ebnf-unescape-string | (STR) |