private Operator MatchOperator(Operator[] ops, Associativity assoc) { foreach (var op in ops) { if (op.associativity != assoc) { continue; } if (!this.NextNthIs(0, op.token1)) { continue; } if (!op.token2.HasValue) { this.Advance(); return(op); } if (this.NextNthIs(1, op.token2.Value)) { this.Advance(); this.Advance(); return(op); } } return(null); }
public SOperator(string regex, string name, int precedence) { Regex = new Regex(regex); Name = name; Precedence = precedence; Associativity = Associativity.LeftToRight; }
public Operator(TokenKind token1, TokenKind?token2, Associativity assoc, Node.BinaryOperator op) { this.token1 = token1; this.token2 = token2; this.associativity = assoc; this.binaryOp = op; }
public Operator(int precedence, Associativity associativity, Func <Expression> expression, bool isUnary = false) { Precedence = precedence; Associativity = associativity; ExpressionFactory = expression; IsUnary = isUnary; }
public RaspyOperator(char symbol, Associativity associativity, int precedence, int argumentCount) { this.Symbol = symbol; this.Associativity = associativity; this.Precedence = precedence; this.ArgumentCount = argumentCount; }
public Operator(char character, int presedence, int inputs, Associativity associativity) { this.character = character; this.presedence = presedence; this.inputs = inputs; this.associativity = associativity; }
public Operator(Op op, int precedence, int inputs, Associativity associativity) { this.op = op; this.precedence = precedence; this.inputs = inputs; this.associativity = associativity; }
public IdfOperator(string op, Associativity assoc, string compiled, int precedence) { Op = op; Associativity = assoc; Compiled = compiled; Precedence = precedence; }
public void RegisterOperators(int precedence, Associativity associativity, params BnfTerm[] opTerms) { foreach (var term in opTerms) { term.SetFlag(TermFlags.IsOperator); term.Precedence = precedence; term.Associativity = associativity; } }
/// <summary> /// Initializes a nes instance of the <see cref="UnaryOperator"/> class with specified /// associativity, priority, operator, and operand. /// </summary> /// <param name="associativity"> /// The associativity, usual <see cref="Associativity.Right"/> for prefix operators, /// and <see cref="Associativity.Left"/> for postfix operators. /// </param> /// <param name="priority">The priority.</param> /// <param name="@operator">The string representation of the operator.</param> /// <param name="operand">The single operand.</param> protected UnaryOperator(Associativity associativity, Priority priority, string @operator, IExpression operand) { Associativity = associativity; Priority = priority; Operator = @operator; Operand = operand; }
/// <summary> /// token as an int as attribute can not be generics. /// </summary> /// <param name="token">token enum as int value</param> /// <param name="arity">operator arity</param> /// <param name="assoc">operator aosociativity (<see cref="Associativity"/>) </param> /// <param name="precedence">precedence level: the greater, the higher</param> public OperationAttribute(int token, int arity, Associativity assoc, int precedence) { Token = token; Arity = arity; Assoc = assoc; Precedence = precedence; }
public Token(TokenType type, Associativity associativity, int precedence, object value) { this.type = type; this.associativity = associativity; this.precedence = precedence; this.value = value; }
public PrecedenceAttribute(Type term, int value, Associativity assoc = Associativity.Left) { this.TermText = null; this.TermType = term; this.PrecedenceValue = value; this.Associativity = assoc; }
public TokenAttribute(string value, Precedence prec, AstBinaryType binary = 0, Associativity assoc = Associativity.LeftToRight) { Value = value; Precedence = prec; BinaryType = binary; Associativity = assoc; }
public ParseTreeNode(object node, BnfTerm term, int precedence, Associativity associativity, SourceSpan span) { AstNode = node; Term = term; Precedence = precedence; Associativity = associativity; }
public Token(TokenType tokenType, Associativity associativity, int precedenceLevel, string element) { TokenType = tokenType; Associativity = associativity; PrecedenceLevel = precedenceLevel; Element = element; }
public PrecedenceAttribute(Type term, int value, Associativity assoc = Associativity.Left) { this.TermText = null; this.TermType = term; this.PrecedenceValue = value; this.Associativity = assoc; }
public void setValues(char symbol, Associativity assoc, int parameterCount, int precedence) { this.Symbol = symbol; this.assoc = assoc; this.Precedence = precedence; this.ParameterCount = parameterCount; }
public BinaryExpression(string op, Expression left, Expression right, Precedence precedence, Associativity associativity) : base(precedence) { _op = op; _left = left; _right = right; _associativity = associativity; }
public SOperator(string regex, string name, int precedence, Associativity assoc) { Regex = new Regex(regex); Name = name; Precedence = precedence; Associativity = assoc; }
/// <summary> /// token as an int as attribute can not be generics. /// </summary> /// <param name="token">token enum as int value</param> /// <param name="arity">operator arity</param> /// <param name="assoc">operator aosociativity (<see cref="Associativity" />) </param> /// <param name="precedence">precedence level: the greater, the higher</param> public OperationAttribute(int token, Affix affix, Associativity assoc, int precedence) { Token = token; Affix = affix; Assoc = assoc; Precedence = precedence; }
public RaspyOperator(char symbol, Associativity associativity, int precedence, int argumentCount) { this.Symbol = symbol; this.Associativity = associativity; this.Precedence = precedence; this.ArgumentCount = argumentCount; }
/// <summary> /// Initializes a new instance of the <see cref="Operator"/> class. /// </summary> /// <param name="sign">The sign.</param> /// <param name="associativity">The associativity.</param> /// <param name="paramCount">The parameter count.</param> /// <param name="precendence">The precendence.</param> public Operator(string sign = "", Associativity associativity = Expressions.Associativity.None, int paramCount = 1, int precendence = 0) { this.associativity = associativity; this.sign = sign; this.paramCount = paramCount; this.precendence = precendence; }
/// <summary> /// ctor /// </summary> /// <param name="operator"></param> /// <param name="precedence"></param> /// <param name="associativity"></param> /// <param name="unary"></param> /// <param name="evaluation"></param> public Operation(string @operator, int precedence, Associativity associativity, bool unary, Func <SymMathNode, SymMathNode, SymMathNode> evaluation) { Operator = @operator; Precedence = precedence; Associativity = associativity; Unary = unary; Evaluation = evaluation; }
public BinaryOperationToken(char symbol, Func <double, double, double> operation, int priority, Associativity associativity) { this.operation = operation; this.Symbol = symbol; Priority = priority; Associativity = associativity; Length = 1; }
public void RegisterOperators(int precedence, Associativity associativity, params string[] opSymbols) { foreach (string op in opSymbols) { KeyTerm opSymbol = ToTerm(op); opSymbol.SetFlag(TermFlags.IsOperator); opSymbol.Precedence = precedence; opSymbol.Associativity = associativity; } }//method
public OperationMetaData(int precedence, Associativity assoc, MethodInfo method, Affix affix, T oper) { Precedence = precedence; Associativity = assoc; VisitorMethod = method; OperatorToken = oper; Affix = affix; }
private Operator(string symbol, Associativity associativity, int priority, Operation operation) { this.symbol = symbol; this.associativity = associativity; this.priority = priority; this.operation = operation; Operator.values.Add(this); }
public Operator(char s, int p, Associativity a, Calculation calc) { symbol = s; precedence = p; numArgs = 2; assoc = a; calculate = calc; }
public Token(OperatorType operatorType, int operandsCount, Associativity assoc) { this.Type = TokenType.Operator; this.OperatorType = operatorType; this.OperandsCount = operandsCount; this.Associativity = assoc; this.Precedence = GetPrecedence(); }
public Token(OperatorType operatorType, int operandsCount, Associativity assoc) { this.Type = TokenType.Operator; this.OperatorType = operatorType; this.OperandsCount = operandsCount; this.Associativity = assoc; this.Precedence = GetPrecedence(); }
public Token(string identifier, int position, TokenType type) { Identifier = identifier.ToLower(); Position = position; Type = type; Precedence = type.GetPrecedence(); Associativity = type.GetAssociativity(); }
protected GrammarHint ImplyPrecedenceHere(int precedence, Associativity associativity) { var hint = new GrammarHint(HintType.Precedence, null); hint.Precedence = precedence; hint.Associativity = associativity; return(hint); }
/// <summary> /// Initializes a nes instance of the <see cref="BinaryOperator"/> class with specified /// associativity, priority, operator, left, and right operands. /// </summary> /// <param name="associativity"> /// The associativity (usual <see cref="Associativity.Right"/> for power operator, /// and <see cref="Associativity.Left"/> for all the others. /// </param> /// <param name="priority">The priority.</param> /// <param name="@operator">The string representation of the operator.</param> /// <param name="left">The left operand.</param> /// <param name="right">The right operand.</param> protected BinaryOperator(Associativity associativity, Priority priority, string @operator, IExpression left, IExpression right) { Associativity = associativity; Priority = priority; Operator = @operator; Left = left; Right = right; }
public Token(String operand, Associativity assoc, int precedence, int parameterCount) { type = TokenType.Operator; this.operand = operand; this.assoc = assoc; this.precedence = precedence; this.parameterCount = parameterCount; }
/// <summary> Adds the specified operator to the respective appendable sets regarding domainKind, associativity and precedence. </summary> public static void Add(Notion @operator, DomainKind domainKind, Associativity associativity, Set precedenceSet) { Contract.Requires(@operator != null); Contract.RequiresEnumIsDefined(domainKind); Contract.Requires(domainKind != DomainKind.Operand); Contract.RequiresEnumIsDefined(associativity); Contract.Requires(precedenceSet != null); Contract.Requires(ReferenceEquals(precedenceSet.Workspace, @operator.Workspace)); Contract.Requires(Precedences.Contains(precedenceSet)); Contract.Requires(AllAppendableSetsRelationToLinearNotions.All(linearAppendableSet => !linearAppendableSet.Contains(@operator))); Contract.Requires(precedenceSet.IsAppendable); var workspace = @operator.Workspace; precedenceSet.Append(@operator); switch (domainKind) { case DomainKind.UnaryPrefix: UnaryPreOperators.Append(@operator); break; case DomainKind.UnaryPostfix: UnaryPostOperators.Append(@operator); break; case DomainKind.Binary: BinaryOperators.Append(@operator); break; case DomainKind.Nullary: NullaryOperators.Append(@operator); break; case DomainKind.Operand: default: throw new Exception(); } switch (associativity) { case Associativity.Left: LeftAssociativeOperators.Append(@operator); break; case Associativity.Right: RightAssociativeOperators.Append(@operator); break; case Associativity.Undefined: UnassociativeOperators.Append(@operator); break; case Associativity.Associative: AssociativeOperators.Append(@operator); break; default: throw new Exception(); } }
public LinearAPSet(Workspace workspace, Associativity associativity) : base(DefaultNotions.Operators, $"{associativity.ToName()}associative operators", appendable: true) { Contract.Requires(DefaultNotions.Operators != null); Contract.Requires(workspace != null); Contract.RequiresEnumIsDefined(associativity); this.Associativity = associativity; this.PrecedenceComparisonToken = defaultPrecedenceToken; this.DomainKind = defaultDomainKind; }
/// <summary> /// Initializes a new instance of the <see cref="OperatorToken"/> struct. /// </summary> /// <param name="operatorType">Type of the operator.</param> public OperatorToken(OperatorType operatorType) { if (operatorType != OperatorType.Add && operatorType != OperatorType.Divide && operatorType != OperatorType.Multiply && operatorType != OperatorType.Subtract && operatorType != OperatorType.RaiseTo && operatorType != OperatorType.Modulo && operatorType != OperatorType.UnaryMinus) { throw new ArgumentException("The operator type is not of a valid type.", "operatorType"); } this._operatorType = operatorType; this._precedence = operatorType.GetOperatorPrecedence(); this._associativity = operatorType.GetAssociativity(); this._argumentCount = operatorType.GetArgumentCount(); }
// UnaryPlus calls this constructor because it doesn't use the stack protected Function(Priority priority, Associativity associativity) : base(priority, associativity) { }
protected GrammarHint ImplyPrecedenceHere(int precedence, Associativity associativity) { return new ImpliedPrecedenceHint(precedence, associativity); }
public void RegisterOperators(int precedence, Associativity associativity, params BnfTerm[] opTerms) { foreach (var term in opTerms) { term.SetFlag(TermFlags.IsOperator); term.Precedence = precedence; term.Associativity = associativity; } }
public void RegisterOperators(int precedence, Associativity associativity, params string[] opSymbols) { foreach (string op in opSymbols) { SymbolTerminal opSymbol = Symbol(op); opSymbol.SetOption(TermOptions.IsOperator); if (!UsePrecedenceRestricted) opSymbol.SetOption(TermOptions.UsePrecedence); opSymbol.Precedence = precedence; opSymbol.Associativity = associativity; } }//method
public UnaryOperationToken(string symbol, int index, Associativity associativity = Associativity.Right, int precedence = 1) : base(symbol, index, associativity, precedence) { }
public Precedence(int value, Associativity assoc) { this.Value = value; this.Assoc = assoc; }
public BinaryOperationToken(string symbol, int index, Associativity associativity = Associativity.Left, int precedence = 0) : base(symbol, index, associativity, precedence) { }
public Operation(char symbol, int precendence, Associativity associativity) { this.Symbol = symbol; this.Precedence = precendence; this.Associativity = associativity; }
public static void RegisterOperators(int precedence, Associativity associativity, params string[] opSymbols) { foreach (var opSymbol in opSymbols.Select(GetSymbol)) { opSymbol.SetOption(TermOptions.IsOperator, true); opSymbol.Precedence = precedence; opSymbol.Associativity = associativity; } }
public Expr(double value, int precedence, Associativity assoc = Associativity.Left) { this.Value = value; this.Precedence = precedence; this.Associativity = assoc; }
//Must create new overrides here in order to support the "Operator" token color public new void RegisterOperators(int precedence, Associativity associativity, params string[] opSymbols) { foreach (string op in opSymbols) { KeyTerm opSymbol = Operator(op); opSymbol.Precedence = precedence; opSymbol.Associativity = associativity; } }
public TokenOperator( char opcode, Func<double, double, double> op, int priority = 0, Associativity associac = Associativity.Associative ) { this.OpCode = opcode; this.Operator = op; this.Priority = priority; this.Associac = associac; }
protected BinaryOperator(Priority priority, Associativity associativity, Stack<double> stack) : base(priority, associativity, stack) { }
public void RegisterOperators(int precedence, Associativity associativity, params string[] opSymbols) { foreach (string op in opSymbols) { SymbolTerminal opSymbol = SymbolTerminal.GetSymbol(op); opSymbol.SetOption(TermOptions.IsOperator, true); opSymbol.Precedence = precedence; opSymbol.Associativity = associativity; } }
protected Operator(Priority priority, Associativity associativity, Stack<double> stack) : base(stack) { Priority = priority; Associativity = associativity; }
protected Function(Priority priority, Associativity associativity, Stack<double> stack) : base(priority, associativity, stack) { }
public Token(string symbol, int index, Associativity associativity, int precedence) { Symbol = symbol; Index = index; Associativity = associativity; Precedence = precedence; }
protected GrammarHint ImplyPrecedenceHere(int precedence, Associativity associativity) { var hint = new GrammarHint(HintType.Precedence, null); hint.Precedence = precedence; hint.Associativity = associativity; return hint; }
// Bracket does not need to pass stack because it doesn't use it in Execute protected Operator(Priority priority, Associativity associativity) : this(priority, associativity, null) { }
public void RegisterOperators(int precedence, Associativity associativity, params string[] opSymbols) { foreach (string op in opSymbols) { KeyTerm opSymbol = ToTerm(op); opSymbol.SetFlag(TermFlags.IsOperator); opSymbol.Precedence = precedence; opSymbol.Associativity = associativity; } }
// a flag to mark a state for setting implied precedence //GrammarHint inherits Precedence and Associativity members from BnfTerm; we'll use them to store implied values for this hint public ImpliedPrecedenceHint(int precedence, Associativity associativity) { Precedence = precedence; Associativity = associativity; }
public void RegisterOperators(int precedence, Associativity associativity, params BnfTerm[] opTerms) { foreach (var term in opTerms) { term.SetOption(TermOptions.IsOperator); if (!UsePrecedenceRestricted) term.SetOption(TermOptions.UsePrecedence); term.Precedence = precedence; term.Associativity = associativity; } }