Find() public method

Gets the precedence in LES of a prefix, suffix, or infix operator.
public Find ( OperatorShape shape, object op, bool cacheWordOp = true, bool les3InfixOp = false ) : Precedence
shape OperatorShape 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 op (see )
op object Parsed form of the operator. op must be a Symbol, but /// the parameter has type object to avoid casting Token.Value in the parser.
cacheWordOp bool
les3InfixOp bool
return Precedence
Beispiel #1
0
 protected Precedence PrefixPrecedenceOf(Token t)
 {
     if (t.TypeInt == (int)TT.BQOperator)
     {
         return(LesPrecedence.Prefix);
     }
     return(_prec.Find(OperatorShape.Prefix, t.Value));
 }
Beispiel #2
0
        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);
        }