File tree 6 files changed +29
-32
lines changed
6 files changed +29
-32
lines changed Original file line number Diff line number Diff line change @@ -68,8 +68,8 @@ expr1 = do
68
68
case getPrimes primes of
69
69
" " -> return e
70
70
cs -> return $ case e of
71
- ESub b sub -> ESubsup b sub (ESymbol Ord (T. pack cs))
72
- _ -> ESuper e (ESymbol Ord (T. pack cs))
71
+ ESub b sub -> ESubsup b sub (ESymbol Pun (T. pack cs))
72
+ _ -> ESuper e (ESymbol Pun (T. pack cs))
73
73
74
74
expr2 :: TP Exp
75
75
expr2 = choice
Original file line number Diff line number Diff line change @@ -362,13 +362,16 @@ isUppercaseGreek t = not (T.null t) && T.all isUGreek t
362
362
where
363
363
isUGreek c = c >= ' \x0391 ' && c <= ' \x03A9 '
364
364
365
- toPrimes :: T. Text -> Maybe T. Text
366
- toPrimes t =
367
- case T. uncons t of
368
- Nothing -> Just " "
369
- Just (' \' ' , t') -> (" '" <> ) <$> toPrimes t'
370
- Just (' \x2032 ' , t') -> (" '" <> ) <$> toPrimes t'
371
- Just (' \x2033 ' , t') -> (" ''" <> ) <$> toPrimes t'
372
- Just (' \x2034 ' , t') -> (" '''" <> ) <$> toPrimes t'
373
- Just (' \x2057 ' , t') -> (" ''''" <> ) <$> toPrimes t'
374
- _ -> Nothing
365
+ toPrimes :: Exp -> Maybe T. Text
366
+ toPrimes (ESymbol ty s) | ty == Pun || ty == Ord = go s
367
+ where
368
+ go t =
369
+ case T. uncons t of
370
+ Nothing -> Just " "
371
+ Just (' \' ' , t') -> (" '" <> ) <$> go t'
372
+ Just (' \x2032 ' , t') -> (" '" <> ) <$> go t'
373
+ Just (' \x2033 ' , t') -> (" ''" <> ) <$> go t'
374
+ Just (' \x2034 ' , t') -> (" '''" <> ) <$> go t'
375
+ Just (' \x2057 ' , t') -> (" ''''" <> ) <$> go t'
376
+ _ -> Nothing
377
+ toPrimes _ = Nothing
Original file line number Diff line number Diff line change @@ -165,15 +165,13 @@ writeExp (EFraction fractype e1 e2) = writeExp' e1 <> op <> writeExp' e2
165
165
else " over "
166
166
writeExp (ESub b e1) = writeExp' b <> " sub " <> writeExp' e1
167
167
writeExp (ESuper b e1) = writeExp' b <>
168
- case e1 of
169
- ESymbol Ord s
170
- | Just ps <- toPrimes s -> ps
168
+ case toPrimes e1 of
169
+ Just ps -> ps
171
170
_ -> " sup " <> writeExp' e1
172
171
writeExp (ESubsup b e1 e2) =
173
172
writeExp' b <> " sub " <> writeExp' e1 <>
174
- case e2 of
175
- ESymbol Ord s
176
- | Just cs <- toPrimes s -> writeExp' b <> cs
173
+ case toPrimes e2 of
174
+ Just ps -> ps
177
175
_ -> " sup " <> writeExp' e2
178
176
writeExp (EOver _convertible b e1) =
179
177
writeExp' b <> " to " <> writeExp' e1
Original file line number Diff line number Diff line change @@ -199,18 +199,16 @@ writeExp (ESub b e1) = do
199
199
tellGroup (writeExp e1)
200
200
writeExp (ESuper b e1) = do
201
201
(if isFancy b then tellGroup else id ) $ writeExp b
202
- case e1 of
203
- ESymbol Ord s
204
- | Just ps <- S. toPrimes s -> tell (replicate (T. length ps) (Token ' \' ' ))
202
+ case S. toPrimes e1 of
203
+ Just ps -> tell (replicate (T. length ps) (Token ' \' ' ))
205
204
_ -> do tell [Token ' ^' ]
206
205
tellGroup (writeExp e1)
207
206
writeExp (ESubsup b e1 e2) = do
208
207
(if isFancy b then tellGroup else id ) $ writeExp b
209
208
tell [Token ' _' ]
210
209
tellGroup (writeExp e1)
211
- case e2 of
212
- ESymbol Ord s
213
- | Just ps <- S. toPrimes s -> tell (replicate (T. length ps) (Token ' \' ' ))
210
+ case S. toPrimes e2 of
211
+ Just ps -> tell (replicate (T. length ps) (Token ' \' ' ))
214
212
_ -> do tell [Token ' ^' ]
215
213
tellGroup (writeExp e2)
216
214
writeExp (EOver convertible b e1) = do
Original file line number Diff line number Diff line change @@ -140,14 +140,12 @@ writeExp (EFraction _fractype e1 e2) =
140
140
_ -> writeExp e1 <> " / " <> writeExp e2
141
141
writeExp (ESub b e1) = writeExpB b <> " _" <> writeExpS e1
142
142
writeExp (ESuper b e1) = writeExpB b <>
143
- case e1 of
144
- ESymbol Ord t
145
- | Just ps <- S. toPrimes t -> ps
143
+ case S. toPrimes e1 of
144
+ Just ps -> ps
146
145
_ -> " ^" <> writeExpS e1
147
146
writeExp (ESubsup b e1 e2) = writeExpB b <> " _" <> writeExpS e1 <>
148
- case e2 of
149
- ESymbol Ord t
150
- | Just ps <- S. toPrimes t -> ps
147
+ case S. toPrimes e2 of
148
+ Just ps -> ps
151
149
_ -> " ^" <> writeExpS e2
152
150
writeExp (EOver _ (EOver _ b (ESymbol TOver " \9182" )) e1) =
153
151
" overbrace(" <> writeExp b <> " , " <> writeExp e1 <> " )"
Original file line number Diff line number Diff line change @@ -3,13 +3,13 @@ u'' + p(x)u' + q(x)u=f(x),\quad x>a
3
3
4
4
5
5
>>> native
6
- [ ESuper (EIdentifier "u") (ESymbol Ord "\8243")
6
+ [ ESuper (EIdentifier "u") (ESymbol Pun "\8243")
7
7
, ESymbol Bin "+"
8
8
, EIdentifier "p"
9
9
, ESymbol Open "("
10
10
, EIdentifier "x"
11
11
, ESymbol Close ")"
12
- , ESuper (EIdentifier "u") (ESymbol Ord "\8242")
12
+ , ESuper (EIdentifier "u") (ESymbol Pun "\8242")
13
13
, ESymbol Bin "+"
14
14
, EIdentifier "q"
15
15
, ESymbol Open "("
You can’t perform that action at this time.
0 commit comments