Skip to content
Browse files

* Priority fix

* Other parse fix (spaces)
  • Loading branch information...
1 parent 9963131 commit 9896851754d00b4afcaa4791a0ac7769ee24fb41 @spockz committed
Showing with 14 additions and 6 deletions.
  1. +2 −2 src/Language/Prolog/NanoProlog/NanoProlog.hs
  2. +12 −4 src/Language/Prolog/NanoProlog/ParserUUTC.hs
View
4 src/Language/Prolog/NanoProlog/NanoProlog.hs
@@ -16,7 +16,7 @@ module Language.Prolog.NanoProlog.NanoProlog (
, solve
, unify
) where
-
+
import Data.List (intercalate)
import Data.Map (Map)
import qualified Data.Map as M
@@ -55,7 +55,7 @@ emptyEnv = Just (Env M.empty)
-- * The Prolog machinery
-- The result type contains a search tree, where the branches represent an application of a rule, and the
-- leaves succesful results. Successes are represented by their corresponding substitution.
--- A branch is represented by the tag used to loabel the rule that was applied, by the rule that was applied,
+-- A branch is represented by the tag used to label the rule that was applied, by the rule that was applied,
-- and by the ``continution'' of the search.
data Result = Done Env
View
16 src/Language/Prolog/NanoProlog/ParserUUTC.hs
@@ -9,10 +9,17 @@ module Language.Prolog.NanoProlog.ParserUUTC (
import Control.Applicative ((<**>))
import Language.Prolog.NanoProlog.NanoProlog
-import ParseLib.Abstract
+import ParseLib.Abstract hiding ( token, symbol )
+import qualified ParseLib.Abstract as PL ( token, symbol )
spaces :: Parser Char String
-spaces = many (choice [symbol ' ', symbol '\r', symbol '\n', symbol '\t'])
+spaces = many (choice [PL.symbol ' ', PL.symbol '\r', PL.symbol '\n', PL.symbol '\t'])
+
+token :: String -> Parser Char String
+token t = PL.token t <* spaces
+
+symbol :: Char -> Parser Char Char
+symbol c = PL.symbol c <* spaces
lexeme :: Parser Char a -> Parser Char a
lexeme p = p <* spaces
@@ -41,7 +48,7 @@ pFun = Fun <$> pLowerCase <*> (parenthesised pTerms `opt` [])
pVar = Var <$> lexeme ((++) <$> many1 pUpper <*> (concat <$> pSepDot (many1 pDigit) `opt` []))
pRange :: (Enum a, Eq a) => (a, a) -> Parser a a
-pRange (b, e) = choice (map symbol [b..e])
+pRange (b, e) = choice (map PL.symbol [b..e])
pUpper, pLower, pLetter, pDigit :: Parser Char Char
pUpper = pRange ('A', 'Z')
@@ -56,7 +63,8 @@ pTerms :: Parser Char [Term]
pTerms = listOf pTerm (symbol ',')
pRule :: Parser Char Rule
-pRule = (:<-:) <$> pFun <*> (token ":-" *> pTerms `opt` []) <* pDot
+pRule = (:<-:) <$> pFun <*> ((token ":-" *> pTerms) `opt` []) <* pDot
+-- pRule = (:<-:) <$> pFun <*> (pure []) <* pDot
startParse :: Parser s a -> [s] -> [(a,[s])]
startParse p = parse (p <* eof)

0 comments on commit 9896851

Please sign in to comment.
Something went wrong with that request. Please try again.