[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/bnf-mode c836c7c 19/74: Temporarily removed ABNF, amend
From: |
Stefan Monnier |
Subject: |
[elpa] externals/bnf-mode c836c7c 19/74: Temporarily removed ABNF, amended tests |
Date: |
Thu, 9 May 2019 08:27:45 -0400 (EDT) |
branch: externals/bnf-mode
commit c836c7c60eb565311d930d8fa486af92ab29a6e4
Author: Serghei Iakovlev <address@hidden>
Commit: Serghei Iakovlev <address@hidden>
Temporarily removed ABNF, amended tests
---
CHANGELOG.org | 1 -
README.org | 3 ++
bnf-mode.el | 47 +++++++++++----------------
test/bnf-mode-font-test.el | 79 +++++++++++++++++++++++-----------------------
test/test-helper.el | 10 ++++++
5 files changed, 71 insertions(+), 69 deletions(-)
diff --git a/CHANGELOG.org b/CHANGELOG.org
index f43e99e..8334f11 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -9,7 +9,6 @@ The format is based on [[http://keepachangelog.com][Keep a
Changelog]] and this
*** Changed
- LHS nonterminals may be preceded by an unlimited number of spaces
-- Regarding to
[[https://tools.ietf.org/html/rfc5234#section-2.1][RFC5234#2.1]] angle brackets
to use for nonterminals are optional
** [[https://github.com/sergeyklay/bnf-mode/compare/0.1.0...0.2.0][0.2.0]] -
2019-03-16
*** Changed
diff --git a/README.org b/README.org
index 8a1d74a..8c37260 100644
--- a/README.org
+++ b/README.org
@@ -21,6 +21,7 @@ When developing this mode, the following RFCs were taken into
account:
- [[https://www.ietf.org/rfc/rfc822.txt][RFC822]]: Standard for ARPA Internet
Text Messages
- [[https://www.ietf.org/rfc/rfc5234.txt][RFC5234]]: Augmented BNF for Syntax
Specifications: ABNF
+- [[https://tools.ietf.org/html/rfc7405][RFC7405]]: Case-Sensitive String
Support in ABNF
** Features
@@ -90,6 +91,8 @@ To see what has changed in recent versions of BNF Mode, see
the [[https://github
** External Links
- [[https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form][Wikipedia:
Backus–Naur form]]
+-
[[https://en.wikipedia.org/wiki/Extended_Backus%25E2%2580%2593Naur_form][Wikipedia:
Extended Backus–Naur form]]
+-
[[https://en.wikipedia.org/wiki/Augmented_Backus%25E2%2580%2593Naur_form][Wikipedia:
Augmented Backus–Naur form]]
- [[https://www.cl.cam.ac.uk/~mgk25/iso-14977.pdf][ISO/IEC 14977: EBNF]]
- [[https://www.ics.uci.edu/~pattis/ICS-33/lectures/ebnf.pdf][EBNF: A Notation
to Describe Syntax]]
diff --git a/bnf-mode.el b/bnf-mode.el
index 12550b4..1585922 100644
--- a/bnf-mode.el
+++ b/bnf-mode.el
@@ -31,15 +31,17 @@
;;; Commentary:
;; GNU Emacs major mode for editing BNF grammars. Currently this mode
-;; provides basic syntax and font-locking for "*.bnf" files.
+;; provides basic syntax and font-locking for BNF files.
;;
;; When developing this mode, the following RFCs were taken into account:
;;
;; - RFC822: Standard for ARPA Internet Text Messages [1]
;; - RFC5234: Augmented BNF for Syntax Specifications: ABNF [2]
+;; - FRC7405: Case-Sensitive String Support in ABNF [3]
;;
;; [1]: https://www.ietf.org/rfc/rfc822.txt
;; [2]: https://www.ietf.org/rfc/rfc5234.txt
+;; [3]: https://www.ietf.org/rfc/rfc7405.txt
;;
;; Usage: Put this file in your Emacs Lisp path (eg. site-lisp) and add to
;; your .emacs file:
@@ -111,12 +113,11 @@ just return nil."
(eval-when-compile
(defconst bnf-rx-constituents
`(
- ;; rulename
- (rulename . ,(rx (and
- symbol-start
- letter
- (0+ (or "-" alnum))
- symbol-end)))
+ (bnf-rule-name . ,(rx (and
+ symbol-start
+ letter
+ (0+ (or "-" alnum))
+ symbol-end)))
"Additional special sexps for `bnf-rx'."))
(defmacro bnf-rx (&rest sexps)
@@ -125,12 +126,12 @@ just return nil."
In addition to the standard forms of `rx', the following forms
are available:
-`rulename'
- Any valid rule name. The name of a rule is simply the
+`bnf-rule-name'
+ Any valid BNF rule name. The name of a rule is simply the
name itself, that is, a sequence of characters, beginning
with an alphabetic character, and followed by a combination
of alphabetics, digits, and hyphens (dashes).
- For more see RFC5234#2.1
+ For examle see RFC5234#2.1
See `rx' documentation for more information about REGEXPS param."
(let ((rx-constituents (append bnf-rx-constituents rx-constituents)))
@@ -151,29 +152,17 @@ See `rx' documentation for more information about REGEXPS
param."
(,(bnf-rx (and line-start
(0+ space)
"<"
- (group rulename)
+ (group bnf-rule-name)
">"
- (1+ space)
- "::="))
- 1 font-lock-function-name-face)
- ;; Regarding to RFC5234#2.1 angle brackets
- ;; (“<”, “>”) for LHS nonterminals are optional.
- (,(bnf-rx (and line-start
(0+ space)
- (group rulename)
- (1+ space)
"::="))
1 font-lock-function-name-face)
- ;; RHS nonterminals
- (,(bnf-rx (and (1+ space)
+ ;; Other nonterminals
+ (,(bnf-rx (and (0+ space)
"<"
- (group rulename)
- ">"))
- 1 font-lock-builtin-face)
- ;; Regarding to RFC5234#2.1 angle brackets
- ;; (“<”, “>”) for RHS nonterminals are optional.
- (,(bnf-rx (and (1+ space)
- (group rulename)))
+ (group bnf-rule-name)
+ ">"
+ (0+ space)))
1 font-lock-builtin-face)
;; “may expand into” symbol
(,(bnf-rx (and symbol-start
@@ -187,7 +176,7 @@ See `rx' documentation for more information about REGEXPS
param."
symbol-end
(0+ space)))
1 font-lock-warning-face))
- "Font lock keywords for BNF Mode.")
+ "Font lock BNF keywords for BNF Mode.")
;;; Initialization
diff --git a/test/bnf-mode-font-test.el b/test/bnf-mode-font-test.el
index cfe18d2..25cc3d4 100644
--- a/test/bnf-mode-font-test.el
+++ b/test/bnf-mode-font-test.el
@@ -34,19 +34,6 @@
;;; Code:
-;;;; Utilities
-
-(defun bnf-test-face-at (pos &optional content)
- "Get the face at POS in CONTENT.
-
-If CONTENT is not given, return the face at POS in the current
-buffer."
- (if content
- (bnf-test-with-temp-buffer content
- (get-text-property pos 'face))
- (get-text-property pos 'face)))
-
-
;;;; Font locking
(ert-deftest bnf-mode-syntax-table/fontify-strings ()
@@ -81,32 +68,25 @@ angle-brackets ::= are-optional"
(should-not (bnf-test-face-at 11))
;; “dec” symbol
(should (eq (bnf-test-face-at 12)
'font-lock-builtin-face))
- (should (eq (bnf-test-face-at 15)
'font-lock-builtin-face))
- ;; “angle-brackets”
- (should (eq (bnf-test-face-at 18)
'font-lock-function-name-face))
- (should (eq (bnf-test-face-at 31)
'font-lock-function-name-face))
- ;; space
- (should-not (bnf-test-face-at 32))
- ;; “are-optional” symbol
- (should (eq (bnf-test-face-at 37)
'font-lock-builtin-face))
- (should (eq (bnf-test-face-at 48)
'font-lock-builtin-face))))
+ (should (eq (bnf-test-face-at 15)
'font-lock-builtin-face))))
(ert-deftest bnf-mode-syntax-table/fontify-nonterminals-case ()
:tags '(fontification syntax-table)
- (bnf-test-with-temp-buffer "<RULE> ::= foo
+ (bnf-test-with-temp-buffer "<RULE> ::= <foo>
<RuLe> ::= <foO>"
(should (eq (bnf-test-face-at 2)
'font-lock-function-name-face))
(should (eq (bnf-test-face-at 5)
'font-lock-function-name-face))
- (should (eq (bnf-test-face-at 17)
'font-lock-function-name-face))
- (should (eq (bnf-test-face-at 20)
'font-lock-function-name-face))
- (should-not (bnf-test-face-at 21))
- (should (eq (bnf-test-face-at 28)
'font-lock-builtin-face))
+ (should-not (bnf-test-face-at 17))
+ (should (eq (bnf-test-face-at 19)
'font-lock-function-name-face))
+ (should (eq (bnf-test-face-at 22)
'font-lock-function-name-face))
+ (should-not (bnf-test-face-at 23))
(should (eq (bnf-test-face-at 30)
'font-lock-builtin-face))
- (should-not (bnf-test-face-at 31))))
+ (should (eq (bnf-test-face-at 32)
'font-lock-builtin-face))
+ (should-not (bnf-test-face-at 33))))
(ert-deftest bnf-mode-syntax-table/fontify-nonterminals-start-pos ()
:tags '(fontification syntax-table)
- (bnf-test-with-temp-buffer " <rule> ::= doo"
+ (bnf-test-with-temp-buffer " <rule> ::= <foo>"
(should-not (bnf-test-face-at 4))
(should (eq (bnf-test-face-at 5)
'font-lock-function-name-face))
(should (eq (bnf-test-face-at 6)
'font-lock-function-name-face))
@@ -116,23 +96,44 @@ angle-brackets ::= are-optional"
(ert-deftest bnf-mode-syntax-table/fontify-sequence ()
:tags '(fontification syntax-table)
- (bnf-test-with-temp-buffer "rule ::= foo bar baz"
+ (bnf-test-with-temp-buffer "<rule> ::= <foo> <bar> <baz>"
+ ;; “<” angle bracket
+ (should-not (bnf-test-face-at 1))
;; “rule”
- (should (eq (bnf-test-face-at 1)
'font-lock-function-name-face))
- (should (eq (bnf-test-face-at 4)
'font-lock-function-name-face))
+ (should (eq (bnf-test-face-at 2)
'font-lock-function-name-face))
+ (should (eq (bnf-test-face-at 5)
'font-lock-function-name-face))
+ ;; “>” angle bracket
+ (should-not (bnf-test-face-at 6))
;; “foo”
- (should (eq (bnf-test-face-at 10)
'font-lock-builtin-face))
- (should (eq (bnf-test-face-at 12)
'font-lock-builtin-face))
+ (should (eq (bnf-test-face-at 13)
'font-lock-builtin-face))
+ (should (eq (bnf-test-face-at 15)
'font-lock-builtin-face))
;; space
- (should-not (bnf-test-face-at 13))
+ (should-not (bnf-test-face-at 17))
;; “bar”
- (should (eq (bnf-test-face-at 14)
'font-lock-builtin-face))
- (should (eq (bnf-test-face-at 16)
'font-lock-builtin-face))
+ (should (eq (bnf-test-face-at 19)
'font-lock-builtin-face))
+ (should (eq (bnf-test-face-at 21)
'font-lock-builtin-face))
;; space
- (should-not (bnf-test-face-at 17))
+ (should-not (bnf-test-face-at 23))
;; “baz”
+ (should (eq (bnf-test-face-at 25)
'font-lock-builtin-face))
+ (should (eq (bnf-test-face-at 27)
'font-lock-builtin-face))))
+
+(ert-deftest bnf-mode-syntax-table/fontify-alternatives ()
+ :tags '(fontification syntax-table)
+ (bnf-test-with-temp-buffer "<foo> | <bar> | <baz>"
+ ;; foo
+ (should (eq (bnf-test-face-at 2)
'font-lock-builtin-face))
+ (should (eq (bnf-test-face-at 4)
'font-lock-builtin-face))
+ ;; |
+ (should (eq (bnf-test-face-at 7)
'font-lock-warning-face))
+ ;; bar
+ (should (eq (bnf-test-face-at 10)
'font-lock-builtin-face))
+ (should (eq (bnf-test-face-at 12)
'font-lock-builtin-face))
+ ;; |
+ (should (eq (bnf-test-face-at 15)
'font-lock-warning-face))
+ ;; baz
(should (eq (bnf-test-face-at 18)
'font-lock-builtin-face))
- (should (eq (bnf-test-face-at 10)
'font-lock-builtin-face))))
+ (should (eq (bnf-test-face-at 20)
'font-lock-builtin-face))))
(provide 'bnf-mode-font-test)
diff --git a/test/test-helper.el b/test/test-helper.el
index a051fbe..a8e9b90 100644
--- a/test/test-helper.el
+++ b/test/test-helper.el
@@ -92,6 +92,16 @@
(insert indented)
(should (equal indented
,expected-output)))))))
+(defun bnf-test-face-at (pos &optional content)
+ "Get the face at POS in CONTENT.
+
+If CONTENT is not given, return the face at POS in the current
+buffer."
+ (if content
+ (bnf-test-with-temp-buffer content
+ (get-text-property pos 'face))
+ (get-text-property pos 'face)))
+
(when (s-contains? "--win" (getenv "ERT_RUNNER_ARGS"))
(defun ert-runner/run-tests-batch-and-exit (selector)
(ert-run-tests-interactively selector)))
- [elpa] externals/bnf-mode e898672 73/74: Removed no longer needed local variables, (continued)
- [elpa] externals/bnf-mode e898672 73/74: Removed no longer needed local variables, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode f95ec5f 69/74: Improved preparing package, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode 7c98cc9 66/74: Fixed misspelling, updated change log, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode ce5005e 57/74: Install missed dependency on Travis CI, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode f00384e 10/74: Change comment syntax, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode 7240455 38/74: Improved test reporting, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode 6ce1208 33/74: We're on MELPA. Yay!, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode e5f56ca 35/74: Amended documentation, update change log, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode ac004f6 34/74: Removed the bnf-mode-version function, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode 89660ba 44/74: Removing emacs26-el package solves "Recursive load" issue, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode c836c7c 19/74: Temporarily removed ABNF, amended tests,
Stefan Monnier <=
- [elpa] externals/bnf-mode 5b6ff92 41/74: Update copyright, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode e9a5e4a 45/74: Return back comment-start and comment-end, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode 3eda5e7 48/74: This package is NOT part of GNU Emacs, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode ebd9b83 51/74: Added ability to generate info, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode 7a4a1b0 55/74: Build package on Travis CI, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode f00edff 56/74: Prepare deploy on Travis CI, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode 1105934 59/74: Cleaned up Travis CI config, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode 548c33b 58/74: Bump version, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode aed186d 54/74: Provided ability to build installation package., Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode 119d792 72/74: Added Emacs 26.2 to Travis CI build matrix, Stefan Monnier, 2019/05/09