Changeset 7317

Show
Ignore:
Timestamp:
10/05/05 20:17:28 (3 years ago)
Author:
autrijus
Message:

* gaal reported the block parsing fix is still buggy, so now

I made sure that adverbial blocks parse differently from
nonadverbial ones:

pugs> :d f{x}.z
App &f (: App &z (Syn "sub" {sub {...}}: ))

pugs> :d f:{x}.z
App &z (App &f (: Syn "sub" {sub {...}}): )

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Parser.hs

    r7311 r7317  
    17231723parseNoParenParamList :: RuleParser (Maybe Exp, [Exp]) 
    17241724parseNoParenParamList = do 
    1725     formal <- formalSegment argBlockish `sepEndBy` sep 
     1725    formal <- (<|> return []) $ do 
     1726        x <- formalSegment dotForbidden 
     1727        (<|> return [x]) $ do 
     1728            sep 
     1729            xs <- formalSegment dotAllowed `sepEndBy` sep 
     1730            return (x:xs) 
    17261731    processFormals formal 
    17271732    where 
    17281733    sep = symbol ":" 
    1729     formalSegment args = do 
    1730         rv <- option Nothing (fmap Just $ tryChoice args) 
     1734    formalSegment dot = do 
     1735        rv <- option Nothing (fmap Just $ tryChoice (argBlockish dot)) 
    17311736        case rv of 
    17321737            Nothing           -> return [] 
    17331738            Just (exp, trail) -> do 
    1734                 rest <- option [] $ do { trail; formalSegment args } 
     1739                rest <- option [] $ do { trail; formalSegment dot } 
    17351740                return (exp ++ rest) 
    1736     argBlockish = 
    1737         [ argBlockWith ruleBlockLiteral 
    1738         , argBlockWith pairOrBlockAdverb 
     1741    argBlockish dot = 
     1742        [ argBlockWith ruleBlockLiteral dot 
     1743        , argBlockWith pairOrBlockAdverb dot 
    17391744        , argVanilla 
    17401745        ] 
    1741     argBlockWith p = do 
    1742         x <- p 
    1743         lookAhead (satisfy (not . (`elem` ".,"))) 
     1746    argBlockWith rule pred = do 
     1747        x <- rule 
     1748        lookAhead $ satisfy pred 
    17441749        return ([x], return "") 
     1750    dotAllowed = (/= '.') 
     1751    dotForbidden = (not . (`elem` ".,")) 
    17451752    argVanilla = do 
    17461753        x <- parseTightOp