Skip to content

Commit fa25626

Browse files
committed
Minor cleanup of parser code.
1 parent ac88d0e commit fa25626

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

source/parser/parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class Parser : public SceneTask
241241
TokenId Function_Id; ///< token type ID, in case Token_Id is an identifier ID
242242
int context; ///< context the token is local to (i.e., table index)
243243
DBL Token_Float; ///< token value (if it is a float literal)
244-
int Unget_Token, End_Of_File;
244+
bool Unget_Token, End_Of_File;
245245
void *Data; ///< reference to token value (if it is a non-float identifier)
246246
TokenId *NumberPtr;
247247
void **DataPtr;

source/parser/parser_tokenizer.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ void Parser::Read_Symbol(const RawToken& rawToken)
527527

528528
haveNextRawToken = PeekRawToken(nextRawToken);
529529

530-
if (!haveNextRawToken || (nextRawToken.lexeme.category != Lexeme::Category::kOther) || (nextRawToken.lexeme.text != "["))
530+
if (!haveNextRawToken || (nextRawToken.lexeme.category != Lexeme::kOther) || (nextRawToken.lexeme.text != "["))
531531
{
532532
breakLoop = true;
533533
break;
@@ -592,7 +592,7 @@ void Parser::Read_Symbol(const RawToken& rawToken)
592592
table = Tables [pseudoDictionary];
593593
pseudoDictionary = -1;
594594

595-
if (!haveNextRawToken || (nextRawToken.lexeme.category != Lexeme::Category::kOther) ||
595+
if (!haveNextRawToken || (nextRawToken.lexeme.category != Lexeme::kOther) ||
596596
((nextRawToken.lexeme.text != "[") && (nextRawToken.lexeme.text != ".")))
597597
{
598598
Get_Token(); // ensures the error is reported at the right token
@@ -602,7 +602,7 @@ void Parser::Read_Symbol(const RawToken& rawToken)
602602
else
603603
table = reinterpret_cast<SYM_TABLE *>(*(mToken.DataPtr));
604604

605-
if (haveNextRawToken && (nextRawToken.lexeme.category == Lexeme::Category::kOther) && (nextRawToken.lexeme.text == "."))
605+
if (haveNextRawToken && (nextRawToken.lexeme.category == Lexeme::kOther) && (nextRawToken.lexeme.text == "."))
606606
{
607607
if (table == nullptr)
608608
{
@@ -621,7 +621,7 @@ void Parser::Read_Symbol(const RawToken& rawToken)
621621

622622
Temp_Entry = Find_Symbol (table, mToken.raw.lexeme.text.c_str());
623623
}
624-
else if (haveNextRawToken && (nextRawToken.lexeme.category == Lexeme::Category::kOther) && (nextRawToken.lexeme.text == "["))
624+
else if (haveNextRawToken && (nextRawToken.lexeme.category == Lexeme::kOther) && (nextRawToken.lexeme.text == "["))
625625
{
626626
if (table == nullptr)
627627
{
@@ -837,7 +837,7 @@ bool Parser::GetRawToken(RawToken& rawToken, bool fastForwardToDirective)
837837
{
838838
rawToken = mPendingRawToken;
839839
mHavePendingRawToken = false;
840-
if (!fastForwardToDirective || ((rawToken.lexeme.category == Lexeme::Category::kOther) && (rawToken.lexeme.text == "#")))
840+
if (!fastForwardToDirective || ((rawToken.lexeme.category == Lexeme::kOther) && (rawToken.lexeme.text == "#")))
841841
return true;
842842
}
843843

@@ -847,12 +847,12 @@ bool Parser::GetRawToken(RawToken& rawToken, bool fastForwardToDirective)
847847
return mTokenizer.GetNextToken(rawToken);
848848
}
849849

850-
bool Parser::PeekRawToken(RawToken& lexeme)
850+
bool Parser::PeekRawToken(RawToken& rawToken)
851851
{
852-
if (!GetRawToken(lexeme, false))
852+
if (!GetRawToken(rawToken, false))
853853
return false;
854854

855-
UngetRawToken(lexeme);
855+
UngetRawToken(rawToken);
856856
return true;
857857
}
858858

source/parser/scanner.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ bool Scanner::GetNextLexeme(Lexeme& lexeme)
423423
else if (*mpNextChar == '/')
424424
{
425425
// Either division operator or start of comment.
426-
lexeme.category = Lexeme::Category::kOther;
426+
lexeme.category = Lexeme::kOther;
427427
if (!CopyAndAdvance(lexeme))
428428
return true;
429429
if (*mpNextChar == '/')
@@ -442,7 +442,7 @@ bool Scanner::GetNextLexeme(Lexeme& lexeme)
442442
else if ((*mpNextChar == '!') || (*mpNextChar == '<') || (*mpNextChar == '>'))
443443
{
444444
// Either single-character operator or comparison.
445-
lexeme.category = Lexeme::Category::kOther;
445+
lexeme.category = Lexeme::kOther;
446446
if (!CopyAndAdvance(lexeme))
447447
return true;
448448
if (*mpNextChar == '=')
@@ -457,7 +457,7 @@ bool Scanner::GetNextLexeme(Lexeme& lexeme)
457457
else
458458
{
459459
// Single-character operator (or not a valid lexeme at all)
460-
lexeme.category = Lexeme::Category::kOther;
460+
lexeme.category = Lexeme::kOther;
461461
(void)CopyAndAdvance(lexeme);
462462
return true;
463463
}
@@ -513,7 +513,7 @@ bool Scanner::GetNextDirective(Lexeme& lexeme)
513513
{
514514
POV_PARSER_ASSERT(*mpNextChar == '#');
515515
// Found what we've been looking for.
516-
lexeme.category = Lexeme::Category::kOther;
516+
lexeme.category = Lexeme::kOther;
517517
(void)CopyAndAdvance(lexeme);
518518
return true;
519519
}
@@ -529,7 +529,7 @@ bool Scanner::GetNextWordLexeme(Lexeme& lexeme)
529529
POV_PARSER_ASSERT(!mEndOfStream);
530530
POV_PARSER_ASSERT(IsIdentifierChar1(*mpNextChar));
531531

532-
lexeme.category = Lexeme::Category::kWord;
532+
lexeme.category = Lexeme::kWord;
533533

534534
// Read identifier name.
535535
while (CopyAndAdvance(lexeme) && IsIdentifierChar2(*mpNextChar))
@@ -544,7 +544,7 @@ bool Scanner::GetNextFloatLiteralLexeme(Lexeme& lexeme)
544544
{
545545
POV_PARSER_ASSERT(!mEndOfStream);
546546

547-
lexeme.category = Lexeme::Category::kFloatLiteral;
547+
lexeme.category = Lexeme::kFloatLiteral;
548548

549549
if (!GetNextFloatLiteralDigits(lexeme))
550550
POV_PARSER_ASSERT(false);
@@ -577,7 +577,7 @@ bool Scanner::GetNextFloatLiteralOrDotLexeme(Lexeme& lexeme)
577577
if (CopyAndAdvance(lexeme) && IsDecimalDigit(*mpNextChar))
578578
{
579579
// Valid start of a numeric literal, starting with the decimal point.
580-
lexeme.category = Lexeme::Category::kFloatLiteral;
580+
lexeme.category = Lexeme::kFloatLiteral;
581581

582582
// Read fractional part.
583583
if (!GetNextFloatLiteralDigits(lexeme))
@@ -593,7 +593,7 @@ bool Scanner::GetNextFloatLiteralOrDotLexeme(Lexeme& lexeme)
593593
else
594594
{
595595
// Dot operator.
596-
lexeme.category = Lexeme::Category::kOther;
596+
lexeme.category = Lexeme::kOther;
597597

598598
// Dot has already been copied to lexeme.
599599

@@ -667,7 +667,7 @@ bool Scanner::GetNextStringLiteralLexeme(Lexeme& lexeme)
667667
POV_PARSER_ASSERT(!mEndOfStream);
668668
POV_PARSER_ASSERT(*mpNextChar == '"');
669669

670-
lexeme.category = Lexeme::Category::kStringLiteral;
670+
lexeme.category = Lexeme::kStringLiteral;
671671

672672
if (!CopyAndAdvance(lexeme))
673673
return false;

0 commit comments

Comments
 (0)