- Help parser more
authorunc0rr
Sun, 27 Nov 2011 00:25:28 +0300
changeset 6444 eddc1e9bcd81
parent 6443 23364a5fcc86
child 6445 fd151457fae6
- Help parser more
hedgewars/uConsole.pas
hedgewars/uKeys.pas
hedgewars/uUtils.pas
tools/PascalParser.hs
--- a/hedgewars/uConsole.pas	Sat Nov 26 21:12:23 2011 +0300
+++ b/hedgewars/uConsole.pas	Sun Nov 27 00:25:28 2011 +0300
@@ -91,7 +91,7 @@
 {$ENDIF}
 end;
 
-function ShortStringAsPChar(s: ShortString) : PChar;
+function ShortStringAsPChar(s: shortstring) : PChar;
 begin
     if Length(s) = High(s) then Dec(s[0]);
     s[Ord(Length(s))+1] := #0;
--- a/hedgewars/uKeys.pas	Sat Nov 26 21:12:23 2011 +0300
+++ b/hedgewars/uKeys.pas	Sun Nov 27 00:25:28 2011 +0300
@@ -147,7 +147,7 @@
     if (tkbd[i] = 0) and (tkbdn[i] <> 0) then
          begin
          ParseCommand(CurrentBinds[i], Trusted);
-         if (CurrentTeam <> nil) and not CurrentTeam^.ExtDriven and (ReadyTimeLeft > 1) then ParseCommand('gencmd R', true)
+         if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then ParseCommand('gencmd R', true)
          end
     else if (CurrentBinds[i][1] = '+')
             and (tkbdn[i] = 0)
@@ -156,7 +156,7 @@
             s:= CurrentBinds[i];
             s[1]:= '-';
             ParseCommand(s, Trusted);
-            if (CurrentTeam <> nil) and not CurrentTeam^.ExtDriven and (ReadyTimeLeft > 1) then ParseCommand('gencmd R', true)
+            if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then ParseCommand('gencmd R', true)
             end;
     tkbd[i]:= tkbdn[i]
     end
--- a/hedgewars/uUtils.pas	Sat Nov 26 21:12:23 2011 +0300
+++ b/hedgewars/uUtils.pas	Sun Nov 27 00:25:28 2011 +0300
@@ -262,7 +262,7 @@
 begin
 s:= s;
 {$IFDEF DEBUGFILE}
-writeln(f, GameTicks: 6, ': ', s);
+writeln(f, GameTicks, ': ', s);
 flush(f)
 {$ENDIF}
 end;
--- a/tools/PascalParser.hs	Sat Nov 26 21:12:23 2011 +0300
+++ b/tools/PascalParser.hs	Sun Nov 27 00:25:28 2011 +0300
@@ -67,6 +67,7 @@
     | BinOp String Expression Expression
     | StringLiteral String
     | CharCode String
+    | HexCharCode String
     | NumberLiteral String
     | FloatLiteral String
     | HexNumber String
@@ -175,17 +176,17 @@
     aConstDecl = do
         comments
         i <- iD
-        optional $ do
+        t <- optionMaybe $ do
             char ':'
             comments
             t <- typeDecl
             comments
-            return ()
+            return t
         char '='
         comments
         e <- initExpression
         comments
-        return $ VarDeclaration False ([i], UnknownType) (Just e)
+        return $ VarDeclaration False ([i], fromMaybe UnknownType t) (Just e)
         
 typeDecl = choice [
     char '^' >> typeDecl >>= return . PointerTo
@@ -373,6 +374,7 @@
     functionDecorator = choice [
         try $ string "inline;"
         , try $ string "cdecl;"
+        , try $ string "overload;"
         , try (string "external") >> comments >> iD >> optional (string "name" >> comments >> stringLiteral pas)>> string ";"
         ] >> comments
         
@@ -422,6 +424,7 @@
         , try $ float pas >>= return . FloatLiteral . show
         , try $ natural pas >>= return . NumberLiteral . show
         , stringLiteral pas >>= return . StringLiteral
+        , try (string "#$") >> many hexDigit >>= \c -> comments >> return (HexCharCode c)
         , char '#' >> many digit >>= \c -> comments >> return (CharCode c)
         , char '$' >> many hexDigit >>=  \h -> comments >> return (HexNumber h)
         , char '-' >> expression >>= return . PrefixOp "-"
@@ -458,7 +461,7 @@
 phrasesBlock = do
     try $ string "begin"
     comments
-    p <- manyTill phrase (try $ string "end")
+    p <- manyTill phrase (try $ string "end" >> notFollowedBy alphaNum)
     comments
     return $ Phrases p
     
@@ -607,8 +610,8 @@
         , try $ float pas >>= return . InitFloat . show
         , try $ integer pas >>= return . InitNumber . show
         , stringLiteral pas >>= return . InitString
-        , char '#' >> many digit >>= return . InitChar
-        , char '$' >> many hexDigit >>= return . InitHexNumber
+        , char '#' >> many digit >>= \c -> comments >> return (InitChar c)
+        , char '$' >> many hexDigit >>= \h -> comments >> return (InitHexNumber h)
         , try $ string "nil" >> return InitNull
         , iD >>= return . InitReference
         ]