DEADSOFTWARE

map records and fields can have optional tooltips ("tip") and help ("help") in mapdef...
[d2df-sdl.git] / src / shared / xparser.pas
index 76ac3c0165483ef90d4066904540d1eef5b7a2dd..f539536ce0ffe98da543820f560365b6de8a8279 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;
 
@@ -156,6 +158,9 @@ type
     procedure putIndent ();
     procedure indent ();
     procedure unindent ();
+
+  public
+    property curIndent: Integer read mIndent;
   end;
 
 
@@ -544,6 +549,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');