]> hydra-www.ietfng.org Git - dyna2/commitdiff
Remove defaults from operator parser
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Sun, 30 Jun 2013 06:42:09 +0000 (02:42 -0400)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Sun, 30 Jun 2013 06:42:09 +0000 (02:42 -0400)
(Some unit-tests keep them on for the moment)

src/Dyna/ParserHS/OneshotDriver.hs
src/Dyna/ParserHS/Selftest.hs
src/Dyna/Term/SurfaceSyntax.hs

index 79347bc48a05afc025529d5ac1ed0bf6840cb028..0ad2f78d5cf93022eb75a5508f4b24e3631a8f14 100644 (file)
@@ -97,7 +97,7 @@ update_pcs_dt,
 update_pcs_dt = pcs_dt_cache <~
                 liftA2 ($) (uses pcs_dt_mk dtmk) (use pcs_dt_over)
 
-update_pcs_ot = pcs_ot_cache <~ (flip mkEOT True <$> (use pcs_operspec))
+update_pcs_ot = pcs_ot_cache <~ (flip mkEOT False <$> (use pcs_operspec))
 
 dtmk :: String -> DisposTabOver -> DisposTab
 dtmk "dyna"      = disposTab_dyna
@@ -129,7 +129,7 @@ defPCS = PCS { _pcs_dt_mk     = "dyna"
              , _pcs_modemap   = mempty -- XXX
 
              , _pcs_operspec  = defOperSpec
-             , _pcs_ot_cache  = mkEOT (defPCS ^. pcs_operspec) True
+             , _pcs_ot_cache  = mkEOT (defPCS ^. pcs_operspec) False
 
              , _pcs_ruleix    = 0
              }
index ea6d5628f786769e4e37c5661cf34f8c1ff45987..3cf851538b72780475b067aff01be1d2e303b28a 100644 (file)
@@ -50,6 +50,8 @@ _tNumeric = TBase . TNumeric
 
 defDLC :: DLCfg
 defDLC = DLC (mkEOT defOperSpec True) genericAggregators
+-- quasiDLC :: DLCfg
+-- quasiDLC = DLC (mkEOT defOperSpec False) genericAggregators
 
 term :: ByteString -> Spanned Term
 term = unsafeParse (testTerm defDLC <* eof)
index 823370ff9276fa391604f7826fcf5e69f5ae2e44..fc325fe2400cd31541f8d3ae85822a0d42013ea5 100644 (file)
@@ -11,7 +11,9 @@ module Dyna.Term.SurfaceSyntax where
 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(..))
 
 ------------------------------------------------------------------------}}}
@@ -22,11 +24,22 @@ 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"
 
 ------------------------------------------------------------------------}}}
@@ -48,29 +61,35 @@ type OperSpec = M.Map String [(Int, Fixity)]
 --
 -- 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                                               {{{