// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - static FunctionParser() { FirstFunction = new TokenSet(TokenType.Sine | TokenType.Cosine | TokenType.Tangent); FirstFactor = FirstFunction + new TokenSet(TokenType.Variable | TokenType.OpenParen); FirstFactorPrefix = FirstFactor + TokenType.Constant; FirstUnaryExp = FirstFactorPrefix + TokenType.Minus; FirstExpExp = new TokenSet(FirstUnaryExp); FirstMultExp = new TokenSet(FirstUnaryExp); FirstAddExp = new TokenSet(FirstUnaryExp); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - static FunctionParser() { FirstFunction = new TokenSet( TokenType.Sine | TokenType.Cosine | TokenType.Tangent ); FirstFactor = FirstFunction + new TokenSet( TokenType.Variable | TokenType.OpenParen ); FirstFactorPrefix = FirstFactor + TokenType.Constant; FirstUnaryExp = FirstFactorPrefix + TokenType.Minus; FirstExpExp = new TokenSet( FirstUnaryExp ); FirstMultExp = new TokenSet( FirstUnaryExp ); FirstAddExp = new TokenSet( FirstUnaryExp ); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /// <summary> /// Check if the CurrentToken is a member of a set Token types /// </summary> /// <param name="tokens">The set of Token types to check against</param> /// <returns> /// true if the CurrentToken's type is in the set /// false if it is not /// </returns> private static bool Check( TokenSet tokens ) { return tokens.Contains( CurrentToken.type ); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /// <summary> /// Check if the CurrentToken is a member of a set Token types /// </summary> /// <param name="tokens">The set of Token types to check against</param> /// <returns> /// true if the CurrentToken's type is in the set /// false if it is not /// </returns> private static bool Check(TokenSet tokens) { return(tokens.Contains(CurrentToken.type)); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public TokenSet( TokenSet t ) { this.tokens = t.tokens; }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public TokenSet(TokenSet t) { this.tokens = t.tokens; }