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

View File

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