diff -r ac23ba018ed2 -r 83b93a2d2741 tools/PascalParser.hs --- a/tools/PascalParser.hs Wed Nov 09 21:36:20 2011 +0300 +++ b/tools/PascalParser.hs Thu Nov 10 23:14:40 2011 +0300 @@ -65,7 +65,7 @@ | Reference Reference | Null deriving Show -data Reference = ArrayElement Identifier Expression +data Reference = ArrayElement [Expression] Reference | FunCall [Expression] Reference | SimpleReference Identifier | Dereference Reference @@ -147,7 +147,6 @@ where term = comments >> choice [ parens pas reference - , try $ iD >>= \i -> (brackets pas) expression >>= return . ArrayElement i , char '@' >> reference >>= return . Address , iD >>= return . SimpleReference ] "simple reference" @@ -155,6 +154,7 @@ 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] ] @@ -190,7 +190,7 @@ constsDecl = do - vs <- many (try (aConstDecl >>= \i -> semi pas >> return i) >>= \i -> comments >> return i) + vs <- many1 (try (aConstDecl >>= \i -> semi pas >> return i) >>= \i -> comments >> return i) comments return vs where @@ -294,7 +294,7 @@ return t procDecl = do - string "procedure" + try $ string "procedure" comments i <- iD optional $ do @@ -315,7 +315,7 @@ return $ [FunctionDeclaration i UnknownType b] funcDecl = do - string "function" + try $ string "function" comments i <- iD optional $ do