scanl (\exp y -> scanl (\x -> if (isLetter x) then update exp (Literal x) "" else
if x=='+' then update exp Epsilon "+" else
if x=='*' then update exp Epsilon "*" else
update exp Epsilon "|") y) Epsilon q
我的数据类型是:
data Reg = Epsilon | Literal Char | Or Reg Reg | Then Reg Reg | Star Reg deriving Eq
和
update:: Reg -> Reg -> [Char] -> Reg
update a b "" = (a `Then` b)
update a b "|"= (a `Or` b)
update a b "*" = (Star a)
update a b "+" = (plus a)
update a b "?" = (opt a)
我正在尝试使用上述函数将此类[“a |”,“bc”]之类的内容转换为(然后a(或b c)),我无法使用ParSec。