summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/core/slang-token-reader.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/source/core/slang-token-reader.h b/source/core/slang-token-reader.h
index f08c1674c..18b56f31f 100644
--- a/source/core/slang-token-reader.h
+++ b/source/core/slang-token-reader.h
@@ -175,6 +175,15 @@ namespace Slang
}
throw TextFormatException("Text parsing error: \'" + expectedStr + "\' expected.");
}
+ bool Read(TokenType tokenType)
+ {
+ if( NextToken().Type == tokenType )
+ {
+ ReadToken();
+ return true;
+ }
+ throw TextFormatException("Text parsing error: unexpected '" + NextToken().Content + "'.");
+ }
String ReadStringLiteral()
{
@@ -231,6 +240,18 @@ namespace Slang
return false;
}
}
+ bool LookAhead(TokenType tokenType)
+ {
+ if (tokenPtr < (int)tokens.getCount())
+ {
+ auto next = NextToken();
+ return next.Type == tokenType;
+ }
+ else
+ {
+ return false;
+ }
+ }
bool AdvanceIf(String token)
{
if( LookAhead(token) )