tools/PascalParser.hs
changeset 7006 6af78154dc62
parent 6897 a9126661f613
child 7043 7c080e5ac8d0
--- a/tools/PascalParser.hs	Sun Apr 01 15:23:34 2012 +0200
+++ b/tools/PascalParser.hs	Wed May 02 23:53:45 2012 +0200
@@ -14,7 +14,7 @@
 import PascalBasics
 import PascalUnitSyntaxTree
     
-knownTypes = ["shortstring", "char", "byte"]
+knownTypes = ["shortstring", "ansistring", "char", "byte"]
 
 pascalUnit = do
     comments
@@ -113,12 +113,13 @@
         comments
         e <- initExpression
         comments
-        return $ VarDeclaration False ([i], fromMaybe (DeriveType e) t) (Just e)
+        return $ VarDeclaration (isNothing t) ([i], fromMaybe (DeriveType e) t) (Just e)
         
 typeDecl = choice [
     char '^' >> typeDecl >>= return . PointerTo
     , try (string "shortstring") >> return (String 255)
     , try (string "string") >> optionMaybe (brackets pas $ integer pas) >>= return . String . fromMaybe 255
+    , try (string "ansistring") >> optionMaybe (brackets pas $ integer pas) >>= return . String . fromMaybe 255
     , arrayDecl
     , recordDecl
     , setDecl
@@ -407,6 +408,7 @@
         , withBlock
         , forCycle
         , (try $ reference >>= \r -> string ":=" >> return r) >>= \r -> expression >>= return . Assignment r
+        , builtInFunction expression >>= \(n, e) -> return $ BuiltInFunctionCall e (SimpleReference (Identifier n BTUnknown))
         , procCall
         , char ';' >> comments >> return NOP
         ]
@@ -581,8 +583,8 @@
            , Infix (try $ string "or" >> return (InitBinOp "or")) AssocLeft
            , Infix (try $ string "xor" >> return (InitBinOp "xor")) AssocLeft
           ]
-        , [  Infix (try $ string "shl" >> return (InitBinOp "and")) AssocNone
-           , Infix (try $ string "shr" >> return (InitBinOp "or")) AssocNone
+        , [  Infix (try $ string "shl" >> return (InitBinOp "shl")) AssocNone
+           , Infix (try $ string "shr" >> return (InitBinOp "shr")) AssocNone
           ]
         , [Prefix (try (string "not") >> return (InitPrefixOp "not"))]
         ]
@@ -596,7 +598,7 @@
 builtInFunction e = do
     name <- choice $ map (\s -> try $ caseInsensitiveString s >>= \i -> notFollowedBy alphaNum >> return i) builtin
     spaces
-    exprs <- parens pas $ commaSep1 pas $ e
+    exprs <- option [] $ parens pas $ option [] $ commaSep1 pas $ e
     spaces
     return (name, exprs)