From: Nathaniel Wesley Filardo Date: Sun, 30 Jun 2013 06:42:09 +0000 (-0400) Subject: Remove defaults from operator parser X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=1f50446bb5a90a1f6cea4044af5c81adbf37ea71;p=dyna2 Remove defaults from operator parser (Some unit-tests keep them on for the moment) --- diff --git a/src/Dyna/ParserHS/OneshotDriver.hs b/src/Dyna/ParserHS/OneshotDriver.hs index 79347bc..0ad2f78 100644 --- a/src/Dyna/ParserHS/OneshotDriver.hs +++ b/src/Dyna/ParserHS/OneshotDriver.hs @@ -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 } diff --git a/src/Dyna/ParserHS/Selftest.hs b/src/Dyna/ParserHS/Selftest.hs index ea6d562..3cf8515 100644 --- a/src/Dyna/ParserHS/Selftest.hs +++ b/src/Dyna/ParserHS/Selftest.hs @@ -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) diff --git a/src/Dyna/Term/SurfaceSyntax.hs b/src/Dyna/Term/SurfaceSyntax.hs index 823370f..fc325fe 100644 --- a/src/Dyna/Term/SurfaceSyntax.hs +++ b/src/Dyna/Term/SurfaceSyntax.hs @@ -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 {{{