Parse QMode pragmas
-s/whenever/for/ in surface language
-
List notation
----- Frontend
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.
_ -> 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
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
--
-- * 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;
-- 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.
{ _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
}
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