Skip to content

Commit

Permalink
fix bugs in operator and comment regexes
Browse files Browse the repository at this point in the history
  • Loading branch information
friedbrice committed Sep 23, 2018
1 parent fe1fa3d commit df6b175
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
9 changes: 5 additions & 4 deletions Haskell.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ contexts:
captures:
1: entity.name.function.haskell
2: keyword.operator.haskell
- match: '\(([!#$%&*+./<=>?@\^|\-~:]+)\)\s*(::|∷)'
- match: '\(([!#$%&*+./<=>?@\\\^|\-~:]+)\)\s*(::|∷)'
comment: Function declarations with operator identifier
captures:
1: entity.name.function.haskell
Expand All @@ -204,7 +204,7 @@ contexts:
scope: constant.other.haskell
- include: comments
- include: infix_op
- match: '[!#$%&*+./<=>?@\^|\-~:]+'
- match: '[!#$%&*+./<=>?@\\\^|\-~:]+'
comment: In case this regex seems overly general, note that Haskell permits the definition of new operators which can be nearly any string of punctuation characters, such as $%^&*.
scope: keyword.operator.haskell
- match: ","
Expand All @@ -224,15 +224,16 @@ contexts:
scope: punctuation.definition.comment.end.haskell
pop: true
comments:
- match: '--'
- match: '--(?![!#$%&*+./<=>?@\\\^|~:])'
scope: punctuation.definition.comment.haskell
push:
- meta_scope: comment.line.double-dash.haskell
- match: $\n?
pop: true
- include: block_comment
infix_op:
- match: '(\([!#$%&*+./<=>?@\^|\-~:]+\)|\(,+\))'
- match: '(\([!#$%&*+./<=>?@\\\^|\-~:]+\)|\(,+\))'
comment: Infix operator in prefix position
scope: entity.name.function.infix.haskell
module_exports:
- match: \(
Expand Down
16 changes: 12 additions & 4 deletions syntax-test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,20 @@ class OneLiner a where oneLiner :: a -> OneLine a
----

-- deriving more than one type class
data DeriveMoreThanOne = DeriveMoreThanOne deriving (Eq, Read, Show)
data DeriveMoreThanOne = MkDeriveMoreThanOne deriving (Eq, Read, Show)

-- arrows
toUnit :: DeriveMoreThanOne -> ()
toUnit DeriveMoreThanOne = ()
toUnit _ = ()

-- question marks in identifiers
-- question marks in operators
(!!?) :: DeriveMoreThanOne -> DeriveMoreThanOne -> DeriveMoreThanOne
_ !!? _ = DeriveMoreThanOne
_ !!? _ = MkDeriveMoreThanOne

-- operators that start with '--'
(-->) :: (a -> b) -> (b -> c) -> a -> c
f --> g = g . f

-- operators that end with '--'
(<--) :: (b -> c) -> (a -> b) -> a -> c
f <-- g = f . g

0 comments on commit df6b175

Please sign in to comment.