emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/bnf-mode 5b223e8 34/36: Provide canonical BNF sytax


From: Stefan Monnier
Subject: [elpa] externals/bnf-mode 5b223e8 34/36: Provide canonical BNF sytax
Date: Wed, 17 Mar 2021 18:40:20 -0400 (EDT)

branch: externals/bnf-mode
commit 5b223e89cb45bf256000b28bd6a6ab0a7c13c122
Author: Serghei Iakovlev <egrep@protonmail.ch>
Commit: Serghei Iakovlev <egrep@protonmail.ch>

    Provide canonical BNF sytax
---
 test/bnf.bnf           | 33 ++++++++++++++++++++++++
 test/ebnf-grammar.ebnf | 68 --------------------------------------------------
 2 files changed, 33 insertions(+), 68 deletions(-)

diff --git a/test/bnf.bnf b/test/bnf.bnf
new file mode 100644
index 0000000..c539e0a
--- /dev/null
+++ b/test/bnf.bnf
@@ -0,0 +1,33 @@
+;; This is canonical BNF notation represented with a BNF.
+;;
+;; The syntax of the BNF has been carefully copied from Revised ALGOL 60 report
+;; <http://www.masswerk.at/algol60/report.htm>.
+
+ <syntax>         ::= <rule> | <rule> <syntax>
+ <rule>           ::= <opt-whitespace> < <rule-name> > <opt-whitespace>
+                      ::= <opt-whitespace> <expression> <line-end>
+ <opt-whitespace> ::= <space> <opt-whitespace> | <empty>
+ <expression>     ::= <list> | <list> <opt-whitespace> <or> <opt-whitespace>
+                      <expression>
+ <line-end>       ::= <opt-whitespace> <EOL> | <line-end> <line-end>
+ <list>           ::= <term> | <term> <opt-whitespace> <list>
+ <term>           ::= <literal> | < <rule-name> >
+ <literal>        ::= <character> <text>
+ <character>      ::= <letter> | <digit> | <symbol>
+ <letter>         ::= A | B | C | D | E | F | G | H | I | J | K | L | M | N |
+                      O | P | Q | R | S | T | U | V | W | X | Y | Z | a | b |
+                      c | d | e | f | g | h | i | j | k | l | m | n | o | p |
+                      q | r | s | t | u | v | w | x | y | z
+ <digit>          ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
+ <symbol>         ::= <or>  | <space>   | ! | # | $ | % | & | ( | ) | * | + |
+                      , | - | . | / | : | ~ | > | = | < | ? | @ | [ | \ | ] |
+                      ^ | _ | ` | ' | ‘ | ’ | " | “ | ” | { | } | ;
+ <rule-name>      ::= <letter> | <rule-name> <rule-char>
+ <rule-char>      ::= <letter> | <digit> | -
+ <space>          ::= <any whitespace character including \t and \n>
+ <or>             ::= |
+ <empty>          ::=
+
+;; Local Variables:
+;; indent-tabs-mode: nil
+;; End:
diff --git a/test/ebnf-grammar.ebnf b/test/ebnf-grammar.ebnf
deleted file mode 100644
index b8e8f20..0000000
--- a/test/ebnf-grammar.ebnf
+++ /dev/null
@@ -1,68 +0,0 @@
-(*  This example defines Extended BNF informally.  Many of the syntax
-rules include a comment to explain their meaning; inside a comment a
-meta identifier is enclosed in angle brackets  <  and  >  to avoid
-confusion with similar English words.  The non-terminal symbols
-<letter>, <decimal_digit> and <character> are NOT defined.  The position
-of <comments> is stated in a comment but not formally defined.  *)
-
-(*  A <syntax_rule> defines the sequences of symbols represented by a
-<meta_identifier>  *)
-syntax = syntax_rule, { syntax_rule } ;
-syntax_rule = meta_identifier, '=', definitions_list, ';' ;
-
-(*  |  separates alternative <single_definitions>  *)
-definitions_list = single_definition, { '|', single_definition } ;
-
-(* ,  separates successive <terms>  *)
-single_definition = term, { ',', term } ;
-
-(*  A <term> represents any sequence of symbols that is defined by the
-<factor> but not defined by the <exception>  *)
-term = factor, ['-', exception] ;
-
-(*  A <factor> may be used as an <exception> if it could be replaced by
-a <factor> containing no <meta_identifiers>  *)
-exception =  factor;
-
-(*  The <integer> specifies the number of repetitions of the
-<primary>  *)
-factor = [ integer, '*' ], primary ;
-
-primary = optional_sequence | repeated_sequence | special_sequence
-          | grouped_sequence | meta_identifier | terminal_string
-          | empty ;
-
-empty = ;
-
-(*  The brackets  [  and  ]  enclose symbols which are optional  *)
-optional_sequence = '[', definitions_list, ']' ;
-
-(*  The brackets  {  and  }  enclose symbols which may be repeated any
-number of times  *)
-repeated_sequence = '{', definitions_list, '}' ;
-
-(*  The brackets  (  and  )  allow any <definitions_list> to be a
-<primary>  *)
-grouped_sequence = '(', definitions_list, ')' ;
-
-(*  A <terminal_string> represents the <characters> between the quote
-symbols '_'  or  "_"  *)
-terminal_string = "'", character - "'", { character - "'" }, "'"
-                  | '"', character - '"', { character - '"' }, '"' ;
-
-(*  A <meta_identifier> is the name of a syntactic element of the
-language being defined  *)
-meta_identifier = letter, { letter | decimal_digit } ;
-
-integer = decimal_digit, { decimal_digit } ;
-
-(*  The meaning of a <special_sequence> is not defined in the standard
-metalanguage.  *)
-special_sequence = '?', { character - '?' }, '?' ;
-
-(*  A comment is allowed anywhere outside a <terminal_string>,
-<meta_identifier>, <integer> or <special_sequence>  *)
-comment = '(*', { comment_symbol }, '*)' ;
-
-comment_symbol = comment | terminal_string | special_sequence
-                 | character ;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]