bit less tolerant HL lexer

This commit is contained in:
Basile Burg 2016-03-19 02:52:28 +01:00
parent a9b8f0554d
commit 930d3577e5
3 changed files with 23 additions and 8 deletions

View File

@ -815,11 +815,15 @@ begin
exit;
end else readerReset;
// numbers 1
// numbers
if (isNumber(reader^)) then
begin
while isAlNum(readerNext^) or (reader^ = '_') or (reader^ = '.') do (*!*);
fTokKind := tkNumbr;
while isHex(readerNext^) or (reader^ = '_') or (reader^ = '.')
or (reader^ in ['x', 'X', 'u', 'U', 'L', 'i']) do (*!*);
if isWhite(reader^) or isSymbol(reader^) or isOperator1(reader^) then
fTokKind := tkNumbr
else
fTokKind := tkError;
exit;
end;
@ -828,6 +832,8 @@ begin
begin
fTokKind := tkSymbl;
case reader^ of
';': if (fTokStop>1) and ((reader-1)^ = '}') then
fTokKind := tkError;
'{': StartCodeFoldBlock(nil, fkBrackets in fFoldKinds);
'}':
begin
@ -846,7 +852,7 @@ begin
exit;
end;
// symbChars 2: operators
// operators
if isOperator1(reader^) then
begin
fTokKind := tkSymbl;
@ -859,7 +865,9 @@ begin
end;
3:begin
if (not isOperator1(reader^)) and
isOperator3(fLineBuf[fTokStart..fTokStop-1])
(isOperator3(fLineBuf[fTokStart..fTokStop-1]) or
(isOperator2(fLineBuf[fTokStart..fTokStop-2]) and
isPostOpSymbol(fLineBuf[fTokStop-1])))
then exit;
end;
2:begin
@ -871,9 +879,9 @@ begin
if not isOperator1(reader^) then exit;
end;
end;
if isWhite(reader^) then
exit;
fTokKind := tkIdent; // invalid op not colorized.
fTokKind := tkError;
//if isWhite(reader^) then
exit;
end;
//Keyword - identifiers

View File

@ -27,6 +27,7 @@ function isAlNum(const c: Char): boolean; {$IFNDEF DEBUG}inline;{$ENDIF}
function isHex(const c: Char): boolean; {$IFNDEF DEBUG}inline;{$ENDIF}
function isSymbol(const c: char): boolean; {$IFNDEF DEBUG}inline;{$ENDIF}
function isPtrOperator(const c: char): boolean; {$IFNDEF DEBUG}inline;{$ENDIF}
function isPostOpSymbol(const c: char): boolean; {$IFNDEF DEBUG} inline; {$ENDIF}
function isOperator1(const c: char): boolean; {$IFNDEF DEBUG}inline;{$ENDIF}
function isOperator2(const s: string): boolean; {$IFNDEF DEBUG}inline;{$ENDIF}
function isOperator3(const s: string): boolean; {$IFNDEF DEBUG} inline; {$ENDIF}
@ -101,6 +102,11 @@ begin
exit(c in ['&', '*']);
end;
function isPostOpSymbol (const c: char): boolean; {$IFNDEF DEBUG}inline;{$ENDIF}
begin
exit(c in ['+', '-', '*', '&']);
end;
function isOperator1(const c: char): boolean; {$IFNDEF DEBUG}inline;{$ENDIF}
begin
exit(c in ['/', '*', '-', '+', '%', '>', '<', '=', '!', '&', '|', '^', '~']);

View File

@ -0,0 +1 @@
- new symbolic strings, ENV_XXX, see issue #27