[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode 71cf945 048/385: lexer test based on Hask
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode 71cf945 048/385: lexer test based on Haskell2010 |
Date: |
Tue, 5 Oct 2021 23:58:59 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit 71cf9457cba13230a35d348a50099d056b9b7579
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
lexer test based on Haskell2010
---
README.md | 1 +
haskell-tng-smie.el | 7 ++
test/faces/{medley.hs.forward => medley.hs.lexer} | 0
test/haskell-tng-smie-test.el | 7 +-
test/lexer/layout.hs | 19 +++
test/lexer/layout.hs.lexer | 142 ++++++++++++++++++++++
6 files changed, 174 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 72d68b8..5e84623 100644
--- a/README.md
+++ b/README.md
@@ -69,6 +69,7 @@ Some blue sky features are being considered but may be best
as independent proje
- `:type` at point
- `:browse` `company-backend`
- `:doc` at point
+ - expand type definitions (e.g. to show full ADT)
- [`flycheck`](http://www.flycheck.org/en/latest/) integration with
`haskell-compile`
- `ghc` / `cabal v2-exec ghc --` for red squiggles, getting the correct info
from [`cabal-helper`](http://hackage.haskell.org/package/cabal-helper)
- and [`hlint`](https://github.com/ndmitchell/hlint)
diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el
index c08b252..ce8d614 100644
--- a/haskell-tng-smie.el
+++ b/haskell-tng-smie.el
@@ -19,6 +19,11 @@
;; Users may consult the SMIE manual to customise their indentation rules:
;; https://www.gnu.org/software/emacs/manual/html_mono/elisp.html#SMIE
;;
+;; The Haskell2010 report's sections 2.7 and 10.3 are particularly pertinent:
+;;
+;; https://www.haskell.org/onlinereport/haskell2010/haskellch2.html
+;; https://www.haskell.org/onlinereport/haskell2010/haskellch10.html
+;;
;;; Code:
(require 'smie)
@@ -48,6 +53,8 @@
(progn (skip-syntax-forward "w_")
(point))))))
+;;
+
;; TODO a haskell grammar
;; https://www.gnu.org/software/emacs/manual/html_mono/elisp.html#SMIE-Grammar
(defvar haskell-tng-smie:grammar
diff --git a/test/faces/medley.hs.forward b/test/faces/medley.hs.lexer
similarity index 100%
rename from test/faces/medley.hs.forward
rename to test/faces/medley.hs.lexer
diff --git a/test/haskell-tng-smie-test.el b/test/haskell-tng-smie-test.el
index f5253f6..005ed0e 100644
--- a/test/haskell-tng-smie-test.el
+++ b/test/haskell-tng-smie-test.el
@@ -41,7 +41,7 @@
(filename (expand-file-name
file
(haskell-tng-smie:this-lisp-directory)))
- (golden (concat filename ".forward"))
+ (golden (concat filename ".lexer"))
(expected (with-temp-buffer
(insert-file-contents golden)
(buffer-string)))
@@ -61,8 +61,11 @@
nil))
(kill-buffer lexed))))
+;; TODO the backwards test should simply assert consistency
+
(ert-deftest haskell-tng-smie-file-tests ()
- (should (have-expected-forward-lex "faces/medley.hs")))
+ (should (have-expected-forward-lex "faces/medley.hs"))
+ (should (have-expected-forward-lex "lexer/layout.hs")))
;; ideas for an indentation tester
;;
https://github.com/elixir-editors/emacs-elixir/blob/master/test/test-helper.el#L52-L63
diff --git a/test/lexer/layout.hs b/test/lexer/layout.hs
new file mode 100644
index 0000000..749b05d
--- /dev/null
+++ b/test/lexer/layout.hs
@@ -0,0 +1,19 @@
+-- Figure 2.1 from the Haskell2010 report
+module AStack( Stack, push, pop, top, size ) where
+data Stack a = Empty
+ | MkStack a (Stack a)
+
+push :: a -> Stack a -> Stack a
+push x s = MkStack x s
+
+size :: Stack a -> Int
+size s = length (stkToLst s) where
+ stkToLst Empty = []
+ stkToLst (MkStack x s) = x:xs where xs = stkToLst s
+
+pop :: Stack a -> (a, Stack a)
+pop (MkStack x s)
+ = (x, case s of r -> i r where i x = x) -- (pop Empty) is an error
+
+top :: Stack a -> a
+top (MkStack x s) = x -- (top Empty) is an error
diff --git a/test/lexer/layout.hs.lexer b/test/lexer/layout.hs.lexer
new file mode 100644
index 0000000..10ac6b0
--- /dev/null
+++ b/test/lexer/layout.hs.lexer
@@ -0,0 +1,142 @@
+module
+AStack
+(
+Stack
+,
+;
+push
+,
+pop
+,
+top
+,
+size
+)
+where
+{
+data
+Stack
+a
+=
+Empty
+|
+MkStack
+a
+(
+Stack
+a
+)
+;
+push
+::
+a
+->
+Stack
+a
+->
+Stack
+a
+push
+x
+s
+=
+MkStack
+x
+s
+;
+size
+::
+Stack
+a
+->
+Int
+;
+size
+s
+=
+length
+(
+stkToLst
+s
+)
+where
+{
+stkToLst
+Empty
+=
+[
+]
+;
+stkToLst
+(
+MkStack
+x
+s
+)
+=
+x:xs
+where
+{
+xs
+=
+stkToLst
+s
+}
+}
+;
+pop
+::
+Stack
+a
+->
+(
+a
+,
+Stack
+a
+)
+;
+pop
+(
+MkStack
+x
+s
+)
+=
+(
+x
+,
+case
+s
+of
+{
+r
+->
+i
+r
+where
+{
+i
+x
+=
+x
+}
+}
+)
+;
+top
+::
+Stack
+a
+->
+a
+;
+top
+(
+MkStack
+x
+s
+)
+=
+x
+}
- [nongnu] elpa/haskell-tng-mode dae43ac 049/385: improvements to the default lexer, (continued)
- [nongnu] elpa/haskell-tng-mode dae43ac 049/385: improvements to the default lexer, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode d76c6ad 053/385: some thoughts on WLDO detection, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 3e53f56 055/385: cleaner lexer test output, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 73e2b11 063/385: the new lexer works!, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 8e1a225 068/385: sexp tests, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 269be91 072/385: revert broken grammar rules, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 3194e62 074/385: stefan to the rescue, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode b690037 081/385: comment-* support, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 502cc26 085/385: document a failure mode, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 08f924c 088/385: simplify the grammar rules, better s-exps, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 71cf945 048/385: lexer test based on Haskell2010,
ELPA Syncer <=
- [nongnu] elpa/haskell-tng-mode 4d6bbfc 050/385: feedback from Stefan, improving lexing, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 96609e4 052/385: thoughts on layout inference, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 06b357c 054/385: hacky closing braces, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 64ad4a8 057/385: refactored to centralise state, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 0ac5a2f 059/385: copyright years and move the test assertions, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode a6bb27e 061/385: [ci skip] layout algorithm implemented and tested, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 7d2863e 065/385: tests for SMIE state invalidation, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 41a29dd 066/385: backward lexer, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode c48e7a5 069/385: starting to transcribe the expression table, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 1f1110a 073/385: transcribe the grammar rules, ELPA Syncer, 2021/10/06