1 -- Copyright 2006-2017 Mitchell mitchell.att.foicica.com. See LICENSE.
3 -- Modified by Alex Suraci.
5 local l
= require('lexer')
6 local token
, word_match
= l
.token
, l
.word_match
7 local P
, R
, S
= lpeg
.P
, lpeg
.R
, lpeg
.S
9 local M
= {_NAME
= 'haskell'}
12 local ws
= token(l
.WHITESPACE
, l
.space^
1)
15 local line_comment
= '--' * l
.nonnewline_esc^
0
16 local block_comment
= '{-' * (l
.any
- '-}')^
0 * P('-}')^
-1
17 local comment
= token(l
.COMMENT
, line_comment
+ block_comment
)
20 local string = token(l
.STRING
, l
.delimited_range('"'))
23 local char
= token(l
.STRING
, l
.delimited_range("'", true))
26 local number = token(l
.NUMBER
, l
.float
+ l
.integer
)
29 local keyword
= token(l
.KEYWORD
, word_match
{
30 'case', 'class', 'data', 'default', 'deriving', 'do', 'else', 'if', 'import',
31 'in', 'infix', 'infixl', 'infixr', 'instance', 'let', 'module', 'newtype',
32 'of', 'then', 'type', 'where', '_', 'as', 'qualified', 'hiding'
36 local word
= (l
.alnum
+ S("._'#"))^
0
37 local identifier
= token(l
.IDENTIFIER
, (l
.alpha
+ '_') * word
)
40 local op
= l
.punct
- S('()[]{}')
41 local operator
= token(l
.OPERATOR
, op
)
43 -- Types & type constructors.
44 local constructor
= token(l
.TYPE
, (l
.upper
* word
) + (P(":") * (op^
1 - P(":"))))
49 {'type', constructor
},
50 {'identifier', identifier
},
55 {'operator', operator
},
58 M
._FOLDBYINDENTATION
= true