# HG changeset patch # User unc0rr # Date 1321460725 -10800 # Node ID 7d7703b26bda0644bb8ce9f5029dd1997483221f # Parent e6d30db1e3b08a19b853b969a354d4ec07c4e6c5 Prefix followed by prefix issue solved. Also some slight improvements. diff -r e6d30db1e3b0 -r 7d7703b26bda tools/PascalParser.hs --- a/tools/PascalParser.hs Tue Nov 15 00:43:19 2011 -0500 +++ b/tools/PascalParser.hs Wed Nov 16 19:25:25 2011 +0300 @@ -103,8 +103,8 @@ , "type", "var", "const", "out", "array", "packed" , "procedure", "function", "with", "for", "to" , "downto", "div", "mod", "record", "set", "nil" - , "string", "shortstring", "succ", "pred", "low" - , "high" + , "string", "shortstring"--, "succ", "pred", "low" + --, "high" ] , reservedOpNames= [] , caseSensitive = False @@ -162,17 +162,22 @@ reference = buildExpressionParser table term "reference" where term = comments >> choice [ - parens pas reference - , char '@' >> reference >>= return . Address - , iD >>= return . SimpleReference + parens pas (reference >>= postfixes) >>= postfixes + , char '@' >> reference >>= postfixes >>= return . Address + , liftM SimpleReference iD >>= postfixes ] "simple reference" table = [ - [Postfix $ (parens pas) (option [] parameters) >>= return . FunCall] - , [Postfix (char '^' >> return Dereference)] - , [Postfix $ (brackets pas) (commaSep1 pas $ expression) >>= return . ArrayElement] - , [Infix (try (char '.' >> notFollowedBy (char '.')) >> return RecordField) AssocLeft] + [Infix (try (char '.' >> notFollowedBy (char '.')) >> return RecordField) AssocLeft] ] + + postfixes r = many postfix >>= return . foldl fp r + postfix = choice [ + parens pas (option [] parameters) >>= return . FunCall + , char '^' >> return Dereference + , (brackets pas) (commaSep1 pas $ expression) >>= return . ArrayElement + ] + fp r f = f r varsDecl1 = varsParser sepEndBy1 @@ -477,12 +482,12 @@ withBlock = do try $ string "with" comments - r <- reference + (r:rs) <- (commaSep1 pas) reference comments string "do" comments o <- phrase - return $ WithBlock r o + return $ WithBlock r (foldl (\ph r -> WithBlock r ph) o rs) repeatCycle = do try $ string "repeat"