[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode c48e7a5 069/385: starting to transcribe t
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode c48e7a5 069/385: starting to transcribe the expression table |
Date: |
Tue, 5 Oct 2021 23:59:03 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit c48e7a5aa51642ee3d06945e86af300800d96e39
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
starting to transcribe the expression table
---
haskell-tng-smie.el | 73 +++++++++++++++++++++++++++++++++++++-----------
test/src/layout.hs.sexps | 20 ++++++-------
2 files changed, 66 insertions(+), 27 deletions(-)
diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el
index 3fb7183..cbd281f 100644
--- a/haskell-tng-smie.el
+++ b/haskell-tng-smie.el
@@ -9,9 +9,8 @@
;; rules.
;;
;; Note that we don't support every aspect of the Haskell language. e.g. if we
-;; had access to all the operators in scope, and their fixity, we could create
-;; file-specific precendences. However, the complexity-to-benefit payoff is
-;; minimal.
+;; had access to the fixity of operators in scope we could create
file-specific
+;; rules.
;;
;; Users may consult the SMIE manual to customise their indentation rules:
;; https://www.gnu.org/software/emacs/manual/html_mono/elisp.html#SMIE
@@ -23,25 +22,65 @@
(require 'haskell-tng-font-lock)
(require 'haskell-tng-lexer)
-;; FIXME a haskell grammar
+;; FIXME a haskell grammar that doesn't have warnings during the tests
+
;; https://www.gnu.org/software/emacs/manual/html_mono/elisp.html#SMIE-Grammar
+;; https://www.haskell.org/onlinereport/haskell2010/haskellch3.html
(defvar haskell-tng-smie:grammar
(smie-prec2->grammar
(smie-bnf->prec2
'((id)
- (inst ("if" exp "then" inst "else" inst)
- (id "<-" exp)
- (id "=" exp)
- (exp))
- (insts (insts ";" insts) (inst))
- (exp (exp "+" exp)
- (exp "*" exp)
- ("(" exps ")")
- ("{" insts "}"))
- (exps (exps "," exps) (exp)))
- '((assoc ";"))
- '((assoc ","))
- '((assoc "+") (assoc "*")))))
+ (exp
+ ;; TODO context
+ ;;(infixexp "::" context "=>" type)
+ (infixexp "::" type)
+ (infixexp))
+
+ ;; TODO monkey patch `smie-indent-forward' to support regexps in `assoc'
+ (infixexp
+ (lexp "$" infixexp) ;; TODO arrange by fixity
+ (lexp "+" infixexp)
+ (lexp "-" infixexp)
+ (lexp "*" infixexp)
+ (lexp "/" infixexp)
+ (lexp "<$>" infixexp)
+ (lexp "<*>" infixexp)
+ (lexp ">>=" infixexp)
+ (lexp "`should`" infixexp)
+ (lexp "&" infixexp)
+ ("-" infixexp)
+ (lexp))
+
+ (lexp
+ ;; TODO apats, it is hard to formalise...
+ ;;("\\" apats "->" exp)
+ ("let" "{" decls "}" "in" exp)
+ ("if" exp "then" exp "else" exp)
+ ("case" exp "of" "{" alts "}")
+ ("do" "{" stmts "}")
+ ;; TODO fexp
+ )
+
+ ;; TODO formal decls definition
+ (decls
+ (decls ";" decls)
+ (decl))
+ (decl
+ (id "=" exp))
+ ;; TODO formal alts definition
+ (alts
+ (alts ";" alts)
+ (alt))
+ (alt
+ (id "->" exp))
+ ;; TODO formal stmts definition
+ (stmts
+ (stmts ";" stmts)
+ (stmt))
+ (stmt
+ (id "<-" exp))
+
+ ))))
;; TODO indentation rules
;;
https://www.gnu.org/software/emacs/manual/html_mono/elisp.html#SMIE-Indentation
diff --git a/test/src/layout.hs.sexps b/test/src/layout.hs.sexps
index a507d5b..a3b077a 100644
--- a/test/src/layout.hs.sexps
+++ b/test/src/layout.hs.sexps
@@ -1,20 +1,20 @@
-((--) Figure 2.1 from the Haskell2010 report
-(module)) (AStack()( (Stack), (push), (pop), (top), (size) )) (where)
-((data) (Stack) (a) = (Empty)
+(-- 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) (::) ((a) ->) ((Stack) (a) ->) (Stack) (a)))
((push) (x) (s) = (MkStack) (x) (s))
-((size) (::) (Stack) (a) (->) (Int))
+(((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) (::) ((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
+ = (((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
-)
\ No newline at end of file
+(((top) (::) ((Stack) (a) ->) (a)))
+((top) (((MkStack) (x) (s))) = (x)) -- (top Empty) is an
(error)
+))
\ No newline at end of file
- [nongnu] elpa/haskell-tng-mode 08f924c 088/385: simplify the grammar rules, better s-exps, (continued)
- [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, 2021/10/06
- [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 <=
- [nongnu] elpa/haskell-tng-mode 1f1110a 073/385: transcribe the grammar rules, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 01789b1 075/385: y u no haskell-mode?, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode b8f3e3f 079/385: back out incomplete grammar rules, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 9e19b2b 080/385: double down on simpler grammar, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 6e7a24f 083/385: lexer identifies conid / varid, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode b12e49a 086/385: consym, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 7d6fa3d 091/385: thoughts on lexers, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 6a05d12 090/385: planning for indentation, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 2060f7a 092/385: thoughts on indentation testing, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 6d2d764 094/385: skeleton for indentation tests, ELPA Syncer, 2021/10/06