* Patch from Graeme Geldenhuys (bug 17237) extending scanner to report EOL and TAB

git-svn-id: trunk@15877 -
This commit is contained in:
michael 2010-08-23 07:42:42 +00:00
parent 700f687692
commit a848b6fde2
2 changed files with 29 additions and 9 deletions

View File

@ -92,16 +92,18 @@ uses Classes;
var
IsIdentStart: array[char] of boolean;
type
const
WhitespaceTokensToIgnore = [tkWhitespace, tkComment, tkLineEnding, tkTab];
type
TDeclType = (declNone, declConst, declResourcestring, declType, declVar, declThreadvar, declProperty);
TProcType = (ptProcedure, ptFunction, ptOperator, ptConstructor, ptDestructor,
ptClassProcedure, ptClassFunction);
TExprKind = (ek_Normal, ek_PropertyIndex);
TExprKind = (ek_Normal, ek_PropertyIndex);
{ TPasParser }
TPasParser = class
@ -291,7 +293,7 @@ begin
try
repeat
FCurToken := Scanner.FetchToken;
until not (FCurToken in [tkWhitespace, tkComment]);
until not (FCurToken in WhitespaceTokensToIgnore);
except
on e: EScannerError do
raise EParserError.Create(e.Message,

View File

@ -138,7 +138,10 @@ type
tkvar,
tkwhile,
tkwith,
tkxor);
tkxor,
tkLineEnding,
tkTab
);
TLineReader = class
public
@ -339,7 +342,9 @@ const
'var',
'while',
'with',
'xor'
'xor',
'LineEnding',
'Tab'
);
function FilenameIsAbsolute(const TheFilename: string):boolean;
@ -675,9 +680,9 @@ begin
#0: // Empty line
begin
FetchLine;
Result := tkWhitespace;
Result := tkLineEnding;
end;
#9, ' ':
' ':
begin
Result := tkWhitespace;
repeat
@ -688,7 +693,20 @@ begin
FCurToken := Result;
exit;
end;
until not (TokenStr[0] in [#9, ' ']);
until not (TokenStr[0] in [' ']);
end;
#9:
begin
Result := tkTab;
repeat
Inc(TokenStr);
if TokenStr[0] = #0 then
if not FetchLine then
begin
FCurToken := Result;
exit;
end;
until not (TokenStr[0] in [#9]);
end;
'#', '''':
Result:=DoFetchTextToken;