Compare commits
No commits in common. "27eb944b071e777b4450eadf1f76cd6a95e94fc9" and "7ac8aef519995090167496f67b7fa0e106198e6a" have entirely different histories.
27eb944b07
...
7ac8aef519
@ -25,7 +25,7 @@ initHandler = notificationHandler SMethod_Initialized $ \_ -> pure ()
|
||||
serverDefinition :: LSPState -> ServerDefinition LSPState
|
||||
serverDefinition context =
|
||||
ServerDefinition
|
||||
{ parseConfig = \c _ -> Right c
|
||||
{ parseConfig = \c v -> Right c
|
||||
, onConfigChange = const $ pure ()
|
||||
, defaultConfig = context
|
||||
, configSection = "demo"
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
{-# LANGUAGE BlockArguments #-}
|
||||
{-# LANGUAGE MultilineStrings #-}
|
||||
{- HLINT ignore "Use void" -}
|
||||
|
||||
module Datalog.Parser (
|
||||
parseTerm,
|
||||
@ -13,11 +12,12 @@ where
|
||||
import Data.Text (Text)
|
||||
import Data.Text qualified as T
|
||||
import Data.Void (Void)
|
||||
import Datalog.Syntax (Atom' (..), Program' (..), Rule' (..))
|
||||
import Datalog.Syntax (Atom' (..), Program' (..), Rule' (..), Term' (..))
|
||||
import Datalog.Syntax hiding (Atom, Program, Rule, Term)
|
||||
import Text.Megaparsec
|
||||
import Text.Megaparsec.Char
|
||||
import Text.Megaparsec.Char.Lexer qualified as L
|
||||
import Text.Pretty.Simple
|
||||
|
||||
type Parser = Parsec Void Text
|
||||
|
||||
@ -96,3 +96,22 @@ parseThingWithSub f parseSub = do
|
||||
c <- parseSub
|
||||
SourcePos _ el ec <- getSourcePos
|
||||
pure $ f (SrcLoc (unPos sl) (unPos sc) (unPos el) (unPos ec)) c
|
||||
|
||||
test = do
|
||||
let r = runParser parseProgram "???" prog
|
||||
pPrint @IO r
|
||||
|
||||
prog =
|
||||
"""
|
||||
odd(X,Y) :- r(X,Y).
|
||||
odd(X,Y) :- even(X,Z), r(Z,Y).
|
||||
even(X,Y) :- odd(X,Z), r(Z,Y).
|
||||
|
||||
r(0,1).
|
||||
r(1,2).
|
||||
r(2,3).
|
||||
r(3,4).
|
||||
r(4,5).
|
||||
|
||||
r(X,Y) :- r(Y,X).
|
||||
"""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user