import qualified Data.ByteString.UTF8 as BU
import qualified Data.Char as C
import qualified Data.Map as M
+import Data.String
import Dyna.Term.TTerm
+import Dyna.XXX.DataUtils
import Text.Parser.Expression (Assoc(..))
------------------------------------------------------------------------}}}
-- If we ever revisit the structure of rules, cross-ref XREF:ANFRESERVED and
-- maybe move all of this into the parser proper.
+dynaEvalOper :: (IsString s) => s
dynaEvalOper = "*"
+
+dynaQuoteOper :: (IsString s) => s
dynaQuoteOper = "&"
+
+dynaEvalAssignOper :: (IsString s) => s
dynaEvalAssignOper = "is"
+
+dynaConjOper :: (IsString s) => s
dynaConjOper = ","
+
+dynaRevConjOpers :: (IsString s) => [s]
dynaRevConjOpers = ["whenever","for"]
+
+dynaUnitTerm :: (IsString s) => s
dynaUnitTerm = "true"
------------------------------------------------------------------------}}}
--
-- The precedence and fixity here are mostly as per Haskell 98.
defOperSpec :: OperSpec
-defOperSpec = M.fromList
- [ ("-" ,[(6,PFIn AssocLeft ), (9, PFPre)])
- , ("^" ,[(8,PFIn AssocLeft ) ])
- , ("|" ,[(2,PFIn AssocRight) ])
- , ("/" ,[(7,PFIn AssocLeft ) ])
- , ("*" ,[(7,PFIn AssocLeft ) ])
- , ("**" ,[(8,PFIn AssocRight) ])
- , ("&" ,[(3,PFIn AssocRight) ])
- , ("%" ,[(7,PFIn AssocLeft ) ])
- , ("+" ,[(6,PFIn AssocLeft ) ])
-
- , ("<=" ,[(4,PFIn AssocNone ) ])
- , ("<" ,[(4,PFIn AssocNone ) ])
- , ("=" ,[(4,PFIn AssocNone ) ])
- , ("==" ,[(4,PFIn AssocNone ) ])
- , (">=" ,[(4,PFIn AssocNone ) ])
- , (">" ,[(4,PFIn AssocNone ) ])
- , ("!=" ,[(4,PFIn AssocNone ) ])
-
- , ("!" ,[(9,PFPre) ])
-
- , ("new",[(0,PFPre)])
- ]
+defOperSpec = foldr (\(k,v) -> mapInOrCons k v) def more
+ where
+ def = M.fromList
+ [ ("-" ,[(6,PFIn AssocLeft ), (9, PFPre)])
+ , ("^" ,[(8,PFIn AssocLeft ) ])
+ , ("|" ,[(2,PFIn AssocRight) ])
+ , ("/" ,[(7,PFIn AssocLeft ) ])
+ , ("*" ,[(7,PFIn AssocLeft ) ])
+ , ("**" ,[(8,PFIn AssocRight) ])
+ , ("&" ,[(3,PFIn AssocRight) ])
+ , ("%" ,[(7,PFIn AssocLeft ) ])
+ , ("+" ,[(6,PFIn AssocLeft ) ])
+
+ , ("<=" ,[(4,PFIn AssocNone ) ])
+ , ("<" ,[(4,PFIn AssocNone ) ])
+ , ("=" ,[(4,PFIn AssocNone ) ])
+ , ("==" ,[(4,PFIn AssocNone ) ])
+ , (">=" ,[(4,PFIn AssocNone ) ])
+ , (">" ,[(4,PFIn AssocNone ) ])
+ , ("!=" ,[(4,PFIn AssocNone ) ])
+
+ , ("!" ,[(9,PFPre) ])
+
+ , ("new",[(0,PFPre) ])
+ ]
+
+ more = [(dynaQuoteOper, (9,PFPre))
+ ,(dynaEvalOper, (9,PFPre))
+ ]
------------------------------------------------------------------------}}}
-- Evaluation Disposition {{{