branch: elpa/haskell-tng-mode
commit 174c63b799a5a8ce94f392a976698a0aff5636be
Author: Tseen She <[email protected]>
Commit: Tseen She <[email protected]>
laying the foundations for SMIE
---
haskell-tng-smie.el | 41 ++++++++++++++++++++++++++++++++++++++
test/haskell-tng-font-lock-test.el | 2 +-
test/haskell-tng-smie-test.el | 39 ++++++++++++++++++++++++++++++++++++
3 files changed, 81 insertions(+), 1 deletion(-)
diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el
new file mode 100644
index 0000000..436b17a
--- /dev/null
+++ b/haskell-tng-smie.el
@@ -0,0 +1,41 @@
+;;; haskell-tng-smie.el --- SMIE Rules for Haskell -*- lexical-binding: t -*-
+
+;; Copyright (C) 2018 Tseen She
+;; License: GPL 3 or any later version
+
+;;; Commentary:
+;;
+;; SMIE lexer, precedence table (providing s-expression navigation), and
+;; indentation rules.
+;;
+;; https://www.gnu.org/software/emacs/manual/html_mono/elisp.html#SMIE
+;;
+;;; Code:
+
+(require 'smie)
+
+ ;; (defvar sample-keywords-regexp
+ ;; (regexp-opt '("+" "*" "," ";" ">" ">=" "<" "<=" ":=" "=")))
+ ;; (defun sample-smie-forward-token ()
+ ;; (forward-comment (point-max))
+ ;; (cond
+ ;; ((looking-at sample-keywords-regexp)
+ ;; (goto-char (match-end 0))
+ ;; (match-string-no-properties 0))
+ ;; (t (buffer-substring-no-properties
+ ;; (point)
+ ;; (progn (skip-syntax-forward "w_")
+ ;; (point))))))
+ ;; (defun sample-smie-backward-token ()
+ ;; (forward-comment (- (point)))
+ ;; (cond
+ ;; ((looking-back sample-keywords-regexp (- (point) 2) t)
+ ;; (goto-char (match-beginning 0))
+ ;; (match-string-no-properties 0))
+ ;; (t (buffer-substring-no-properties
+ ;; (point)
+ ;; (progn (skip-syntax-backward "w_")
+ ;; (point))))))
+
+(provide 'haskell-tng-smie)
+;;; haskell-tng-smie.el ends here
diff --git a/test/haskell-tng-font-lock-test.el
b/test/haskell-tng-font-lock-test.el
index afaba90..fe5c739 100644
--- a/test/haskell-tng-font-lock-test.el
+++ b/test/haskell-tng-font-lock-test.el
@@ -17,6 +17,6 @@
(faceup-defexplainer have-expected-faces)
(ert-deftest haskell-tng-font-lock-file-tests ()
- (should (have-expected-faces "faces/medley.hs")) )
+ (should (have-expected-faces "faces/medley.hs")))
;;; haskell-tng-font-lock-test.el ends here
diff --git a/test/haskell-tng-smie-test.el b/test/haskell-tng-smie-test.el
new file mode 100644
index 0000000..2905484
--- /dev/null
+++ b/test/haskell-tng-smie-test.el
@@ -0,0 +1,39 @@
+;;; haskell-tng-smie-test.el --- Tests for fontification -*- lexical-binding:
t -*-
+
+;; Copyright (C) 2018 Tseen She
+;; License: GPL 3 or any later version
+
+(require 'haskell-tng-mode)
+
+(require 'ert)
+(require 'faceup)
+
+(defun haskell-tng-smie:lex-forward-buffer ()
+ (let* ((buf (current-buffer))
+ (work (switch-to-buffer (concat (buffer-file-name)
".lexer.forward"))))
+ (switch-to-buffer buf)
+ (goto-char (point-min))
+
+ ;; FIXME progress through the buf writing the returned values to work
+ ;; maybe with a character to indicate invocations, maybe newlines.
+
+ ))
+
+(defun have-expected-forward-lexer (file)
+ (let* ((filename (expand-file-name
+ file
+ (eval-when-compile (faceup-this-file-directory))))
+ (golden (concat filename ".lexer.forward")))
+
+ ;; FIXME run the lex-forward-buffer and compare the result with the version
+ ;; on disk, perhaps a trimmed diff.
+
+ ))
+
+(ert-deftest haskell-tng-smie-file-tests ()
+ (should (have-expected-forward-lexer "faces/medley.hs")))
+
+;; ideas for an indentation tester
+;;
https://github.com/elixir-editors/emacs-elixir/blob/master/test/test-helper.el#L52-L63
+
+;;; haskell-tng-smie-test.el ends here