/// <summary> /// Reads the next token from the stream. If it's not a literal, /// throws an exception. /// </summary> private LiteralToken ReadNextAsLiteral() { Token nextToken = ReadNextToken(); bool isNegative = false; if ((nextToken is OperatorToken) && (nextToken.Name == "-")) { isNegative = true; nextToken = ReadNextToken(); } if (!(nextToken is LiteralToken)) { throw new CompilerMessage(ErrorCode.UnexpectedToken, "Literal expected at '" + nextToken.Name + "'"); } Token tokenToReturn = nextToken; if (isNegative) { if (_source == null) { throw new CompilerMessage(ErrorCode.InternalError, "Internal error: attempted to use tokenized script with no source"); } tokenToReturn = _source.FindTokenWithName("-" + nextToken.Name); if (tokenToReturn == null) { tokenToReturn = new LiteralToken("-" + nextToken.Name); _source.AddToken(tokenToReturn); } } return((LiteralToken)tokenToReturn); }
public static Token GetTokenForStructMember(TokenizedScript script, Token structName, Token memberName, out string mangledName) { mangledName = structName.Name + "::" + memberName.Name; return(script.FindTokenWithName(mangledName)); }
public static Token GetTokenForStructMember(TokenizedScript script, Token structName, Token memberName, out string mangledName) { mangledName = structName.Name + "::" + memberName.Name; return script.FindTokenWithName(mangledName); }