@@ -110,10 +110,6 @@ instance CanParse ListValuesBase where
110
110
unnest (Paren (LVBase (LVBParen e))) = e
111
111
unnest e = e
112
112
113
- -- | Helper function to try to parse the second part of a binary operator.
114
- binOpParseHelp :: (CanParse a ) => Char -> (a -> a ) -> Parser a
115
- binOpParseHelp c con = try (skipSpace *> char c) *> skipSpace *> (con <$> pars)
116
-
117
113
instance (CanParse b ) => CanParse (If b ) where
118
114
pars = do
119
115
a <- string " if" *> skipSpace1 *> pars <* skipSpace1
@@ -171,16 +167,17 @@ instance CanParse Negation where
171
167
<|> NoNeg <$> pars
172
168
173
169
instance CanParse Expo where
174
- pars = do
175
- t <- pars
176
- binOpParseHelp ' ^' (Expo t) <|> (return . NoExpo ) t
170
+ pars = Expo <$> pars
171
+
172
+ instance CanParse ExpoType where
173
+ pars = try (char ' ^' $> Expo' )
177
174
178
175
instance CanParse NumBase where
179
176
pars =
180
177
(NBParen . unnest <$> pars)
181
178
<|> Value <$> integer <??> " could not parse integer"
182
179
where
183
- unnest (Paren (Expr (SingBinOp (Term (SingBinOp (NoNeg (NoExpo ( NoFunc (NBase (NBParen e)))))))))) = e
180
+ unnest (Paren (Expr (SingBinOp (Term (SingBinOp (NoNeg (Expo ( SingBinOp ( NoFunc (NBase (NBParen e) )))))))))) = e
184
181
unnest e = e
185
182
186
183
instance (CanParse a ) => CanParse (Paren a ) where
@@ -285,7 +282,7 @@ instance ParseShow ArgValue where
285
282
instance ParseShow ListValues where
286
283
parseShow (LVBase e) = parseShow e
287
284
parseShow (MultipleValues nb b) = parseShow nb <> " #" <> parseShow b
288
- parseShow (LVFunc s n) = funcInfoName s <> " (" <> T. intercalate " ," (parseShow <$> n) <> " )"
285
+ parseShow (LVFunc s n) = funcInfoName s <> " (" <> T. intercalate " , " (parseShow <$> n) <> " )"
289
286
parseShow (LVVar t) = t
290
287
parseShow (ListValuesMisc l) = parseShow l
291
288
@@ -304,14 +301,14 @@ instance ParseShow ExprType where
304
301
parseShow Add = " +"
305
302
parseShow Sub = " -"
306
303
307
- instance ParseShow TermType where
308
- parseShow Multi = " *"
309
- parseShow Div = " /"
310
-
311
304
instance ParseShow Expr where
312
305
parseShow (Expr e) = parseShow e
313
306
parseShow (ExprMisc e) = parseShow e
314
307
308
+ instance ParseShow TermType where
309
+ parseShow Multi = " *"
310
+ parseShow Div = " /"
311
+
315
312
instance ParseShow Term where
316
313
parseShow (Term f) = parseShow f
317
314
@@ -323,9 +320,11 @@ instance ParseShow Negation where
323
320
parseShow (Neg expo) = " -" <> parseShow expo
324
321
parseShow (NoNeg expo) = parseShow expo
325
322
323
+ instance ParseShow ExpoType where
324
+ parseShow _ = " ^"
325
+
326
326
instance ParseShow Expo where
327
- parseShow (NoExpo b) = parseShow b
328
- parseShow (Expo b expo) = parseShow b <> " ^ " <> parseShow expo
327
+ parseShow (Expo e) = parseShow e
329
328
330
329
instance ParseShow NumBase where
331
330
parseShow (NBParen p) = parseShow p
0 commit comments