[ parens texpr
, spanned $ TVar <$> (bsf $ ident dynaVarStyle)
- , spanned $ mkta <$> (colon *> term) <* spaces <*> term
+ , spanned $ mkta <$> (colon *> term) <* whiteSpace <*> term
, try $ spanned $ TNumeric <$> naturalOrDouble
-- we hope is a rule.
rulepfx :: DeltaParsing f => f ([Spanned Term] -> Spanned Term -> Rule)
rulepfx = Rule <$> term
- <* spaces
+ <* whiteSpace
<*> (bsf $ ident dynaOperStyle <?> "Aggregator")
rule :: DeltaParsing m => m Rule
hrss = highlight ReservedOperator . spanned . symbol
drule :: DeltaParsing m => m (Spanned Rule)
-drule = spanned rule
+drule = unDL (spanned rule)
------------------------------------------------------------------------}}}
-- Lines {{{
progline :: DeltaParsing m => m (Spanned Line)
-progline = spanned $ choice [ LRule <$> drule
- , LPragma <$> (symbol ":-" *> spaces *> texpr)
- ]
+progline = do
+ whiteSpace
+ spanned (choice [ LRule <$> drule
+ , LPragma <$> (symbol ":-" *> whiteSpace *> texpr)
+ ])
dline :: DeltaParsing m => m (Spanned Line)
dline = unDL (progline <* optional (char '.') <* optional newline)
dlines :: DeltaParsing m => m [Spanned Line]
-dlines = unDL (progline `sepEndBy` (char '.' <* spaces))
+dlines = unDL (progline `sepEndBy` (char '.' <* whiteSpace))
------------------------------------------------------------------------}}}
-- import Control.Applicative ((<*))
import Data.ByteString (ByteString)
+import qualified Data.ByteString as B
-- import Data.Foldable (toList)
-- import Data.Monoid (mempty)
-- import qualified Data.Sequence as S
case_failIncompleteExpr = checkParseFail dterm "foo +"
"(interactive):1:5: error: expected: \"(\",\n end of input\nfoo +<EOF> "
+------------------------------------------------------------------------}}}
-- Annotations {{{
case_tyAnnot :: Assertion
]
sr = "goal += 1 . goal += 2 ."
+case_rulesWhitespace :: Assertion
+case_rulesWhitespace = e @=? (proglines sr)
+ where
+ e = [ LRule (Rule (TFunctor "goal" [] :~ Span (Columns 2 2) (Lines 1 1 16 1) l0)
+ "+="
+ []
+ (TNumeric (Left 1) :~ Span (Lines 1 4 19 4) (Lines 1 6 21 6) l1)
+ :~ Span (Columns 2 2) (Lines 1 6 21 6) l0)
+ :~ Span (Columns 2 2) (Lines 1 6 21 6) l0
+ , LRule (Rule (TFunctor "goal" [] :~ Span (Lines 3 1 31 1) (Lines 3 6 36 6) l3)
+ "+="
+ []
+ (TNumeric (Left 2) :~ Span (Lines 3 9 39 9) (Lines 3 11 41 11) l3)
+ :~ Span (Lines 3 1 31 1) (Lines 3 11 41 11) l3)
+ :~ Span (Lines 3 1 31 1) (Lines 3 11 41 11) " goal += 2 .\n"
+ ]
+ l0 = " goal%comment\n"
+ l1 = " += 1 .\n"
+ l2 = "%test \n"
+ l3 = " goal += 2 .\n"
+ sr = B.concat [l0,l1,l2,l3]
+
+
case_rulesDotExpr :: Assertion
case_rulesDotExpr = e @=? (proglines sr)
where