branch: elpa/haskell-tng-mode commit 47f1f9fd88eb3adef44dcf5bda16a31dfc5e7de6 Author: Tseen She <ts33n....@gmail.com> Commit: Tseen She <ts33n....@gmail.com>
lex CONSYM correctly --- haskell-tng-lexer.el | 10 ++++++++-- haskell-tng-smie.el | 13 ++++++------- test/src/layout.hs.lexer | 2 +- test/src/medley.hs.lexer | 4 ++-- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/haskell-tng-lexer.el b/haskell-tng-lexer.el index 8ea1a68..b7da5f7 100644 --- a/haskell-tng-lexer.el +++ b/haskell-tng-lexer.el @@ -96,7 +96,10 @@ the lexer." ;; reserved keywords take precedence ((looking-at haskell-tng:regexp:reserved-hack) - (haskell-tng-lexer:last-match)) + (pcase (haskell-tng-lexer:last-match) + (":" "CONSYM") + ("':" "KINDSYM") ;; DataKinds + (other other))) ;; syntax tables (supported by `smie-indent-forward-token') ((looking-at haskell-tng-lexer:fast-syntax) nil) @@ -164,7 +167,10 @@ the lexer." ((bobp) nil) ((looking-back haskell-tng:regexp:reserved-hack (max lbp (- (point) 8)) 't) - (haskell-tng-lexer:last-match 'reverse)) + (pcase (haskell-tng-lexer:last-match 'reverse) + (":" "CONSYM") + ("':" "KINDSYM") ;; DataKinds + (other other))) ((looking-back haskell-tng-lexer:fast-syntax (max lbp (- (point) 1))) nil) diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el index 8375515..a340f72 100644 --- a/haskell-tng-smie.el +++ b/haskell-tng-smie.el @@ -95,9 +95,8 @@ foobar1 :: ;; operators all have the same precedence (infixexp - ;; TODO : and ': should lex as SYMID - (id ":" infixexp) ;; keyword infix - (id "':" infixexp) ;; DataKinds + (id "KINDSYM" infixexp) + (id "CONSYM" infixexp) (id "SYMID" infixexp)) (data @@ -256,7 +255,7 @@ information, to aid in the creation of new rules." (:list-intro (pcase arg - ((or "<-" "SYMID") t) + ((or "<-" "SYMID" "CONSYM" "KINDSYM") t) )) (:after @@ -272,7 +271,7 @@ information, to aid in the creation of new rules." 2) ("::" 5) ("," (smie-rule-separator method)) - ((or "SYMID") + ((or "SYMID" "CONSYM" "KINDSYM") (if (smie-rule-hanging-p) 2 (smie-rule-parent))) )) @@ -288,7 +287,7 @@ information, to aid in the creation of new rules." ;; ;; blah = bloo where ;; bloo = blu - ((or "where" "let" "do" "case" "=" "->" "SYMID") + ((or "where" "let" "do" "case" "=" "->" "SYMID" "CONSYM" "KINDSYM") (smie-rule-parent)) ("\\case" ;; LambdaCase (smie-rule-parent)) @@ -304,7 +303,7 @@ information, to aid in the creation of new rules." ;; heuristic works in most cases, but is not robust. (smie-rule-parent -2) (smie-rule-separator method))) - ((guard (smie-rule-parent-p "SYMID")) + ((guard (smie-rule-parent-p "SYMID" "CONSYM" "KINDSYM")) (smie-rule-parent)) )) diff --git a/test/src/layout.hs.lexer b/test/src/layout.hs.lexer index 4128c01..e523ca9 100644 --- a/test/src/layout.hs.lexer +++ b/test/src/layout.hs.lexer @@ -9,7 +9,7 @@ module CONID « CONID , VARID , VARID , VARID , VARID » where ; VARID :: CONID VARID -> CONID ; VARID VARID = VARID « VARID VARID » where { VARID CONID = [] -; VARID « CONID VARID VARID » = VARID : VARID where { VARID = VARID VARID +; VARID « CONID VARID VARID » = VARID CONSYM VARID where { VARID = VARID VARID } } ; VARID :: CONID VARID -> « VARID , CONID VARID » ; VARID « CONID VARID VARID » diff --git a/test/src/medley.hs.lexer b/test/src/medley.hs.lexer index 0a2047f..b391454 100644 --- a/test/src/medley.hs.lexer +++ b/test/src/medley.hs.lexer @@ -51,10 +51,10 @@ VARID , VARID , VARID » ; class CONID VARID VARID where { VARID :: CONID VARID -> VARID -} ; instance CONID VARID « VARID ': VARID » where +} ; instance CONID VARID « VARID KINDSYM VARID » where { VARID « CONID VARID _ » = VARID -} ; instance CONID VARID VARID => CONID VARID « VARID ': VARID » where +} ; instance CONID VARID VARID => CONID VARID « VARID KINDSYM VARID » where { VARID « CONID _ VARID » = VARID VARID } ; data CONID = CONID