Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Support variables with numbers

  • Loading branch information...
commit 76b5a0cfff2bd54c93c472547d6e7df42592faf8 1 parent 208eb52
@norm2782 norm2782 authored
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/Language/Prolog/NanoProlog/NanoProlog.hs
View
8 src/Language/Prolog/NanoProlog/NanoProlog.hs
@@ -117,7 +117,7 @@ enumerateDepthFirst proofs (ApplyRules bs) =
{-
-- | `enumerateBreadthFirst` is still undefined, and is left as an
-- exercise to the JCU students
-enumerateBreadthFirst :: Proofs -> [String] -> Result -> [(Proofs, Env)]
+enumerateBreadthFirst :: Proofs -> Result -> [(Proofs, Env)]
-}
-- | `printEnv` prints a single solution, showing only the variables
@@ -144,14 +144,14 @@ showCommas :: Show a => [a] -> String
showCommas l = intercalate ", " (map show l)
-- ** Parsing Rules and Terms
-startParse :: (ListLike s b, Show b) => P (Str b s LineColPos) a -> s
- -> (a, [Error LineColPos])
+startParse :: (ListLike s b, Show b) => P (Str b s LineColPos) a -> s
+ -> (a, [Error LineColPos])
startParse p inp = parse ((,) <$> p <*> pEnd)
$ createStr (LineColPos 0 0 0) inp
pTerm, pVar, pFun :: Parser Term
pTerm = pVar <|> pFun
-pVar = Var <$> lexeme (pList1 pUpper)
+pVar = Var <$> lexeme ((++) <$> pList1 pUpper <*> pList pDigit)
pFun = Fun <$> pLowerCase <*> (pParens pTerms `opt` [])
where pLowerCase :: Parser String
pLowerCase = (:) <$> pLower <*> lexeme (pList (pLetter <|> pDigit))
Please sign in to comment.
Something went wrong with that request. Please try again.