private static OnStatement readOn(TokenCollection stream) { OnFunctionPrimitive token = stream.GetNextToken() as OnFunctionPrimitive; if (token == null) { throw new HspLogicalLineException("on条件分岐行:条件分岐プリミティブ以外からスタート"); } //式がないこともあるかもしれない(実行時エラー) if (stream.NextIsEndOfLine) { return(new OnStatement(token, null, null)); } //式を読む。goto/gosubがないこともあるかもしれない(実行時エラー) ExpressionToken exp = CodeTokenFactory.ReadExpression(stream); if (stream.NextIsEndOfLine) { return(new OnStatement(token, exp, null)); } //goto/gosub関数を読む。goto/gosub以外でもコンパイルは通る(実行時エラー) //この関数には()がつかない。 FunctionToken func = CodeTokenFactory.ReadFunction(stream, false); if (stream.NextIsEndOfLine) { return(new OnStatement(token, exp, func)); } //まだあまってたらエラーね。 throw new HspLogicalLineException("on条件分岐行:余分なトークンがある"); }
internal OnStatement(OnFunctionPrimitive theToken, ExpressionToken exp, FunctionToken func) { this.token = theToken; this.exp = exp; this.func = func; }