Commit 4a211484 authored by Herbert Valerio Riedel's avatar Herbert Valerio Riedel 🕺

Merge branch 'master'

parents 89d4541f db04c1fd
......@@ -61,7 +61,7 @@ with the `ghci` command).
```
Prelude> :m +Text.Parsec
Prelude Text.Parsec> let parenSet = char '(' >> many parenSet >> char ')'
Prelude Text.Parsec> let parenSet = char '(' >> many parenSet >> char ')' :: Parsec String () Char
Loading package transformers-0.3.0.0 ... linking ... done.
Loading package array-0.5.0.0 ... linking ... done.
Loading package deepseq-1.3.0.2 ... linking ... done.
......
......@@ -186,7 +186,7 @@ chainl p op x = chainl1 p op <|> return x
-- | @chainl1 p op@ parses /one/ or more occurrences of @p@,
-- separated by @op@ Returns a value obtained by a /left/ associative
-- application of all functions returned by @op@ to the values returned
-- by @p@. . This parser can for example be used to eliminate left
-- by @p@. This parser can for example be used to eliminate left
-- recursion which typically occurs in expression grammars.
--
-- > expr = term `chainl1` addop
......
......@@ -108,14 +108,14 @@ buildExpressionParser operators simpleExpr
prefixOp = choice prefix <?> ""
postfixOp = choice postfix <?> ""
ambigious assoc op= try $
ambiguous assoc op= try $
do{ _ <- op; fail ("ambiguous use of a " ++ assoc
++ " associative operator")
}
ambigiousRight = ambigious "right" rassocOp
ambigiousLeft = ambigious "left" lassocOp
ambigiousNon = ambigious "non" nassocOp
ambiguousRight = ambiguous "right" rassocOp
ambiguousLeft = ambiguous "left" lassocOp
ambiguousNon = ambiguous "non" nassocOp
termP = do{ pre <- prefixP
; x <- term
......@@ -131,8 +131,8 @@ buildExpressionParser operators simpleExpr
; y <- do{ z <- termP; rassocP1 z }
; return (f x y)
}
<|> ambigiousLeft
<|> ambigiousNon
<|> ambiguousLeft
<|> ambiguousNon
-- <|> return x
rassocP1 x = rassocP x <|> return x
......@@ -141,17 +141,17 @@ buildExpressionParser operators simpleExpr
; y <- termP
; lassocP1 (f x y)
}
<|> ambigiousRight
<|> ambigiousNon
<|> ambiguousRight
<|> ambiguousNon
-- <|> return x
lassocP1 x = lassocP x <|> return x
nassocP x = do{ f <- nassocOp
; y <- termP
; ambigiousRight
<|> ambigiousLeft
<|> ambigiousNon
; ambiguousRight
<|> ambiguousLeft
<|> ambiguousNon
<|> return (f x y)
}
-- <|> return x
......
......@@ -125,7 +125,7 @@ unexpected msg
-- | @ParsecT s u m a@ is a parser with stream type @s@, user state type @u@,
-- underlying monad @m@ and return type @a@. Parsec is strict in the user state.
-- If this is undesirable, simply used a data type like @data Box a = Box a@ and
-- If this is undesirable, simply use a data type like @data Box a = Box a@ and
-- the state type @Box YourStateType@ to add a level of indirection.
newtype ParsecT s u m a
......@@ -510,7 +510,7 @@ lookAhead p =
-- This combinator is expressed in terms of 'tokenPrim'.
-- It is used to accept user defined token streams. For example,
-- suppose that we have a stream of basic tokens tupled with source
-- positions. We can than define a parser that accepts single tokens as:
-- positions. We can then define a parser that accepts single tokens as:
--
-- > mytoken x
-- > = token showTok posFromTok testTok
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment