X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fshared%2Fxparser.pas;h=f539536ce0ffe98da543820f560365b6de8a8279;hb=48fa53d341e432475432901a339f1ae81fda7809;hp=76ac3c0165483ef90d4066904540d1eef5b7a2dd;hpb=2b647061c5ce08e02c046c3ef8e0a31917cc28f3;p=d2df-sdl.git diff --git a/src/shared/xparser.pas b/src/shared/xparser.pas index 76ac3c0..f539536 100644 --- a/src/shared/xparser.pas +++ b/src/shared/xparser.pas @@ -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');