emacs-elpa-diffs
[Top][All Lists]
Advanced

[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 "&"))
 
     )))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]