Fix inifinite loops
authorunc0rr
Wed, 09 Nov 2011 21:36:20 +0300
changeset 6316 ac23ba018ed2
parent 6315 1f7a7a330c59
child 6317 83b93a2d2741
Fix inifinite loops
tools/PascalParser.hs
--- a/tools/PascalParser.hs	Wed Nov 09 21:28:52 2011 +0300
+++ b/tools/PascalParser.hs	Wed Nov 09 21:36:20 2011 +0300
@@ -66,7 +66,7 @@
     | Null
     deriving Show
 data Reference = ArrayElement Identifier Expression
-    | FunCall Reference [Expression]
+    | FunCall [Expression] Reference
     | SimpleReference Identifier
     | Dereference Reference
     | RecordField Reference Reference
@@ -148,15 +148,16 @@
     term = comments >> choice [
         parens pas reference 
         , try $ iD >>= \i -> (brackets pas) expression >>= return . ArrayElement i
-        , try $ funCall
-        , try $ reference >>= \r -> char '^' >> return (Dereference r)
         , char '@' >> reference >>= return . Address
         , iD >>= return . SimpleReference
         ] <?> "simple reference"
 
     table = [ 
-          [Infix (try (char '.' >> notFollowedBy (char '.')) >> return RecordField) AssocLeft]
+            [Postfix $ (parens pas) (option [] parameters) >>= return . FunCall]
+          , [Postfix (char '^' >> return Dereference)]
+          , [Infix (try (char '.' >> notFollowedBy (char '.')) >> return RecordField) AssocLeft]
         ]
+
     
 varsDecl1 = varsParser sepEndBy1    
 varsDecl = varsParser sepEndBy
@@ -525,11 +526,6 @@
     p <- option [] $ (parens pas) parameters
     return $ ProcCall i p
 
-funCall = do
-    r <- reference
-    p <- (parens pas) $ option [] parameters
-    return $ FunCall r p
-
 parameters = (commaSep pas) expression <?> "parameters"
         
 functionBody = do