diff options
author | simonmar <unknown> | 2002-05-29 13:19:06 +0000 |
---|---|---|
committer | simonmar <unknown> | 2002-05-29 13:19:06 +0000 |
commit | 9234389c497a80edd0cdb5cc050f1d95eaa4552c (patch) | |
tree | 1e02fbcacadbc077f4eeb56da827f44580e0a1b9 /src/HaddockParse.y | |
parent | 093f7e538e89d8f9a1f8362ba76a233b7c286a4f (diff) |
[haddock @ 2002-05-29 13:19:06 by simonmar]
Make the markup syntax a little more friendly:
- single quotes are now interpreted literally unless they surround a
valid Haskell identifier. So for example now there's no need to
escape a single quote used as an apostrophe.
- text to the right of a bird track is now literal (if you want
marked-up text in a code block, use @...@).
Diffstat (limited to 'src/HaddockParse.y')
-rw-r--r-- | src/HaddockParse.y | 41 |
1 files changed, 4 insertions, 37 deletions
diff --git a/src/HaddockParse.y b/src/HaddockParse.y index f74d2b69..d9de9110 100644 --- a/src/HaddockParse.y +++ b/src/HaddockParse.y @@ -3,21 +3,18 @@ module HaddockParse (parseParas, parseString) where import HaddockLex import HsSyn -import HsLexer hiding (Token) -import HsParseMonad } %tokentype { Token } -%token SQUO { TokSpecial '\'' } - BQUO { TokSpecial '`' } - DQUO { TokSpecial '\"' } - '/' { TokSpecial '/' } +%token '/' { TokSpecial '/' } '@' { TokSpecial '@' } + DQUO { TokSpecial '\"' } URL { TokURL $$ } '*' { TokBullet } '(n)' { TokNumber } '>' { TokBirdTrack } + IDENT { TokIdent $$ } PARA { TokPara } STRING { TokString $$ } @@ -69,13 +66,9 @@ elem1 :: { Doc } : STRING { DocString $1 } | '/' STRING '/' { DocEmphasis (DocString $2) } | URL { DocURL $1 } - | squo STRING squo { strToHsQNames $2 } + | IDENT { DocIdentifier $1 } | DQUO STRING DQUO { DocModule $2 } -squo :: { () } - : SQUO { () } - | BQUO { () } - { happyError :: [Token] -> Either String a happyError toks = @@ -88,30 +81,4 @@ instance Monad (Either String) where Left l >>= _ = Left l Right r >>= k = k r fail msg = Left msg - -strToHsQNames :: String -> Doc -strToHsQNames str - = case lexer (\t -> returnP t) str (SrcLoc 1 1) 1 1 [] of - Ok _ (VarId str) - -> DocIdentifier [ UnQual (HsVarName (HsIdent str)) ] - Ok _ (QVarId (mod,str)) - -> DocIdentifier [ Qual (Module mod) (HsVarName (HsIdent str)) ] - Ok _ (ConId str) - -> DocIdentifier [ UnQual (HsTyClsName (HsIdent str)), - UnQual (HsVarName (HsIdent str)) ] - Ok _ (QConId (mod,str)) - -> DocIdentifier [ Qual (Module mod) (HsTyClsName (HsIdent str)), - Qual (Module mod) (HsVarName (HsIdent str)) ] - Ok _ (VarSym str) - -> DocIdentifier [ UnQual (HsVarName (HsSymbol str)) ] - Ok _ (ConSym str) - -> DocIdentifier [ UnQual (HsTyClsName (HsSymbol str)), - UnQual (HsVarName (HsSymbol str)) ] - Ok _ (QVarSym (mod,str)) - -> DocIdentifier [ Qual (Module mod) (HsVarName (HsSymbol str)) ] - Ok _ (QConSym (mod,str)) - -> DocIdentifier [ Qual (Module mod) (HsTyClsName (HsSymbol str)), - Qual (Module mod) (HsVarName (HsSymbol str)) ] - other - -> DocString str } |