private Precedence?GetPrecedenceIfOperator(LNode node, OperatorShape shape, Precedence context) { int ac = node.ArgCount; if ((ac == (int)shape || ac == -(int)shape) && HasSimpleTargetWithoutPAttrs(node)) { var bs = node.BaseStyle; var op = node.Name; bool naturalOp = LesPrecedenceMap.IsNaturalOperator(op); if (bs == NodeStyle.Operator || (naturalOp && bs != NodeStyle.PrefixNotation)) { var result = _prec.Find(shape, op); if (bs == NodeStyle.Operator && !naturalOp) { result = LesPrecedence.Backtick; } else if (!result.CanAppearIn(context)) { result = LesPrecedence.Backtick; } if (!result.CanAppearIn(context) || !result.CanMixWith(context)) { return(null); } return(result); } } return(null); }
private Precedence?GetPrecedenceIfOperator(ILNode node, Symbol opName, OperatorShape shape, Precedence context) { int ac = node.ArgCount(); if ((ac == (int)shape || ac == -(int)shape) && HasTargetIdWithoutPAttrs(node)) { var bs = node.BaseStyle(); bool naturalOp = Les2PrecedenceMap.IsNaturalOperator(opName.Name); if ((naturalOp && bs != NodeStyle.PrefixNotation) || (bs == NodeStyle.Operator && node.Name != null)) { var result = _prec.Find(shape, opName); if (!result.CanAppearIn(context) || !result.CanMixWith(context)) { return(null); } return(result); } } return(null); }
Pair<MMap<object, Precedence>, Precedence> this[OperatorShape s] { get { return _precedenceMap[(int)s + 1]; } set { _precedenceMap[(int)s + 1] = value; } }
/// <summary>Gets the precedence of a prefix, suffix, or infix operator in /// LES, under the assumption that the operator isn't surrounded in /// backticks (in which case its precedence is always Backtick).</summary> /// <param name="op">Parsed form of the operator. op must be a Symbol, but /// the parameter has type object to avoid casting Token.Value in the parser.</param> public Precedence Find(OperatorShape shape, object op, bool cacheWordOp = true) { var pair = this[shape]; return FindPrecedence(pair.A, op, pair.B, cacheWordOp); }
protected Pair <MMap <object, Precedence>, Precedence> this[OperatorShape s] { get { return(_precedenceMap[(int)s + 1]); } set { _precedenceMap[(int)s + 1] = value; } }
/// <summary>Gets the precedence in LES of a prefix, suffix, or infix operator.</summary> /// <param name="shape">Specifies which precedence table and rules to use /// (Prefix, Suffix or Infix). Note: when this is Suffix, "_" is not expected /// to be part of the name in <c>op</c>, i.e. op should be a Symbol like "'++" /// rather than "'_++" (see also <see cref="ResemblesSuffixOperator"/>)</param> /// <param name="op">Parsed form of the operator. op must be a Symbol, but /// the parameter has type object to avoid casting Token.Value in the parser.</param> public Precedence Find(OperatorShape shape, object op, bool cacheWordOp = true) { var pair = this[shape]; return(FindPrecedence(pair.A, op, pair.B, cacheWordOp)); }
/// <summary>Gets the precedence in LES of a prefix, suffix, or infix operator.</summary> /// <param name="shape">Specifies which precedence table and rules to use /// (Prefix, Suffix or Infix). Note: when this is Suffix, "suf" must not be /// part of the name in <c>op</c> (see <see cref="IsSuffixOperatorName"/>)</param> /// <param name="op">Parsed form of the operator. op must be a Symbol, but /// the parameter has type object to avoid casting Token.Value in the parser.</param> public Precedence Find(OperatorShape shape, object op, bool cacheWordOp = true, bool les3InfixOp = false) { var pair = this[shape]; return FindPrecedence(pair.A, op, pair.B, cacheWordOp, les3InfixOp); }