mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-03 20:06:22 +02:00
* Patch from Graeme Geldenhuys (bug 17237) extending scanner to report EOL and TAB
git-svn-id: trunk@15877 -
This commit is contained in:
parent
700f687692
commit
a848b6fde2
@ -92,16 +92,18 @@ uses Classes;
|
|||||||
var
|
var
|
||||||
IsIdentStart: array[char] of boolean;
|
IsIdentStart: array[char] of boolean;
|
||||||
|
|
||||||
type
|
const
|
||||||
|
WhitespaceTokensToIgnore = [tkWhitespace, tkComment, tkLineEnding, tkTab];
|
||||||
|
|
||||||
|
type
|
||||||
TDeclType = (declNone, declConst, declResourcestring, declType, declVar, declThreadvar, declProperty);
|
TDeclType = (declNone, declConst, declResourcestring, declType, declVar, declThreadvar, declProperty);
|
||||||
|
|
||||||
TProcType = (ptProcedure, ptFunction, ptOperator, ptConstructor, ptDestructor,
|
TProcType = (ptProcedure, ptFunction, ptOperator, ptConstructor, ptDestructor,
|
||||||
ptClassProcedure, ptClassFunction);
|
ptClassProcedure, ptClassFunction);
|
||||||
|
|
||||||
|
|
||||||
TExprKind = (ek_Normal, ek_PropertyIndex);
|
TExprKind = (ek_Normal, ek_PropertyIndex);
|
||||||
|
|
||||||
{ TPasParser }
|
{ TPasParser }
|
||||||
|
|
||||||
TPasParser = class
|
TPasParser = class
|
||||||
@ -291,7 +293,7 @@ begin
|
|||||||
try
|
try
|
||||||
repeat
|
repeat
|
||||||
FCurToken := Scanner.FetchToken;
|
FCurToken := Scanner.FetchToken;
|
||||||
until not (FCurToken in [tkWhitespace, tkComment]);
|
until not (FCurToken in WhitespaceTokensToIgnore);
|
||||||
except
|
except
|
||||||
on e: EScannerError do
|
on e: EScannerError do
|
||||||
raise EParserError.Create(e.Message,
|
raise EParserError.Create(e.Message,
|
||||||
|
@ -138,7 +138,10 @@ type
|
|||||||
tkvar,
|
tkvar,
|
||||||
tkwhile,
|
tkwhile,
|
||||||
tkwith,
|
tkwith,
|
||||||
tkxor);
|
tkxor,
|
||||||
|
tkLineEnding,
|
||||||
|
tkTab
|
||||||
|
);
|
||||||
|
|
||||||
TLineReader = class
|
TLineReader = class
|
||||||
public
|
public
|
||||||
@ -339,7 +342,9 @@ const
|
|||||||
'var',
|
'var',
|
||||||
'while',
|
'while',
|
||||||
'with',
|
'with',
|
||||||
'xor'
|
'xor',
|
||||||
|
'LineEnding',
|
||||||
|
'Tab'
|
||||||
);
|
);
|
||||||
|
|
||||||
function FilenameIsAbsolute(const TheFilename: string):boolean;
|
function FilenameIsAbsolute(const TheFilename: string):boolean;
|
||||||
@ -675,9 +680,9 @@ begin
|
|||||||
#0: // Empty line
|
#0: // Empty line
|
||||||
begin
|
begin
|
||||||
FetchLine;
|
FetchLine;
|
||||||
Result := tkWhitespace;
|
Result := tkLineEnding;
|
||||||
end;
|
end;
|
||||||
#9, ' ':
|
' ':
|
||||||
begin
|
begin
|
||||||
Result := tkWhitespace;
|
Result := tkWhitespace;
|
||||||
repeat
|
repeat
|
||||||
@ -688,7 +693,20 @@ begin
|
|||||||
FCurToken := Result;
|
FCurToken := Result;
|
||||||
exit;
|
exit;
|
||||||
end;
|
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;
|
end;
|
||||||
'#', '''':
|
'#', '''':
|
||||||
Result:=DoFetchTextToken;
|
Result:=DoFetchTextToken;
|
||||||
|
Loading…
Reference in New Issue
Block a user