]> hydra-www.ietfng.org Git - dyna2/commitdiff
Add "for" as another spelling of "whenever"
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Thu, 16 May 2013 22:28:01 +0000 (18:28 -0400)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Thu, 16 May 2013 22:29:37 +0000 (18:29 -0400)
docs/TODO.LSA
examples/papa2.dyna
src/Dyna/Analysis/ANF.hs
src/Dyna/ParserHS/Parser.hs

index 208d0800372008fc6423d1d0f70bddbb4e914f13..b5936aafb3673df9234dbaa5e406cb3f6455ffae 100644 (file)
@@ -9,8 +9,6 @@ Utilities for encoding plain-text files to .dyna files.
 
 Parse QMode pragmas
 
-s/whenever/for/ in surface language
-
 List notation
 
 ----- Frontend
index ba13f92710acde91b3b0fe3c91ee45f1798caaf0..34f383faf36eaab6071b811348a6acf37a958441 100644 (file)
@@ -8,8 +8,8 @@ goal(P) max= phrase("S", 0, *length, P).
 
 best max= pair(phrase("S", 0, *length, P), P).
 
-bestScore max= pair(Score,_) is best, Score.
-bestParse max= pair(_,P) is best, P.
+bestScore max= Score for pair(Score,_) is best.
+bestParse max= P for pair(_,P) is best.
 
 length max= word(_, I), I+1.
 
index 42fb6daf2412b0b6a9ffdc12513c7a2a6c96e98c..7ad472ff42bac94ed111c841a285e572c025756d 100644 (file)
@@ -325,12 +325,14 @@ normTerm_ c   ss (P.TFunctor "is" [x T.:~ sx, v T.:~ sv]) = do
         _          -> do
                        NTVar `fmap` newAssign "_i" (Right ("is",[nx,nv]))
 
--- ",/2" and "whenever/2" are also reserved words of the language and get
--- handled here.
+-- ",/2", "whenever/2", and "for/2" are also reserved words of the language
+-- and get handled here.
 --
 -- XXX This is wrong, too, of course; these should really be moved into a
 -- standard prelude.  But there's no facility for that right now and no
 -- reason to make the backend know about them since that's also wrong!
+--
+-- XXX XREF:ANFRESERVED
 normTerm_ (_,ADEval) ss (P.TFunctor ","        [i T.:~ si, r T.:~ sr]) = do
     ni <- normTerm_ (ECFunctor, ADEval) (si:ss) i >>= newAssign "_e" . Left
     nv <- normTerm_ (ECFunctor, ADEval) (sr:ss) r >>= newAssign "_e" . Left
@@ -342,6 +344,9 @@ normTerm_ (_,ADEval) ss (P.TFunctor ","        [i T.:~ si, r T.:~ sr]) = do
 normTerm_ c@(_,ADEval) ss (P.TFunctor "whenever" [sr, si]) =
     normTerm_ c ss (P.TFunctor "," [si,sr])
 
+normTerm_ c@(_,ADEval) ss (P.TFunctor "for" [sr, si]) =
+    normTerm_ c ss (P.TFunctor "," [si,sr])
+
 -- Functors have both top-down and bottom-up dispositions on
 -- their handling.
 normTerm_ c   ss (P.TFunctor f as) = do
index 94607b1d0414fd6d80cc70112fa3d4dc0fc3852c..8bc4f424330b093a16183b4b8cdec74bd671a342 100644 (file)
@@ -13,7 +13,9 @@
 --
 --   * Doesn't handle parenthesized aggregators
 --
---   * Doesn't handle shared subgoals (\"whenever ... { ... }\")
+--   * Doesn't handle shared subgoals (\"for ... { ... }\")
+--     (Fixing that probably means changing our idea of 'Rule';
+--      also revisit XREF:ANFRESERVED if doing so.)
 --
 --   * Doesn't understand nullary star for gensym correctly
 --      (it's a available in term context but not texpr context;
@@ -203,7 +205,7 @@ defPCS = PCS { _pcs_dispostab = defDisposTab
                                -- The basic expression table for limited expressions.
                 --
                                -- Notably, this excludes @,@ (which is important
-                               -- syntactically) and @whenever@ and @is@ (which are
+                               -- syntactically), @for@, @whenever@, and @is@ (which are
                                -- nonsensical in local context)
                                -- XXX right now all binops are at equal precedence and
                                -- left-associative; that's wrong.
@@ -308,7 +310,7 @@ dynaAtomStyle = IdentifierStyle
   { _styleName = "Atom"
   , _styleStart    = (lower <|> oneOf "$")
   , _styleLetter   = (alphaNum <|> oneOf "_'")
-  , _styleReserved = H.fromList [ "is", "new", "whenever" ] -- XXX maybe not?
+  , _styleReserved = H.fromList [ "for", "is", "new", "whenever" ] -- XXX maybe not?
   , _styleHighlight = Constant
   , _styleReservedHighlight = ReservedOperator
   }
@@ -414,7 +416,8 @@ tlexpr = view pcs_opertab >>= flip buildExpressionParser term . unEOT
 moreETable :: DeltaParsing m => [[Operator m (Spanned Term)]]
 moreETable = [ [ Infix  (bf (spanned $ bsf $ symbol "is"      )) AssocNone  ]
              , [ Infix  (bf (spanned $ bsf $ symbol ","       )) AssocRight ]
-             , [ Infix  (bf (spanned $ bsf $ symbol "whenever")) AssocNone  ]
+             , [ Infix  (bf (spanned $ bsf $ symbol "whenever")) AssocNone
+               , Infix  (bf (spanned $ bsf $ symbol "for"     )) AssocNone  ]
              ]
 
 -- | Full Expression