wasp/waspc/test/Analyzer/TestUtil.hs
Craig McIlwrath 0de0855787
Integrate new error resilient parser into waspc (#684)
* Add CST parsing code into waspc

* Implement CST -> AST conversion

* Implement parseExpression & isValidWaspIdentifier

* Implement golden tests for Parser

* Configure CI git checkout to always use LF line endings
2022-08-11 12:26:12 -04:00

20 lines
596 B
Haskell

module Analyzer.TestUtil where
import qualified Wasp.Analyzer.Parser as P
import qualified Wasp.Analyzer.TypeChecker as T
pos :: Int -> Int -> P.SourcePosition
pos line column = P.SourcePosition line column
rgn :: (Int, Int) -> (Int, Int) -> P.SourceRegion
rgn (sl, sc) (el, ec) = P.SourceRegion (pos sl sc) (pos el ec)
ctx :: (Int, Int) -> (Int, Int) -> P.Ctx
ctx (a, b) (c, d) = P.ctxFromRgn (pos a b) (pos c d)
wctx :: (Int, Int) -> (Int, Int) -> a -> P.WithCtx a
wctx start end = P.WithCtx (ctx start end)
fromWithCtx :: P.WithCtx T.TypedExpr -> T.TypedExpr
fromWithCtx = P.fromWithCtx