internal static FunctionToken ReadFunction(TokenCollection stream, bool hasBracket) { if (stream.NextIsEndOfStream) { throw new HspLogicalLineException("関数:読み込み中にスタックが空になった"); } FunctionPrimitive token = stream.GetNextToken() as FunctionPrimitive; if (token == null) { throw new HspLogicalLineException("関数:関数プリミティブ以外からスタート"); } //行末なら強制的に終了 if (stream.NextIsEndOfLine) { return(new FunctionToken(token)); } //ゴーストラベル処理 if (token.HasGhostLabel && (stream.NextToken.CodeType == HspCodeType.Label)) { stream.GetNextToken(); if (stream.NextIsEndOfLine) { return(new FunctionToken(token)); } } //次が'('なら引数読み込み if (stream.NextIsBracketStart) { return(new FunctionToken(token, ReadArgument(stream))); } //どちらでもないなら、hasBracketで分岐 //hasBracket =falseなら強制的に引数ありに。 if (hasBracket) { return(new FunctionToken(token)); } else { return(new FunctionToken(token, ReadArgument(stream))); } }
internal FunctionToken(FunctionPrimitive token, ArgumentToken theArg) { primitive = token; arg = theArg; }
internal FunctionToken(FunctionPrimitive token) { primitive = token; }