diff --git a/src/shared/xparser.pas b/src/shared/xparser.pas
index b704c4b7016a65f119192cc325e07fe49e51bf85..7d7a9ed5d3bbdeb237376833203c68374a90986c 100644 (file)
--- a/src/shared/xparser.pas
+++ b/src/shared/xparser.pas
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*)
{$INCLUDE a_modes.inc}
+{.$DEFINE XPARSER_DEBUG}
unit xparser;
interface
uses
- Classes, mempool;
+ Classes{$IFDEF USE_MEMPOOL}, mempool{$ENDIF};
// ////////////////////////////////////////////////////////////////////////// //
type
- TTextParser = class(TPoolObject)
+ TTextParser = class{$IFDEF USE_MEMPOOL}(TPoolObject){$ENDIF}
public
const
TTNone = -1;
TOption = (
SignedNumbers, // allow signed numbers; otherwise sign will be TTDelim
DollarIsId, // allow dollar in identifiers; otherwise dollar will be TTDelim
- DotIsId // allow dot in identifiers; otherwise dot will be TTDelim
+ DotIsId, // allow dot in identifiers; otherwise dot will be TTDelim
+ PascalComments // allow `{}` pascal comments
);
TOptions = set of TOption;
function skipBlanks (): Boolean; // ...and comments; returns `false` on eof
function skipToken (): Boolean; // returns `false` on eof
- //function skipToken1 (): Boolean;
+ {$IFDEF XPARSER_DEBUG}
+ function skipToken1 (): Boolean;
+ {$ENDIF}
function expectId (): AnsiString;
procedure expectId (const aid: AnsiString);
skipChar();
end;
continue;
+ end
+ else if (curChar = '{') and (TOption.PascalComments in mOptions) then
+ begin
+ // pascal comment; skip comment start
+ skipChar();
+ while not isEOF do
+ begin
+ if (curChar = '}') then
+ begin
+ // skip comment end
+ skipChar();
+ break;
+ end;
+ skipChar();
+ end;
+ continue;
end;
if (curChar > ' ') then break;
skipChar(); // skip blank
end;
-{
+{$IFDEF XPARSER_DEBUG}
function TTextParser.skipToken (): Boolean;
begin
writeln('getting token...');
result := skipToken1();
writeln(' got token: ', mTokType, ' <', mTokStr, '> : <', mTokChar, '>');
end;
-}
-
+function TTextParser.skipToken1 (): Boolean;
+{$ELSE}
function TTextParser.skipToken (): Boolean;
-
+{$ENDIF}
procedure parseInt ();
var
neg: Boolean = false;