wipp
This commit is contained in:
parent
8dc5cd3c17
commit
f87a3b72dd
@ -1,4 +1,5 @@
|
|||||||
{-# LANGUAGE MultilineStrings #-}
|
{-# LANGUAGE MultilineStrings #-}
|
||||||
|
{-# LANGUAGE BlockArguments #-}
|
||||||
|
|
||||||
module Datalog.Parser (
|
module Datalog.Parser (
|
||||||
parseTerm,
|
parseTerm,
|
||||||
@ -71,9 +72,31 @@ parseRule =
|
|||||||
bodyAtoms <- parseQuery
|
bodyAtoms <- parseQuery
|
||||||
period
|
period
|
||||||
return (Rule () headAtom bodyAtoms)
|
return (Rule () headAtom bodyAtoms)
|
||||||
|
parseRule' :: Parser (Rule' SrcLoc)
|
||||||
|
parseRule' = _
|
||||||
|
|
||||||
parseProgram :: Parser Program
|
-- parseProgram :: Parser Program
|
||||||
parseProgram = Program () <$> many parseRule
|
parseProgram :: Parser (Program' SrcLoc)
|
||||||
|
parseProgram = do
|
||||||
|
-- annotateSrcLoc $
|
||||||
|
s <- getSourcePos
|
||||||
|
c <- many parseRule'
|
||||||
|
e <- getSourcePos
|
||||||
|
-- Program _ <$> many parseRule
|
||||||
|
pure $ Program (SrcLoc s e) c
|
||||||
|
|
||||||
|
parseProgram' :: Parser (Program' SrcLoc)
|
||||||
|
parseProgram' = parseThingWithSub (many parseRule') Program
|
||||||
|
|
||||||
|
parseThingWithSub :: (Parser c) -> (SrcLoc -> c -> f SrcLoc) -> Parser (f SrcLoc)
|
||||||
|
parseThingWithSub parseSub f = do
|
||||||
|
-- annotateSrcLoc $
|
||||||
|
s <- getSourcePos
|
||||||
|
-- c <- many parseRule'
|
||||||
|
c <- parseSub
|
||||||
|
e <- getSourcePos
|
||||||
|
-- Program _ <$> many parseRule
|
||||||
|
pure $ f (SrcLoc s e) c
|
||||||
|
|
||||||
annotateSrcLoc :: (Functor f) => Parser (f a) -> Parser (f SrcLoc)
|
annotateSrcLoc :: (Functor f) => Parser (f a) -> Parser (f SrcLoc)
|
||||||
annotateSrcLoc p = do
|
annotateSrcLoc p = do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user