module BNFC.Backend.Agda.Lexer where import BNFC.CF import BNFC.Options.GlobalOptions import BNFC.Prelude import BNFC.Backend.Agda.Options import BNFC.Backend.Agda.State import BNFC.Backend.CommonInterface.Backend import BNFC.Backend.Haskell.Options (TokenText (..)) import BNFC.Backend.Haskell.Utilities.Utils import BNFC.Backend.Haskell.Layout (cf2layout) import BNFC.Backend.Haskell.Lexer (cf2lexer) import Control.Monad.State import System.FilePath ( takeBaseName ) agdaLexer :: LBNF -> State AgdaBackendState Result agdaLexer lbnf = do st <- get let cfName = takeBaseName $ optInput $ globalOpt st inDirectory = inDir $ agdaOpts st nSpace = nameSpace $ agdaOpts st toks = lexerParserTokens st lexerSpecification = cf2lexer lbnf cfName inDirectory nSpace TextToken toks layout = cf2layout lbnf cfName inDirectory nSpace return $ if layoutsAreUsed lbnf then (mkFilePath inDirectory nSpace cfName "Lex" "x", lexerSpecification) : [(mkFilePath inDirectory nSpace cfName "Layout" "hs", layout)] else [(mkFilePath inDirectory nSpace cfName "Lex" "x", lexerSpecification)]