DEADSOFTWARE

mapdef cleanup; renamed some fields; mapdef.txt is RC0 now
[d2df-sdl.git] / src / shared / xparser.pas
index 76ac3c0165483ef90d4066904540d1eef5b7a2dd..01c49b4bb1bb4e4360dd8e4c1057686e15b7c5ff 100644 (file)
@@ -75,6 +75,8 @@ type
     function expectStr (allowEmpty: Boolean=false): AnsiString;
     function expectInt (): Integer;
 
+    function expectStrOrId (allowEmpty: Boolean=false): AnsiString;
+
     procedure expectTT (ttype: Integer);
     function eatTT (ttype: Integer): Boolean;
 
@@ -544,6 +546,21 @@ begin
 end;
 
 
+function TTextParser.expectStrOrId (allowEmpty: Boolean=false): AnsiString;
+begin
+  case mTokType of
+    TTStr:
+      if (not allowEmpty) and (Length(mTokStr) = 0) then raise Exception.Create('non-empty string expected');
+    TTId:
+      begin end;
+    else
+      raise Exception.Create('string or identifier expected');
+  end;
+  result := mTokStr;
+  skipToken();
+end;
+
+
 function TTextParser.expectInt (): Integer;
 begin
   if (mTokType <> TTInt) then raise Exception.Create('string expected');