[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode 1f1110a 073/385: transcribe the grammar r
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode 1f1110a 073/385: transcribe the grammar rules |
Date: |
Tue, 5 Oct 2021 23:59:04 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit 1f1110ac962474103e7d15eb6afea6f35db73690
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
transcribe the grammar rules
---
haskell-tng-smie.el | 89 +++++++++++++++++++++++++++++++++++++----------------
1 file changed, 62 insertions(+), 27 deletions(-)
diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el
index 08bfe71..87ba057 100644
--- a/haskell-tng-smie.el
+++ b/haskell-tng-smie.el
@@ -26,6 +26,35 @@
;; https://www.gnu.org/software/emacs/manual/html_mono/elisp.html#SMIE-Grammar
;; https://www.haskell.org/onlinereport/haskell2010/haskellch3.html
+;;
+;; exp infixexp :: [context =>] type (expression type signature)
+;; | infixexp
+;;
+;; infixexp lexp qop infixexp (infix operator application)
+;; | - infixexp (prefix negation)
+;; | lexp
+;;
+;; lexp \ apat1 … apatn -> exp (lambda abstraction, n ≥ 1)
+;; | let decls in exp (let expression)
+;; | if exp [;] then exp [;] else exp (conditional)
+;; | case exp of { alts } (case expression)
+;; | do { stmts } (do expression)
+;; | fexp
+;;
+;; fexp [fexp] aexp (function application)
+;;
+;; aexp qvar (variable)
+;; | gcon (general constructor)
+;; | literal
+;; | ( exp ) (parenthesized expression)
+;; | ( exp1 , … , expk ) (tuple, k ≥ 2)
+;; | [ exp1 , … , expk ] (list, k ≥ 1)
+;; | [ exp1 [, exp2] .. [exp3] ] (arithmetic sequence)
+;; | [ exp | qual1 , … , qualn ] (list comprehension, n ≥ 1)
+;; | ( infixexp qop ) (left section)
+;; | ( qop⟨-⟩ infixexp ) (right section)
+;; | qcon { fbind1 , … , fbindn } (labeled construction, n ≥
0)
+;; | aexp⟨qcon⟩ { fbind1 , … , fbindn } (labeled update, n ≥ 1)
(defvar haskell-tng-smie:grammar
(smie-prec2->grammar
(smie-bnf->prec2
@@ -34,7 +63,8 @@
;; TODO context
;;(infixexp "::" context "=>" type)
(infixexp "::" type)
- (infixexp))
+ (infixexp)
+ )
;; TODO update the lexer to provide a virtual token for infix but keep
;; popular operators with important fixity.
@@ -42,27 +72,31 @@
(lexp "$" infixexp)
(lexp "+" infixexp)
(lexp "-" infixexp)
- (lexp "*" infixexp)
- (lexp "/" infixexp)
- (lexp "<$>" infixexp)
- (lexp "<*>" infixexp)
- (lexp ">>=" infixexp)
- (lexp "`should`" infixexp)
- (lexp "&" infixexp)
+ ;; (lexp "*" infixexp)
+ ;; (lexp "/" infixexp)
+ ;; (lexp "<$>" infixexp)
+ ;; (lexp "<*>" infixexp)
+ ;; (lexp ">>=" infixexp)
+ ;; (lexp "`should`" infixexp)
+ ;; (lexp "&" infixexp)
+
;;("-" infixexp) ;; can't be opener and neither
- ;;(lexp)
+ (lexp)
)
+ ;; TODO to support terminators as separators
+ ;;(insts (insts ";" insts) (inst))
+
;; ;; FIXME these seem to break everything
- ;; (lexp
- ;; ;; TODO apats
- ;; ;;("let" decls "in" exp)
- ;; ;;("if" exp "then" exp "else" exp)
- ;; ;;("case" exp "of" alts)
- ;; ;;("do" stmts)
- ;; ;; TODO where?
- ;; ;; TODO fexp
- ;; )
+ (lexp
+ ("if" exp "then" exp "else" exp)
+ ;; TODO apats
+ ;;("let" decls "in" exp)
+ ;;("case" exp "of" alts)
+ ;;("do" stmts)
+ ;; TODO where?
+ ;; TODO fexp
+ )
;; (decls
;; ;;("{" decls "}")
@@ -86,16 +120,17 @@
)
;; operator precedences
+ ;;'((assoc ";"))
+ ;;'((assoc ","))
;; TODO arrange by fixity
- '((left "$"))
- '((left "+"))
- '((left "-"))
- '((left "*"))
- '((left "/"))
- '((left "<$>"))
- '((left "<*>"))
- '((left ">>="))
- '((left "&"))
+ '((assoc "$"))
+ '((assoc "+") (assoc "-"))
+ ;; '((assoc "*"))
+ ;; '((assoc "/"))
+ ;; '((assoc "<$>"))
+ ;; '((assoc "<*>"))
+ ;; '((assoc ">>="))
+ ;; '((assoc "&"))
)))
- [nongnu] elpa/haskell-tng-mode 71cf945 048/385: lexer test based on Haskell2010, (continued)
- [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, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 1f1110a 073/385: transcribe the grammar rules,
ELPA Syncer <=
- [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
- [nongnu] elpa/haskell-tng-mode 0d04664 115/385: implement batch compilation, ELPA Syncer, 2021/10/06