BDN参考的写法:http://bdn.borland.com/article/26380
procedure TForm1.Button6Click(Sender: TObject);
var
theParser: TParser;
oString: TStringStream;
str:AnsiString;
Pos,Line:integer;
begin
oString := TStringStream.Create(Memo1.Lines.text);
oString.Position := 0;
theParser:= TParser.Create(oString);
while (theParser.Token <> toEOF) do //while we're in the file
begin
//Get Token
str:=theParser.TokenString();
//Get the position in the stream
Pos:=theParser.SourcePos();
//Get the line number
Line:=theParser.SourceLine;
//Get token type
case (theParser.Token) of
toSymbol:
Memo2.Lines.Add(
procedure TForm1.Button6Click(Sender: TObject);
var
theParser: TParser;
oString: TStringStream;
str:AnsiString;
Pos,Line:integer;
begin
oString := TStringStream.Create(Memo1.Lines.text);
oString.Position := 0;
theParser:= TParser.Create(oString);
while (theParser.Token <> toEOF) do //while we're in the file
begin
//Get Token
str:=theParser.TokenString();
//Get the position in the stream
Pos:=theParser.SourcePos();
//Get the line number
Line:=theParser.SourceLine;
//Get token type
case (theParser.Token) of
toSymbol:
Memo2.Lines.Add(