fix, lexer needed full bool eval

This commit is contained in:
Basile Burg 2016-04-03 06:12:14 +02:00
parent 10796ab262
commit 1655300dfe
2 changed files with 28 additions and 22 deletions

View File

@ -385,7 +385,7 @@ begin
Result.fIndex := -1;
end;
{$BOOLEVAL ON}
procedure lex(const aText: string; aList: TLexTokenList; aCallBack: TLexFoundEvent = nil);
var
reader: TReaderHead;
@ -473,9 +473,11 @@ begin
reader.saveBeginning;
if isOutOfBound then
exit;
while (reader.head^ <> '*') or (reader.Next^ <> '/') do
reader.Next;
while (reader.head^ <> '/') or ((reader.head - 1)^ <> '*') do
begin
identifier += reader.head^;
reader.Next;
if isOutOfBound then
exit;
end;
@ -499,7 +501,7 @@ begin
if isOutOfBound then
exit;
repeat
while ((reader.head^ <> '+') or (reader.head^ <> '/')) or
while ((reader.head^ <> '+') or (reader.head^ <> '/')) and
((reader.next^ <> '/') or (reader.head^ <> '+')) do
begin
if isOutOfBound then
@ -620,22 +622,24 @@ begin
end;
// token string
if (reader.head^ = 'q') and (reader.Next^ = '{') then
if (reader.head^ = 'q') then
begin
reader.saveBeginning;
reader.Next;
if isOutOfBound then
exit;
identifier := 'q{';
addToken(ltkSymbol);
if callBackDoStop then
exit;
continue;
end
else
reader.previous;
if (reader.Next^ = '{') then
begin
reader.saveBeginning;
reader.Next;
if isOutOfBound then
exit;
identifier := 'q{';
addToken(ltkSymbol);
if callBackDoStop then
exit;
continue;
end else
reader.previous;
end;
//chars, note: same escape error as in SynD2Syn
//chars
if (reader.head^ = #39) then
begin
reader.Next;
@ -783,7 +787,7 @@ begin
continue;
end;
// symbChars
// symbols
if isSymbol(reader.head^) then
begin
reader.saveBeginning;
@ -922,6 +926,12 @@ begin
end;
// error
while not isWhite(reader.head^) do
begin
if isOutOfBound then
break;
reader.Next;
end;
{$IFDEF DEBUG}
identifier += ' (unrecognized lexer input)';
{$ENDIF}
@ -929,8 +939,6 @@ begin
end;
end;
{$BOOLEVAL OFF}
{$ENDREGION}
{$REGION Syntactic errors}

View File

@ -54,7 +54,6 @@ function tryReadDelim(var aReader: PChar; var aPosition: Integer; const aDelim:
implementation
{$BOOLEVAL ON}
function isWhite(const c: Char): boolean; {$IFNDEF DEBUG}inline;{$ENDIF}
begin
exit(c in [#0..#32]);
@ -158,7 +157,6 @@ function isFirstIdentifier(const c: char): boolean; {$IFNDEF DEBUG}inline;{$ENDI
begin
exit(isIdentifier(c) and (not isNumber(c)));
end;
{$BOOLEVAL OFF}
function readLine(var aReader: PChar; var aPosition: Integer): boolean;
begin