Find() 공개 메소드

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
리턴 Precedence
예제 #1
0
 private Precedence PrefixPrecedenceOf(Token t)
 {
     if (t.TypeInt == (int)TT.BQString)
     {
         return(LesPrecedence.Prefix);
     }
     return(_prec.Find(OperatorShape.Prefix, t.Value));
 }
예제 #2
0
 protected Precedence PrefixPrecedenceOf(Token t)
 {
     if (t.TypeInt == (int)TT.BQOperator)
     {
         return(LesPrecedence.Prefix);
     }
     return(_prec.Find(OperatorShape.Prefix, t.Value));
 }
예제 #3
0
        protected Precedence PrefixPrecedenceOf(Token t)
        {
            var prec = _prec.Find(OperatorShape.Prefix, t.Value);

            if (prec == LesPrecedence.Other)
            {
                ErrorSink.Write(Severity.Error, F.Id(t),
                                "Operator `{0}` cannot be used as a prefix operator", t.Value);
            }
            return(prec);
        }
예제 #4
0
        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);
        }
예제 #5
0
        private Precedence?GetPrecedenceIfOperator(ILNode node, OperatorShape shape, Precedence context)
        {
            int ac = node.ArgCount();

            if ((ac == (int)shape || ac == -(int)shape) && HasTargetIdWithoutPAttrs(node))
            {
                var  bs        = node.BaseStyle();
                var  op        = node.Name;
                bool naturalOp = LesPrecedenceMap.IsNaturalOperator(op.Name);
                if ((naturalOp && bs != NodeStyle.PrefixNotation) ||
                    (bs == NodeStyle.Operator && node.Name != null))
                {
                    var result = _prec.Find(shape, op);
                    if (!result.CanAppearIn(context) || !result.CanMixWith(context))
                    {
                        return(null);
                    }
                    return(result);
                }
            }
            return(null);
        }