[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/bnf-mode 687ee9e 16/74: Angle brackets to use for nonte
From: |
Stefan Monnier |
Subject: |
[elpa] externals/bnf-mode 687ee9e 16/74: Angle brackets to use for nonterminals are optional. Changed |
Date: |
Thu, 9 May 2019 08:27:45 -0400 (EDT) |
branch: externals/bnf-mode
commit 687ee9e0c10f18c711888af96573bf7b97aff4da
Author: Serghei Iakovlev <address@hidden>
Commit: Serghei Iakovlev <address@hidden>
Angle brackets to use for nonterminals are optional. Changed
In addition:
- LHS nonterminals may be preceded by an unlimited number of spaces
---
CHANGELOG.org | 8 ++++++--
bnf-mode.el | 36 +++++++++++++++++++++++++++---------
test/bnf-mode-font-test.el | 37 ++++++++++++++++++++++++++++---------
3 files changed, 61 insertions(+), 20 deletions(-)
diff --git a/CHANGELOG.org b/CHANGELOG.org
index f8157a7..eb76ed8 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -7,12 +7,16 @@ The format is based on [[http://keepachangelog.com][Keep a
Changelog]] and this
** [[https://github.com/sergeyklay/bnf-mode/compare/0.1.0...HEAD][Unreleased]]
+*** 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
+
** 0.2.0 - 2019-03-16
*** Changed
-- Comments are no longer use syntax table. For more see `comment-use-syntax'.
+- Comments are no longer use syntax table. For more see `comment-use-syntax'
*** Fixed
-- Changed comment syntax from ~#~ to ~;~ to follow
[[https://tools.ietf.org/html/rfc822#section-2.8][RFC822#2.8]] .
+- Changed comment syntax from ~#~ to ~;~ to follow
[[https://tools.ietf.org/html/rfc822#section-2.8][RFC822#2.8]]
** 0.1.0 - 2019-03-16
*** Added
diff --git a/bnf-mode.el b/bnf-mode.el
index dd685ef..32e74ec 100644
--- a/bnf-mode.el
+++ b/bnf-mode.el
@@ -146,23 +146,41 @@ See `rx' documentation for more information about REGEXPS
param."
(defvar bnf-font-lock-keywords
`(
- ;; LHS nonterminals
+ ;; LHS nonterminals may be preceded
+ ;; by an unlimited number of spaces
(,(bnf-rx (and line-start
+ (0+ space)
"<"
(group rulename)
- ">"))
+ ">"
+ (1+ space)
+ "::="))
1 font-lock-function-name-face)
- ;; other nonterminals
- (,(bnf-rx (and "<"
+ ;; 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)
+ "<"
(group rulename)
">"))
1 font-lock-builtin-face)
- ;; "may expand into" symbol
- (,(bnf-rx (and (0+ space)
- symbol-start
+ ;; Regarding to RFC5234#2.1 angle brackets
+ ;; (“<”, “>”) for RHS nonterminals are optional.
+ (,(bnf-rx (and "::="
+ (1+ space)
+ (group rulename)))
+ 1 font-lock-builtin-face)
+ ;; “may expand into” symbol
+ (,(bnf-rx (and symbol-start
(group "::=")
- symbol-end
- (0+ space)))
+ symbol-end))
1 font-lock-constant-face)
;; Alternatives
(,(bnf-rx (and (0+ space)
diff --git a/test/bnf-mode-font-test.el b/test/bnf-mode-font-test.el
index 2300695..23c5bd9 100644
--- a/test/bnf-mode-font-test.el
+++ b/test/bnf-mode-font-test.el
@@ -61,27 +61,35 @@ buffer."
(should (eq (bnf-test-face-at 1)
'font-lock-comment-face))
(should (eq (bnf-test-face-at 3)
'font-lock-comment-face))
(should-not (bnf-test-face-at 5))
- (should (eq (bnf-test-face-at 24) '
- font-lock-comment-face))))
+ (should (eq (bnf-test-face-at 24)
'font-lock-comment-face))))
(ert-deftest bnf-mode-syntax-table/fontify-nonterminals ()
:tags '(fontification syntax-table)
- (bnf-test-with-temp-buffer "<stm> ::= <decl>"
+ (bnf-test-with-temp-buffer "<stm> ::= <decl>
+angle-brackets ::= are-optional"
;; angle bracket
(should-not (bnf-test-face-at 1))
- ;; "stm"
+ ;; “stm”
(should (eq (bnf-test-face-at 2)
'font-lock-function-name-face))
(should (eq (bnf-test-face-at 4)
'font-lock-function-name-face))
;; angle bracket
(should-not (bnf-test-face-at 5))
- ;; "may expand into" symbol
- (should-not (eq (bnf-test-face-at 7)
'font-lock-function-name-face))
- (should-not (eq (bnf-test-face-at 9)
'font-lock-function-name-face))
+ ;; “::=” symbol
+ (should (eq (bnf-test-face-at 7)
'font-lock-constant-face))
+ (should (eq (bnf-test-face-at 9)
'font-lock-constant-face))
;; angle bracket
(should-not (bnf-test-face-at 11))
- ;; "dec" symbol
+ ;; “dec” symbol
(should (eq (bnf-test-face-at 12)
'font-lock-builtin-face))
- (should (eq (bnf-test-face-at 15)
'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))))
(ert-deftest bnf-mode-syntax-table/fontify-nonterminals-case ()
:tags '(fontification syntax-table)
@@ -96,6 +104,17 @@ buffer."
(should (eq (bnf-test-face-at 30)
'font-lock-builtin-face))
(should-not (bnf-test-face-at 31))))
+(ert-deftest bnf-mode-syntax-table/fontify-nonterminals-start-pos ()
+ :tags '(fontification syntax-table)
+ (bnf-test-with-temp-buffer " <rule> ::= doo"
+ (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))
+ (should (eq (bnf-test-face-at 7)
'font-lock-function-name-face))
+ (should (eq (bnf-test-face-at 8)
'font-lock-function-name-face))
+ (should-not (bnf-test-face-at 9))))
+
+
(provide 'bnf-mode-font-test)
;;; bnf-mode-font-test.el ends here
- [elpa] externals/bnf-mode 64a32ba 42/74: Cleaned up Makefile, (continued)
- [elpa] externals/bnf-mode 64a32ba 42/74: Cleaned up Makefile, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode a53ade1 24/74: Fixed BNF rule name definition to follow ALGOL 60 report, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode 65bfadc 65/74: Fixed orthodox comments regexp, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode e2f8bfa 53/74: Added support of ; character to use in terminals, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode 3a46f17 36/74: Correct documentation, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode f99de60 47/74: Cleaned up Makefile, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode 7bbf329 49/74: Added comment-start-skip to help comment commands recognize comments, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode 00a0543 50/74: Removed not used tests macro, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode 6eb06a8 52/74: Make tests easier to read, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode 273eabd 31/74: Correct change log formatting (II) [ci skip], Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode 687ee9e 16/74: Angle brackets to use for nonterminals are optional. Changed,
Stefan Monnier <=
- [elpa] externals/bnf-mode 83f0e0f 28/74: Code cleanup, Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode 96c6e76 61/74: Changed CI deploy token [ci skip], Stefan Monnier, 2019/05/09
- [elpa] externals/bnf-mode 8dabc6c 63/74: Minor correction to the change log format, Stefan Monnier, 2019/05/09
- [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