module Language.Cimple
    ( module X
    , DefaultActions
    , defaultActions
    , removeSloc
    ) where

import           Control.Monad.State.Strict (State)
import qualified Control.Monad.State.Strict as State
import           Data.Text                  (Text)

import           Language.Cimple.Annot      as X
import           Language.Cimple.Ast        as X
import           Language.Cimple.Lexer      as X
import           Language.Cimple.MapAst     as X
import           Language.Cimple.Parser     as X
import           Language.Cimple.Tokens     as X

type DefaultActions a = X.IdentityActions (State a) Text

defaultActions :: DefaultActions state
defaultActions :: forall state. DefaultActions state
defaultActions = AstActions (State state) Text Text
forall (f :: * -> *) text. Applicative f => AstActions f text text
X.identityActions

removeSloc :: Node (Lexeme Text) -> Node (Lexeme Text)
removeSloc :: Node (Lexeme Text) -> Node (Lexeme Text)
removeSloc =
    (State () (Node (Lexeme Text)) -> () -> Node (Lexeme Text))
-> () -> State () (Node (Lexeme Text)) -> Node (Lexeme Text)
forall a b c. (a -> b -> c) -> b -> a -> c
flip State () (Node (Lexeme Text)) -> () -> Node (Lexeme Text)
forall s a. State s a -> s -> a
State.evalState () (State () (Node (Lexeme Text)) -> Node (Lexeme Text))
-> (Node (Lexeme Text) -> State () (Node (Lexeme Text)))
-> Node (Lexeme Text)
-> Node (Lexeme Text)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AstActions (StateT () Identity) Text Text
-> Node (Lexeme Text)
-> StateT () Identity (Mapped Text Text (Node (Lexeme Text)))
forall itext otext a (f :: * -> *).
(MapAst itext otext a, Applicative f) =>
AstActions f itext otext -> a -> f (Mapped itext otext a)
mapAst AstActions (StateT () Identity) Text Text
forall state. DefaultActions state
defaultActions
        { doLexeme :: FilePath
-> Lexeme Text -> State () (Lexeme Text) -> State () (Lexeme Text)
doLexeme = \FilePath
_ (L AlexPosn
_ LexemeClass
c Text
t) State () (Lexeme Text)
_ -> Lexeme Text -> State () (Lexeme Text)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Lexeme Text -> State () (Lexeme Text))
-> Lexeme Text -> State () (Lexeme Text)
forall a b. (a -> b) -> a -> b
$ AlexPosn -> LexemeClass -> Text -> Lexeme Text
forall text. AlexPosn -> LexemeClass -> text -> Lexeme text
L (Int -> Int -> Int -> AlexPosn
AlexPn Int
0 Int
0 Int
0) LexemeClass
c Text
t }