@@ -0,0 +1,51 @@
1+{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
3+module ShellParser(parseCommand, parseTactic) where
9+import Text.ParserCombinators.Parsec
10+import Text.ParserCombinators.Parsec.Expr
11+import Text.ParserCombinators.Parsec.Language
12+import qualified Text.ParserCombinators.Parsec.Token as PTok
16+type TokenParser a = PTok.TokenParser a
18+lexer :: TokenParser ()
19+lexer = PTok.makeTokenParser haskellDef
21+whiteSpace= PTok.whiteSpace lexer
22+lexeme = PTok.lexeme lexer
23+symbol = PTok.symbol lexer
24+natural = PTok.natural lexer
25+parens = PTok.parens lexer
26+semi = PTok.semi lexer
27+comma = PTok.comma lexer
28+identifier= PTok.identifier lexer
29+reserved = PTok.reserved lexer
30+operator = PTok.operator lexer
31+reservedOp= PTok.reservedOp lexer
34+parseCommand = parse pCommand "(input)"
35+parseTactic = parse pTactic "(input)"
37+pCommand :: Parser Command
38+pCommand = do reserved "theorem"; n <- identifier; lchar ':'; ty <- pTerm
39+ return (Theorem (UN [n]) ty)
40+ <|> do reserved "eval"; tm <- pTerm
42+ <|> do reserved "quit";
45+pTactic :: Parser Tactic
46+pTactic = do reserved "attack"; return Attack
47+ <|> do reserved "claim"; ty <- pTerm; return (Claim ty)
48+ <|> do reserved "try"; tm <- pTerm; return (Try tm)
49+ <|> do reserved "regret"; return Regret
50+ <|> do reserved "solve"; return Solve
51+ <|> do reserved "fill"; tm <- pTerm; return (Fill tm)