on master help sign in
style: convert to more modern style
aeee665Evan Czaplicki
src/Parse/Helpers.hs+344−193
@@ -20,6 +20,7 @@ import qualified AST.Helpers as Help
20import qualified AST.Literal as L
20import qualified AST.Literal as L
21import qualified AST.PrettyPrint as P
21import qualified AST.PrettyPrint as P
22import qualified AST.Variable as Variable
22import qualified AST.Variable as Variable
23+import Elm.Utils ((|>))
23
24
24reserveds :: [String]
25reserveds :: [String]
25reserveds =
26reserveds =
@@ -33,66 +34,91 @@ reserveds =
33 , "deriving", "port"
34 , "deriving", "port"
34 ]
35 ]
35
36
37+
36expecting = flip (<?>)
38expecting = flip (<?>)
37
39
40+
38type OpTable = Map.Map String (Int, Decl.Assoc)
41type OpTable = Map.Map String (Int, Decl.Assoc)
39type SourceM = State SourcePos
42type SourceM = State SourcePos
40type IParser a = ParsecT String OpTable SourceM a
43type IParser a = ParsecT String OpTable SourceM a
41
44
45+
42iParse :: IParser a -> String -> Either ParseError a
46iParse :: IParser a -> String -> Either ParseError a
47+iParse parser source =
43−iParse = iParseWithTable "" Map.empty
48+ iParseWithTable "" Map.empty parser source
49+
44
50
45iParseWithTable :: SourceName -> OpTable -> IParser a -> String -> Either ParseError a
51iParseWithTable :: SourceName -> OpTable -> IParser a -> String -> Either ParseError a
46iParseWithTable sourceName table aParser input =
52iParseWithTable sourceName table aParser input =
47 runIndent sourceName $ runParserT aParser table sourceName input
53 runIndent sourceName $ runParserT aParser table sourceName input
48
54
55+
56+-- VARIABLES
57+
49var :: IParser String
58var :: IParser String
59+var =
50−var = makeVar (letter <|> char '_' <?> "variable")
60+ makeVar (letter <|> char '_' <?> "variable")
61+
51
62
52lowVar :: IParser String
63lowVar :: IParser String
64+lowVar =
53−lowVar = makeVar (lower <?> "lower case variable")
65+ makeVar (lower <?> "lower case variable")
66+
67+
54capVar :: IParser String
68capVar :: IParser String
69+capVar =
55−capVar = makeVar (upper <?> "upper case variable")
70+ makeVar (upper <?> "upper case variable")
71+
56
72
57qualifiedVar :: IParser String
73qualifiedVar :: IParser String
58−qualifiedVar = do
74+qualifiedVar =
59− vars <- many ((++) <$> capVar <*> string ".")
75+ do vars <- many ((++) <$> capVar <*> string ".")
60− (++) (concat vars) <$> lowVar
76+ (++) (concat vars) <$> lowVar
77+
61
78
62rLabel :: IParser String
79rLabel :: IParser String
63rLabel = lowVar
80rLabel = lowVar
64
81
82+
65innerVarChar :: IParser Char
83innerVarChar :: IParser Char
84+innerVarChar =
66−innerVarChar = alphaNum <|> char '_' <|> char '\'' <?> ""
85+ alphaNum <|> char '_' <|> char '\'' <?> ""
86+
67
87
68makeVar :: IParser Char -> IParser String
88makeVar :: IParser Char -> IParser String
69−makeVar p = do
89+makeVar p =
70− v <- (:) <$> p <*> many innerVarChar
90+ do v <- (:) <$> p <*> many innerVarChar
71− if v `elem` reserveds
91+ if v `elem` reserveds
72− then fail $ "unexpected keyword '" ++ v ++ "', variables cannot be keywords"
92+ then fail $ "unexpected keyword '" ++ v ++ "', variables cannot be keywords"
73− else return v
93+ else return v
94+
74
95
75reserved :: String -> IParser String
96reserved :: String -> IParser String
76reserved word =
97reserved word =
77− try (string word >> notFollowedBy innerVarChar) >> return word
98+ (try (string word >> notFollowedBy innerVarChar) >> return word)
78 <?> "reserved word '" ++ word ++ "'"
99 <?> "reserved word '" ++ word ++ "'"
79
100
101+
102+-- INFIX OPERATORS
103+
80anyOp :: IParser String
104anyOp :: IParser String
105+anyOp =
81−anyOp = betwixt '`' '`' qualifiedVar <|> symOp <?> "infix operator (e.g. +, *, ||)"
106+ betwixt '`' '`' qualifiedVar
107+ <|> symOp
108+ <?> "infix operator"
109+
82
110
83symOp :: IParser String
111symOp :: IParser String
112+symOp =
84−symOp = do op <- many1 (satisfy Help.isSymbol)
113+ do op <- many1 (satisfy Help.isSymbol)
85− guard (op `notElem` [ "=", "..", "->", "--", "|", "\8594", ":" ])
114+ guard (op `notElem` [ "=", "..", "->", "--", "|", "\8594", ":" ])
86− case op of
115+ case op of
87− "." -> notFollowedBy lower >> return op
116+ "." -> notFollowedBy lower >> return op
88− "\8728" -> return "."
117+ "\8728" -> return "."
89− _ -> return op
118+ _ -> return op
90
119
91−padded :: IParser a -> IParser a
120+
92−padded p = do whitespace
121+-- COMMON SYMBOLS
93− out <- p
94− whitespace
95− return out
96
122
97equals :: IParser String
123equals :: IParser String
98equals = string "="
124equals = string "="
@@ -104,58 +130,86 @@ hasType :: IParser String
104hasType = string ":" <?> "':' (a type annotation)'"
130hasType = string ":" <?> "':' (a type annotation)'"
105
131
106
132
107−commitIf check p = commit <|> try p
133+commitIf check p =
134+ commit <|> try p
135+ where
136+ commit =
108− where commit = do (try $ lookAhead check) >> p
137+ try (lookAhead check) >> p
138+
139+
140+-- SEPARATORS
109
141
110spaceySepBy1 :: IParser b -> IParser a -> IParser [a]
142spaceySepBy1 :: IParser b -> IParser a -> IParser [a]
111−spaceySepBy1 sep p = do
143+spaceySepBy1 sep p =
112− a <- p
144+ do a <- p
113− (a:) <$> many (commitIf (whitespace >> sep) (padded sep >> p))
145+ (a:) <$> many (commitIf (whitespace >> sep) (padded sep >> p))
114
146
115
147
116commaSep1 :: IParser a -> IParser [a]
148commaSep1 :: IParser a -> IParser [a]
149+commaSep1 =
117−commaSep1 = spaceySepBy1 (char ',' <?> "comma ','")
150+ spaceySepBy1 (char ',' <?> "comma ','")
151+
118
152
119commaSep :: IParser a -> IParser [a]
153commaSep :: IParser a -> IParser [a]
154+commaSep =
120−commaSep = option [] . commaSep1
155+ option [] . commaSep1
156+
121
157
122semiSep1 :: IParser a -> IParser [a]
158semiSep1 :: IParser a -> IParser [a]
159+semiSep1 =
123−semiSep1 = spaceySepBy1 (char ';' <?> "semicolon ';'")
160+ spaceySepBy1 (char ';' <?> "semicolon ';'")
161+
124
162
125pipeSep1 :: IParser a -> IParser [a]
163pipeSep1 :: IParser a -> IParser [a]
164+pipeSep1 =
126−pipeSep1 = spaceySepBy1 (char '|' <?> "type divider '|'")
165+ spaceySepBy1 (char '|' <?> "type divider '|'")
166+
127
167
128consSep1 :: IParser a -> IParser [a]
168consSep1 :: IParser a -> IParser [a]
169+consSep1 =
129−consSep1 = spaceySepBy1 (string "::" <?> "cons operator '::'")
170+ spaceySepBy1 (string "::" <?> "cons operator '::'")
171+
130
172
131dotSep1 :: IParser a -> IParser [a]
173dotSep1 :: IParser a -> IParser [a]
174+dotSep1 p =
132−dotSep1 p = (:) <$> p <*> many (try (char '.') >> p)
175+ (:) <$> p <*> many (try (char '.') >> p)
176+
133
177
134spaceSep1 :: IParser a -> IParser [a]
178spaceSep1 :: IParser a -> IParser [a]
179+spaceSep1 p =
135−spaceSep1 p = (:) <$> p <*> spacePrefix p
180+ (:) <$> p <*> spacePrefix p
181+
182+
183+spacePrefix p =
184+ constrainedSpacePrefix p (\_ -> return ())
136
185
137−spacePrefix p = constrainedSpacePrefix p (\_ -> return ())
138
186
139constrainedSpacePrefix p constraint =
187constrainedSpacePrefix p constraint =
188+ many $ choice
140− many $ choice [ try (spacing >> lookAhead (oneOf "[({")) >> p
189+ [ try (spacing >> lookAhead (oneOf "[({")) >> p
141− , try (spacing >> p)
190+ , try (spacing >> p)
142− ]
191+ ]
143 where
192 where
144 spacing = do
193 spacing = do
145 n <- whitespace
194 n <- whitespace
146 constraint n
195 constraint n
147 indented
196 indented
148
197
149−failure msg = do
150− inp <- getInput
151− setInput ('x':inp)
152− anyToken
153− fail msg
154
198
199+-- SURROUNDED BY
200+
155−followedBy a b = do x <- a ; b ; return x
201+followedBy a b =
202+ do x <- a
203+ b
204+ return x
205+
206+
207+betwixt a b c =
208+ do char a
209+ out <- c
210+ char b <?> "closing '" ++ [b] ++ "'"
211+ return out
156
212
157−betwixt a b c = do char a ; out <- c
158− char b <?> "closing '" ++ [b] ++ "'" ; return out
159
213
160surround a z name p = do
214surround a z name p = do
161 char a
215 char a
@@ -163,170 +217,252 @@ surround a z name p = do
163 char z <?> unwords ["closing", name, show z]
217 char z <?> unwords ["closing", name, show z]
164 return v
218 return v
165
219
166−braces :: IParser a -> IParser a
167−braces = surround '[' ']' "brace"
168
220
221+braces :: IParser a -> IParser a
222+braces =
223+ surround '[' ']' "brace"
224+
225+
169−parens :: IParser a -> IParser a
226+parens :: IParser a -> IParser a
227+parens =
170−parens = surround '(' ')' "paren"
228+ surround '(' ')' "paren"
229+
171
230
172brackets :: IParser a -> IParser a
231brackets :: IParser a -> IParser a
232+brackets =
173−brackets = surround '{' '}' "bracket"
233+ surround '{' '}' "bracket"
234+
235+
236+-- HELPERS FOR EXPRESSIONS
174
237
175addLocation :: (P.Pretty a) => IParser a -> IParser (Annotation.Located a)
238addLocation :: (P.Pretty a) => IParser a -> IParser (Annotation.Located a)
176−addLocation expr = do
239+addLocation expr =
177− (start, e, end) <- located expr
240+ do (start, e, end) <- located expr
178− return (Annotation.at start end e)
241+ return (Annotation.at start end e)
242+
179
243
180located :: IParser a -> IParser (SourcePos, a, SourcePos)
244located :: IParser a -> IParser (SourcePos, a, SourcePos)
181−located p = do
245+located p =
182− start <- getPosition
246+ do start <- getPosition
183− e <- p
247+ e <- p
184− end <- getPosition
248+ end <- getPosition
185− return (start, e, end)
249+ return (start, e, end)
250+
186
251
187accessible :: IParser Source.Expr -> IParser Source.Expr
252accessible :: IParser Source.Expr -> IParser Source.Expr
188−accessible expr = do
253+accessible expr =
189− start <- getPosition
254+ do start <- getPosition
190− ce@(Annotation.A _ e) <- expr
255+ ce@(Annotation.A _ e) <- expr
191− let rest f = do
256+ let rest f = do
192− let dot = char '.' >> notFollowedBy (char '.')
257+ let dot = char '.' >> notFollowedBy (char '.')
193− access <- optionMaybe (try dot <?> "field access (e.g. List.map)")
258+ access <- optionMaybe (try dot <?> "field access (e.g. List.map)")
194− case access of
259+ case access of
195− Nothing -> return ce
260+ Nothing -> return ce
196− Just _ -> accessible $ do
261+ Just _ -> accessible $ do
197− v <- var <?> "field access (e.g. List.map)"
262+ v <- var <?> "field access (e.g. List.map)"
198− end <- getPosition
263+ end <- getPosition
199− return (Annotation.at start end (f v))
264+ return (Annotation.at start end (f v))
200− case e of
265+ case e of
201− E.Var (Variable.Raw (c:cs))
266+ E.Var (Variable.Raw (c:cs))
202− | isUpper c -> rest (\v -> E.rawVar (c:cs ++ '.':v))
267+ | isUpper c -> rest (\v -> E.rawVar (c:cs ++ '.':v))
203− | otherwise -> rest (E.Access ce)
268+ | otherwise -> rest (E.Access ce)
204− _ -> rest (E.Access ce)
269+ _ -> rest (E.Access ce)
270+
271+
272+-- WHITESPACE
273+
274+padded :: IParser a -> IParser a
275+padded p =
276+ do whitespace
277+ out <- p
278+ whitespace
279+ return out
205
280
206
281
207spaces :: IParser String
282spaces :: IParser String
283+spaces =
208−spaces = concat <$> many1 (multiComment <|> string " ") <?> "spaces"
284+ concat <$> many1 (string " " <|> multiComment) <?> "spaces"
285+
209
286
210forcedWS :: IParser String
287forcedWS :: IParser String
288+forcedWS =
289+ choice
211−forcedWS = choice [ try $ (++) <$> spaces <*> (concat <$> many nl_space)
290+ [ try $ (++) <$> spaces <*> (concat <$> many nl_space)
212− , try $ concat <$> many1 nl_space ]
291+ , try $ concat <$> many1 nl_space
292+ ]
293+ where
294+ nl_space =
213− where nl_space = try ((++) <$> (concat <$> many1 newline) <*> spaces)
295+ try ((++) <$> (concat <$> many1 newline) <*> spaces)
296+
214
297
215-- Just eats whitespace until the next meaningful character.
298-- Just eats whitespace until the next meaningful character.
216dumbWhitespace :: IParser String
299dumbWhitespace :: IParser String
300+dumbWhitespace =
217−dumbWhitespace = concat <$> many (spaces <|> newline)
301+ concat <$> many (spaces <|> newline)
302+
218
303
219whitespace :: IParser String
304whitespace :: IParser String
305+whitespace =
220−whitespace = option "" forcedWS <?> "whitespace"
306+ option "" forcedWS
307+
221
308
222freshLine :: IParser [[String]]
309freshLine :: IParser [[String]]
310+freshLine =
223−freshLine = try (many1 newline >> many space_nl) <|> try (many1 space_nl) <?> ""
311+ try (many1 newline >> many space_nl) <|> try (many1 space_nl) <?> ""
312+ where
224− where space_nl = try $ spaces >> many1 newline
313+ space_nl = try $ spaces >> many1 newline
314+
225
315
226newline :: IParser String
316newline :: IParser String
317+newline =
227−newline = simpleNewline <|> lineComment <?> "newline"
318+ simpleNewline <|> lineComment <?> "newline"
319+
228
320
229simpleNewline :: IParser String
321simpleNewline :: IParser String
322+simpleNewline =
230−simpleNewline = try (string "\r\n") <|> string "\n"
323+ try (string "\r\n") <|> string "\n"
324+
231
325
232lineComment :: IParser String
326lineComment :: IParser String
233−lineComment = do
327+lineComment =
234− try (string "--")
328+ do try (string "--")
235− comment <- anyUntil $ simpleNewline <|> (eof >> return "\n")
329+ comment <- anyUntil $ simpleNewline <|> (eof >> return "\n")
236− return ("--" ++ comment)
330+ return ("--" ++ comment)
331+
237
332
238multiComment :: IParser String
333multiComment :: IParser String
334+multiComment =
239−multiComment = (++) <$> try (string "{-") <*> closeComment
335+ (++) <$> try (string "{-") <*> closeComment
336+
240
337
241closeComment :: IParser String
338closeComment :: IParser String
242closeComment =
339closeComment =
243− anyUntil . choice $
340+ anyUntil $
341+ choice $
244− [ try (string "-}") <?> "close comment"
342+ [ try (string "-}") <?> "close comment"
245− , concat <$> sequence [ try (string "{-"), closeComment, closeComment ]
343+ , concat <$> sequence [ try (string "{-"), closeComment, closeComment ]
246− ]
344+ ]
345+
346+
347+-- ODD COMBINATORS
348+
349+failure msg = do
350+ inp <- getInput
351+ setInput ('x':inp)
352+ anyToken
353+ fail msg
354+
247
355
248until :: IParser a -> IParser b -> IParser b
356until :: IParser a -> IParser b -> IParser b
249−until p end = go
357+until p end =
358+ go
250− where
359+ where
251− go = end <|> (p >> go)
360+ go = end <|> (p >> go)
361+
252
362
253anyUntil :: IParser String -> IParser String
363anyUntil :: IParser String -> IParser String
254−anyUntil end = go
364+anyUntil end =
365+ go
255− where
366+ where
367+ go =
256− go = end <|> (:) <$> anyChar <*> go
368+ end <|> (:) <$> anyChar <*> go
369+
257
370
258ignoreUntil :: IParser a -> IParser (Maybe a)
371ignoreUntil :: IParser a -> IParser (Maybe a)
259−ignoreUntil end = go
372+ignoreUntil end =
373+ go
260− where
374+ where
261− ignore p = const () <$> p
375+ ignore p =
376+ const () <$> p
377+
378+ filler =
379+ choice
262− filler = choice [ try (ignore chr) <|> ignore str
380+ [ try (ignore chr) <|> ignore str
263− , ignore multiComment
381+ , ignore multiComment
264− , ignore markdown
382+ , ignore markdown
265− , ignore anyChar
383+ , ignore anyChar
266− ]
384+ ]
385+
386+ go =
387+ choice
267− go = choice [ Just <$> end
388+ [ Just <$> end
268− , filler `until` choice [ const Nothing <$> eof, newline >> go ]
389+ , filler `until` choice [ const Nothing <$> eof, newline >> go ]
269− ]
390+ ]
391+
270
392
271onFreshLines :: (a -> b -> b) -> b -> IParser a -> IParser b
393onFreshLines :: (a -> b -> b) -> b -> IParser a -> IParser b
272−onFreshLines insert init thing = go init
394+onFreshLines insert init thing =
395+ go init
273− where
396+ where
274− go values = do
397+ go values =
275− optionValue <- ignoreUntil thing
398+ do optionValue <- ignoreUntil thing
276− case optionValue of
399+ case optionValue of
277− Nothing -> return values
400+ Nothing -> return values
278− Just v -> go (insert v values)
401+ Just v -> go (insert v values)
402+
279
403
280withSource :: IParser a -> IParser (String, a)
404withSource :: IParser a -> IParser (String, a)
281−withSource p = do
405+withSource p =
282− start <- getParserState
406+ do start <- getParserState
283− result <- p
407+ result <- p
284− endPos <- getPosition
408+ endPos <- getPosition
285− setParserState start
409+ setParserState start
286− raw <- anyUntilPos endPos
410+ raw <- anyUntilPos endPos
287− return (raw, result)
411+ return (raw, result)
412+
288
413
289anyUntilPos :: SourcePos -> IParser String
414anyUntilPos :: SourcePos -> IParser String
290−anyUntilPos pos = go
415+anyUntilPos pos =
416+ go
291− where
417+ where
292− go = do currentPos <- getPosition
418+ go = do currentPos <- getPosition
293− case currentPos == pos of
419+ case currentPos == pos of
294− True -> return []
420+ True -> return []
295− False -> (:) <$> anyChar <*> go
421+ False -> (:) <$> anyChar <*> go
422+
423+
424+-- BASIC LANGUAGE LITERALS
296
425
297markdown :: IParser String
426markdown :: IParser String
298markdown =
427markdown =
299− do try (string "[markdown|")
428+ do try (string "[markdown|")
300− closeMarkdown id
429+ closeMarkdown id
301− where
430+ where
302− closeMarkdown markdownBuilder =
431+ closeMarkdown markdownBuilder =
432+ choice
303− choice [ do try (string "|]")
433+ [ do try (string "|]")
304− return (markdownBuilder "")
434+ return (markdownBuilder "")
305− , do c <- anyChar
435+ , do c <- anyChar
306− closeMarkdown (markdownBuilder . (c:))
436+ closeMarkdown (markdownBuilder . (c:))
307− ]
437+ ]
438+
308
439
309shader :: IParser (String, L.GLShaderTipe)
440shader :: IParser (String, L.GLShaderTipe)
310shader =
441shader =
311− do try (string "[glsl|")
442+ do try (string "[glsl|")
312− rawSrc <- closeShader id
443+ rawSrc <- closeShader id
313− case glSource rawSrc of
444+ case glSource rawSrc of
314− Left err -> parserFail . show $ err
445+ Left err -> parserFail . show $ err
315− Right tipe -> return (rawSrc, tipe)
446+ Right tipe -> return (rawSrc, tipe)
316 where
447 where
317− closeShader builder = choice
448+ closeShader builder =
449+ choice
318− [ do try (string "|]")
450+ [ do try (string "|]")
319− return (builder "")
451+ return (builder "")
320− , do c <- anyChar
452+ , do c <- anyChar
321− closeShader (builder . (c:))
453+ closeShader (builder . (c:))
322 ]
454 ]
323
455
456+
324glSource :: String -> Either ParseError L.GLShaderTipe
457glSource :: String -> Either ParseError L.GLShaderTipe
325glSource src =
458glSource src =
326 case GLP.parse src of
459 case GLP.parse src of
327− Right (GLS.TranslationUnit decls) ->
328− Right . foldr addGLinput emptyDecls . join . map extractGLinputs $ decls
329 Left e -> Left e
460 Left e -> Left e
461+ Right (GLS.TranslationUnit decls) ->
462+ map extractGLinputs decls
463+ |> join
464+ |> foldr addGLinput emptyDecls
465+ |> Right
330 where
466 where
331 emptyDecls = L.GLShaderTipe Map.empty Map.empty Map.empty
467 emptyDecls = L.GLShaderTipe Map.empty Map.empty Map.empty
332
468
@@ -367,6 +503,7 @@ glSource src =
367 _ -> []
503 _ -> []
368 _ -> []
504 _ -> []
369
505
506+
370str :: IParser String
507str :: IParser String
371str = expecting "String" $ do
508str = expecting "String" $ do
372 s <- choice [ multiStr, singleStr ]
509 s <- choice [ multiStr, singleStr ]
@@ -394,46 +531,60 @@ str = expecting "String" $ do
394 choice [ char '\n' >> return "\\n"
531 choice [ char '\n' >> return "\\n"
395 , char '\r' >> return "\\r" ]
532 , char '\r' >> return "\\r" ]
396
533
534+
397sandwich :: Char -> String -> String
535sandwich :: Char -> String -> String
398−sandwich delim s = delim : s ++ [delim]
536+sandwich delim s =
537+ delim : s ++ [delim]
538+
399
539
400escaped :: Char -> IParser String
540escaped :: Char -> IParser String
401−escaped delim = try $ do
541+escaped delim =
542+ try $ do
402− char '\\'
543+ char '\\'
403− c <- char '\\' <|> char delim
544+ c <- char '\\' <|> char delim
404− return ['\\', c]
545+ return ['\\', c]
546+
405
547
406chr :: IParser Char
548chr :: IParser Char
549+chr =
407−chr = betwixt '\'' '\'' character <?> "character"
550+ betwixt '\'' '\'' character <?> "character"
408− where
551+ where
409− nonQuote = satisfy (/='\'')
552+ nonQuote = satisfy (/='\'')
553+
410− character = do
554+ character =
555+ do c <- choice
411− c <- choice [ escaped '\''
556+ [ escaped '\''
412− , (:) <$> char '\\' <*> many1 nonQuote
557+ , (:) <$> char '\\' <*> many1 nonQuote
413− , (:[]) <$> nonQuote ]
558+ , (:[]) <$> nonQuote
559+ ]
560+
414− processAs T.charLiteral $ sandwich '\'' c
561+ processAs T.charLiteral $ sandwich '\'' c
562+
415
563
416processAs :: (T.GenTokenParser String u SourceM -> IParser a) -> String -> IParser a
564processAs :: (T.GenTokenParser String u SourceM -> IParser a) -> String -> IParser a
565+processAs processor s =
417−processAs processor s = calloutParser s (processor lexer)
566+ calloutParser s (processor lexer)
418− where
567+ where
419− calloutParser :: String -> IParser a -> IParser a
568+ calloutParser :: String -> IParser a -> IParser a
569+ calloutParser inp p =
420− calloutParser inp p = either (fail . show) return (iParse p inp)
570+ either (fail . show) return (iParse p inp)
421−
571+
422− lexer :: T.GenTokenParser String u SourceM
572+ lexer :: T.GenTokenParser String u SourceM
423− lexer = T.makeTokenParser elmDef
573+ lexer = T.makeTokenParser elmDef
424−
574+
425− -- I don't know how many of these are necessary for charLiteral/stringLiteral
575+ -- I don't know how many of these are necessary for charLiteral/stringLiteral
426− elmDef :: T.GenLanguageDef String u SourceM
576+ elmDef :: T.GenLanguageDef String u SourceM
577+ elmDef =
427− elmDef = T.LanguageDef
578+ T.LanguageDef
428− { T.commentStart = "{-"
579+ { T.commentStart = "{-"
429− , T.commentEnd = "-}"
580+ , T.commentEnd = "-}"
430− , T.commentLine = "--"
581+ , T.commentLine = "--"
431− , T.nestedComments = True
582+ , T.nestedComments = True
432− , T.identStart = undefined
583+ , T.identStart = undefined
433− , T.identLetter = undefined
584+ , T.identLetter = undefined
434− , T.opStart = undefined
585+ , T.opStart = undefined
435− , T.opLetter = undefined
586+ , T.opLetter = undefined
436− , T.reservedNames = reserveds
587+ , T.reservedNames = reserveds
437− , T.reservedOpNames = [":", "->", "<-", "|"]
588+ , T.reservedOpNames = [":", "->", "<-", "|"]
438− , T.caseSensitive = True
589+ , T.caseSensitive = True
439− }
590+ }