1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 19:48:20 +02:00

Ranges (ie: for (int a in 0..<count) for (int i in 1…10))

This commit is contained in:
Brian Fiete 2021-07-21 07:48:37 -07:00
parent e561a26695
commit 465050b81d
11 changed files with 418 additions and 18 deletions

View file

@ -2316,6 +2316,13 @@ void BfParser::NextToken(int endIdx, bool outerIsInterpolate)
mToken = BfToken_DotDotDot;
mSyntaxToken = BfSyntaxToken_Token;
}
else if (mSrc[mSrcIdx + 1] == '<')
{
mSrcIdx += 2;
mTokenEnd = mSrcIdx;
mToken = BfToken_DotDotLess;
mSyntaxToken = BfSyntaxToken_Token;
}
else
{
mSrcIdx++;
@ -2526,8 +2533,15 @@ void BfParser::NextToken(int endIdx, bool outerIsInterpolate)
bool endNumber = false;
bool hasDot = c == '.';
if ((hasDot) && (mSrc[mSrcIdx] == '.'))
{
// Skip float parsing if we have a double-dot `1..` case
hasDot = false;
}
// The 'prevIsDot' helps tuple lookups like "tuple.0.0", interpreting those as two integers rather than a float
if (((c == '.') && (!prevIsDot)) || (hasExp))
if (((hasDot) && (!prevIsDot)) || (hasExp))
{
// Switch to floating point mode
//double dVal = val;