Skip to content

Commit

Permalink
Improving grammar
Browse files Browse the repository at this point in the history
Removed all prelude functions
Added rules for inline type signatures
Changed data, newtype and type markup to be like type signature

See #11
  • Loading branch information
JustusAdam committed Feb 4, 2017
1 parent f237b0c commit a2584a1
Show file tree
Hide file tree
Showing 2 changed files with 181 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
"preLaunchTask": "npm"
}
]
}
}
196 changes: 180 additions & 16 deletions syntaxes/haskell.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
</dict>
<dict>
<key>match</key>
<string>\(\)</string>
<string>\(\s*\)</string>
<key>name</key>
<string>constant.language.unit.haskell</string>
</dict>
<dict>
<key>match</key>
<string>\[\]</string>
<string>\[\s*\]</string>
<key>name</key>
<string>constant.language.empty-list.haskell</string>
</dict>
Expand Down Expand Up @@ -112,12 +112,16 @@
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#type_signature</string>
</dict>
<!--<dict>
<key>match</key>
<string>\b(Monad|Functor|Eq|Ord|Read|Show|Num|(Frac|Ra)tional|Enum|Bounded|Real(Frac|Float)?|Integral|Floating)\b</string>
<key>name</key>
<string>support.class.prelude.haskell</string>
</dict>
<dict>
</dict>-->
<!--<dict>
<key>match</key>
<string>[\p{Lu}\p{Lt}][\p{Ll}_\p{Lu}\p{Lt}\p{Nd}']*</string>
<key>name</key>
Expand All @@ -128,9 +132,104 @@
<string>\b[\p{Ll}_][\p{Ll}_\p{Lu}\p{Lt}\p{Nd}']*</string>
<key>name</key>
<string>variable.other.generic-type.haskell</string>
</dict>
</dict>-->
</array>
</dict>
<dict>
<key>match</key>
<string>(?x)
\b(data|newtype)
\s+
([\p{Lu}\p{Lt}][\w\p{Nd}_']*)
((?:\s+[\p{Ll}][\w\p{Nd}_']*)*)
\s+
(where|=|$)
</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.other.haskell</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>storage.type.haskell</string>
</dict>
<key>3</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>'*[\p{Ll}][\w\p{Nd}_']*</string>
<key>name</key>
<string>variable.other.generic-type.haskell</string>
</dict>
</array>
</dict>
<key>4</key>
<dict>
<key>name</key>
<string>keyword.other.haskell</string>
</dict>
</dict>
</dict>
<dict>
<key>match</key>
<string>(?x)
\b(type)
\s+
([\p{Lu}\p{Lt}][\w\p{Nd}_']*)
((?:\s+[\p{Ll}][\w\p{Nd}_']*)*)
(?:
\s+
(=)
(.*)
)?\s*$
</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.other.haskell</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>storage.type.haskell</string>
</dict>
<key>3</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>'*[\p{Ll}][\w\p{Nd}_']*</string>
<key>name</key>
<string>variable.other.generic-type.haskell</string>
</dict>
</array>
</dict>
<key>4</key>
<dict>
<key>name</key>
<string>keyword.other.haskell</string>
</dict>
<key>5</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#type_signature</string>
</dict>
</array>
</dict>
</dict>
</dict>
<dict>
<key>begin</key>
<string>\b(instance)\b</string>
Expand Down Expand Up @@ -225,13 +324,11 @@
<string>(?x)\b
( deriving
| where
| data
| type([\t ]+(family|role))?
| type([\t ]+(family|role))
| case
| of
| let
| in
| newtype
| in§
| default
)\b
</string>
Expand Down Expand Up @@ -463,12 +560,12 @@
<key>end</key>
<string>(?=^(\1)?[^\s])</string>
</dict>
<dict>
<!--<dict>
<key>match</key>
<string>\b(Just|Nothing|Left|Right|True|False|LT|EQ|GT|\(\)|\[\])\b</string>
<key>name</key>
<string>support.constant.haskell</string>
</dict>
</dict>-->
<dict>
<key>match</key>
<string>\b[\p{Lu}\p{Lt}][\p{Ll}_\p{Lu}\p{Lt}\p{Nd}']*</string>
Expand All @@ -479,16 +576,39 @@
<key>include</key>
<string>#comments</string>
</dict>
<dict>
<!--<dict>
<key>match</key>
<string>\b(abs|acos|acosh|all|and|any|appendFile|applyM|asTypeOf|asin|asinh|atan|atan2|atanh|break|catch|ceiling|compare|concat|concatMap|const|cos|cosh|curry|cycle|decodeFloat|div|divMod|drop|dropWhile|elem|encodeFloat|enumFrom|enumFromThen|enumFromThenTo|enumFromTo|error|even|exp|exponent|fail|filter|flip|floatDigits|floatRadix|floatRange|floor|fmap|foldl|foldl1|foldr|foldr1|fromEnum|fromInteger|fromIntegral|fromRational|fst|gcd|getChar|getContents|getLine|head|id|init|interact|ioError|isDenormalized|isIEEE|isInfinite|isNaN|isNegativeZero|iterate|last|lcm|length|lex|lines|log|logBase|lookup|map|mapM|mapM_|max|maxBound|maximum|maybe|min|minBound|minimum|mod|negate|not|notElem|null|odd|or|otherwise|pi|pred|print|product|properFraction|putChar|putStr|putStrLn|quot|quotRem|read|readFile|readIO|readList|readLn|readParen|reads|readsPrec|realToFrac|recip|rem|repeat|replicate|return|reverse|round|scaleFloat|scanl|scanl1|scanr|scanr1|seq|sequence|sequence_|show|showChar|showList|showParen|showString|shows|showsPrec|significand|signum|sin|sinh|snd|span|splitAt|sqrt|subtract|succ|sum|tail|take|takeWhile|tan|tanh|toEnum|toInteger|toRational|truncate|uncurry|undefined|unlines|until|unwords|unzip|unzip3|userError|words|writeFile|zip|zip3|zipWith|zipWith3)\b(?!')</string>
<key>name</key>
<string>support.function.prelude.haskell</string>
</dict>
</dict>-->
<dict>
<key>include</key>
<string>#infix_op</string>
</dict>
<dict>
<key>begin</key>
<string>(::)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.other.double-colon.haskell</string>
</dict>
</dict>
<key>end</key>
<string>\)|$</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#type_signature</string>
</dict>
</array>
<key>name</key>
<string>meta.type-declaration.haskell</string>
</dict>
<dict>
<key>comment</key>
<string>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 $%^&amp;*.</string>
Expand All @@ -503,6 +623,36 @@
<key>name</key>
<string>punctuation.separator.comma.haskell</string>
</dict>
<!--This below is me testing how to highlight function definitions (doesn't work yet)-->
<!--<dict>
<key>begin</key>
<string>(?=!^\s*)(\p{Ll}[\w\p{Nd}_']*)</string>
<key>beginCaptures</key>
<dict>
<key>2</key>
<dict>
<key>name</key>
<string>entity.name.function.haskell</string>
</dict>
</dict>
<key>end</key>
<string>(?=\||=)</string>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>\b[\p{Lu}\p{Lt}][\p{Ll}_\p{Lu}\p{Lt}\p{Nd}']*</string>
<key>name</key>
<string>constant.other.haskell</string>
</dict>
<dict>
<key>match</key>
<string>\b\p{Ll}[\w\p{Nd}_']*</string>
<key>name</key>
<string>variable.parameter.haskell</string>
</dict>
</array>
</dict>-->
</array>
<key>repository</key>
<dict>
Expand Down Expand Up @@ -661,6 +811,19 @@
<dict>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>\(</string>
<key>end</key>
<string>\)</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#type_signature</string>
</dict>
</array>
</dict>
<dict>
<key>captures</key>
<dict>
Expand Down Expand Up @@ -701,12 +864,12 @@
<key>name</key>
<string>keyword.other.big-arrow.haskell</string>
</dict>
<dict>
<!--<dict>
<key>match</key>
<string>\b(Int(eger)?|Maybe|Either|Bool|Float|Double|Char|String|Ordering|ShowS|ReadS|FilePath|IO(Error)?)\b</string>
<key>name</key>
<string>support.type.prelude.haskell</string>
</dict>
</dict>-->
<dict>
<key>match</key>
<string>\b[\p{Ll}_][\p{Ll}_\p{Lu}\p{Lt}\p{Nd}']*</string>
Expand All @@ -721,7 +884,7 @@
</dict>
<dict>
<key>match</key>
<string>\(\)</string>
<string>\(\s*\)</string>
<key>name</key>
<string>support.constant.unit.haskell</string>
</dict>
Expand All @@ -731,6 +894,7 @@
</dict>
</array>
</dict>

</dict>
<key>scopeName</key>
<string>source.haskell</string>
Expand Down

0 comments on commit a2584a1

Please sign in to comment.