private LiteralToken NextOctIntLiteral() { int start = Index; ++Index; string str = GetOctStr(); char c = Code.GetChar(Index); if (CharUtils.IsDecDigit(c) && !CharUtils.IsOctDigit(c)) { throw VBSyntaxError(VBSyntaxErrorCode.SyntaxError); } if (CharUtils.IsIdentifierStart(c)) { throw VBSyntaxError(VBSyntaxErrorCode.ExpectedEndOfStatement); } var result = ParseInteger(str, 8); result.Start = start; return(result); }
private Token NextNumericLiteral() { int start = Index; char c = Code.GetChar(Index); char next = Code.GetChar(Index + 1); string? dec = null; StringBuilder?fstr = null; if (c != '.') { if (c == '&') { if (CharUtils.Equals(next, 'h')) { return(NextHexIntLiteral()); } else if (CharUtils.IsOctDigit(next)) { return(NextOctIntLiteral()); } else { throw VBSyntaxError(VBSyntaxErrorCode.SyntaxError); } } else { dec = GetDecStr(); if (CharUtils.IsIdentifierStart(Code.GetChar(Index))) { throw VBSyntaxError(VBSyntaxErrorCode.ExpectedEndOfStatement); } } } c = Code.GetChar(Index); if (c == '.') { ++Index; fstr ??= GetStringBuilder(); fstr.Append('.').Append(GetDecStr()); c = Code.GetChar(Index); } if (CharUtils.Equals(c, 'e')) { fstr ??= GetStringBuilder(); fstr.Append('e'); c = Code.GetChar(++Index); if (c == '+' || c == '-') { ++Index; fstr.Append(c); } c = Code.GetChar(Index); if (CharUtils.IsDecDigit(c)) { fstr.Append(GetDecStr()); } else { throw VBSyntaxError(VBSyntaxErrorCode.InvalidNumber); } } c = Code.GetChar(Index); if (CharUtils.IsIdentifierStart(c)) { throw VBSyntaxError(VBSyntaxErrorCode.ExpectedEndOfStatement); } if (fstr != null && dec != null) { fstr.Insert(0, dec); } if (fstr != null) { return(new FloatLiteralToken { Start = start, End = Index, LineNumber = CurrentLine, LineStart = CurrentLineStart, Value = ParseDouble(fstr.ToString()), }); } var result = ParseInteger(dec !, 10); result.Start = start; return(result); }