Beispiel #1
0
        public void propertyType(ArrayList list, Token identifier)
        {
            Token id = null;
            Object body = null;
            Token body2 = null;
            bool bval = false;
            LiteralConstraint vc;
            BoundConstraint bc;
            OrLiteralConstraint orc;
            AndLiteralConstraint andc;
            ArrayList andor = new ArrayList();
            MultiValue mv = null;
            if (mcc_2_26(2147483647))
            {
                predicateFunc(list, identifier);
            }
            else if (mcc_2_27(2147483647))
            {
                body2 = mcc_consume_token(BIND4);
                if (body2 != null)
                {
                    bc = new BoundConstraint();
                    bc.Name = identifier.image;
                    bc.Value = body2.image.Substring(2);
                    bc.IsMultislot = true;
                    list.Add(bc);
                }
            }
            else if (mcc_2_28(2147483647))
            {
                body2 = mcc_consume_token(BIND);
                if (body2 != null)
                {
                    bc = new BoundConstraint();
                    bc.Name = identifier.image;
                    bc.Value = body2.image.Substring(1);
                    list.Add(bc);
                }
            }
            else if (mcc_2_29(2147483647))
            {
                mcc_consume_token(TILDA);
                body2 = mcc_consume_token(BIND);
                if (body2 != null)
                {
                    bc = new BoundConstraint();
                    bc.Name = identifier.image;
                    bc.Value = body2.image.Substring(1);
                    bc.Negated = true;
                    list.Add(bc);
                }
            }
            else if (mcc_2_30(2147483647))
            {
                body = typeExpr();
                while (true)
                {
                    mcc_consume_token(OR2);
                    orType(andor);
                    switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                    {
                        case OR2:
                            ;
                            break;
                        default:
                            mcc_la1[51] = mcc_gen;
                            goto label_25;
                    }
                }
                label_25:
                ;

                if (body != null)
                {
                    orc = new OrLiteralConstraint();
                    orc.Name = identifier.image;
                    mv = new MultiValue(body);
                    orc.addValue(mv);
                    orc.addValues(andor);
                    list.Add(orc);
                }
            }
            else if (mcc_2_31(2147483647))
            {
                mcc_consume_token(TILDA);
                body = typeExpr();
                while (true)
                {
                    mcc_consume_token(OR2);
                    orType(andor);
                    switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                    {
                        case OR2:
                            ;
                            break;
                        default:
                            mcc_la1[52] = mcc_gen;
                            goto label_26;
                    }
                }
                label_26:
                ;

                if (body != null)
                {
                    orc = new OrLiteralConstraint();
                    orc.Name = identifier.image;
                    mv = new MultiValue(body);
                    mv.Negated = true;
                    orc.addValue(mv);
                    orc.addValues(andor);
                    list.Add(orc);
                }
            }
            else if (mcc_2_32(2147483647))
            {
                body = bindTypeExpr();
                while (true)
                {
                    mcc_consume_token(AND2);
                    andType(andor);
                    switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                    {
                        case AND2:
                            ;
                            break;
                        default:
                            mcc_la1[53] = mcc_gen;
                            goto label_27;
                    }
                }
                label_27:
                ;

                if (body != null)
                {
                    if (body is String && ((String) body).StartsWith("?"))
                    {
                        bc = new BoundConstraint();
                        bc.Name = identifier.image;
                        bc.Value = ((String) body).Substring(1);
                        bc.IntraFactJoin = true;
                        bc.addIntrFactJoin(andor);
                        list.Add(bc);
                    }
                    else
                    {
                        andc = new AndLiteralConstraint();
                        andc.Name = identifier.image;
                        mv = new MultiValue(body);
                        andc.addValue(mv);
                        andc.addValues(andor);
                        list.Add(andc);
                    }
                }
            }
            else if (mcc_2_33(2147483647))
            {
                mcc_consume_token(TILDA);
                body = typeExpr();
                while (true)
                {
                    mcc_consume_token(AND2);
                    andType(andor);
                    switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                    {
                        case AND2:
                            ;
                            break;
                        default:
                            mcc_la1[54] = mcc_gen;
                            goto label_28;
                    }
                }
                label_28:
                ;

                if (body != null)
                {
                    andc = new AndLiteralConstraint();
                    andc.Name = identifier.image;
                    mv = new MultiValue(body);
                    mv.Negated = true;
                    andc.addValue(mv);
                    andc.addValues(andor);
                    list.Add(andc);
                }
            }
            else if (mcc_2_34(2147483647))
            {
                mcc_consume_token(TILDA);
                body = typeExpr();
                if (body != null)
                {
                    vc = new LiteralConstraint();
                    vc.Name = identifier.image;
                    vc.Value = body;
                    vc.Negated = true;
                    list.Add(vc);
                }
            }
            else if (mcc_2_35(2147483647))
            {
                id = mcc_consume_token(IDENTIFIER);
                if (id != null)
                {
                    vc = new LiteralConstraint();
                    vc.Name = identifier.image;
                    vc.Value = id.image;
                    list.Add(vc);
                }
            }
            else if (mcc_2_36(2147483647))
            {
                mcc_consume_token(TILDA);
                id = mcc_consume_token(IDENTIFIER);
                if (id != null)
                {
                    vc = new LiteralConstraint();
                    vc.Name = identifier.image;
                    vc.Value = id.image;
                    vc.Negated = true;
                    list.Add(vc);
                }
            }
            else
            {
                switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                {
                    case INTEGER_LITERAL:
                    case FLOATING_POINT_LITERAL:
                    case STRING_LITERAL:
                    case PATH_LITERAL:
                        body = typeExpr();
                        if (body != null)
                        {
                            vc = new LiteralConstraint();
                            vc.Name = identifier.image;
                            vc.Value = body;
                            list.Add(vc);
                        }
                        break;
                    case TRUE:
                    case TRUE2:
                    case FALSE:
                    case FALSE2:
                        bval = trueFalse();
                        vc = new LiteralConstraint();
                        vc.Name = identifier.image;
                        vc.Value = Convert.ToBoolean(bval);
                        list.Add(vc);
                        break;
                    default:
                        mcc_la1[55] = mcc_gen;
                        mcc_consume_token(-1);
                        throw new ParseException();
                }
            }
        }
Beispiel #2
0
        public void propertyType(IList list, Token identifier)
        {
            Token id = null;
            Object body = null;
            Token body2 = null;
            bool bval = false;
            LiteralConstraint vc;
            BoundConstraint bc;
            OrLiteralConstraint orc;
            AndLiteralConstraint andc;
            //UPGRADE_TODO: Field java.util was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1095"'
            IList andor = new ArrayList();
            MultiValue mv = null;
            if (jj_2_26(2147483647))
            {
                predicateFunc(list, identifier);
            }
            else if (jj_2_27(2147483647))
            {
                body2 = jj_consume_token(CLIPSParserConstants_Fields.BIND4);
                if (body2 != null)
                {
                    bc = new BoundConstraint();
                    bc.Name = identifier.image;
                    bc.Value = body2.image.Substring(2);
                    bc.IsMultislot = true;
                    list.Add(bc);
                }
            }
            else if (jj_2_28(2147483647))
            {
                body2 = jj_consume_token(CLIPSParserConstants_Fields.BIND);
                if (body2 != null)
                {
                    bc = new BoundConstraint();
                    bc.Name = identifier.image;
                    bc.Value = body2.image.Substring(1);
                    list.Add(bc);
                }
            }
            else if (jj_2_29(2147483647))
            {
                jj_consume_token(CLIPSParserConstants_Fields.TILDA);
                body2 = jj_consume_token(CLIPSParserConstants_Fields.BIND);
                if (body2 != null)
                {
                    bc = new BoundConstraint();
                    bc.Name = identifier.image;
                    bc.Value = body2.image.Substring(1);
                    bc.Negated = true;
                    list.Add(bc);
                }
            }
            else if (jj_2_30(2147483647))
            {
                body = typeExpr();
                while (true)
                {
                    jj_consume_token(CLIPSParserConstants_Fields.OR2);
                    orType(andor);
                    switch ((jj_ntk_Renamed_Field == - 1) ? jj_ntk() : jj_ntk_Renamed_Field)
                    {
                        case CLIPSParserConstants_Fields.OR2:
                            ;
                            break;

                        default:
                            jj_la1[49] = jj_gen;
                            //UPGRADE_NOTE: Labeled break statement was changed to a goto statement. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1012"'
                            goto label_24_brk;
                    }
                }
                //UPGRADE_NOTE: Label 'label_24_brk' was added. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1011"'
                label_24_brk:
                ;

                if (body != null)
                {
                    orc = new OrLiteralConstraint();
                    orc.Name = identifier.image;
                    mv = new MultiValue(body);
                    orc.addValue(mv);
                    orc.addValues(andor);
                    list.Add(orc);
                }
            }
            else if (jj_2_31(2147483647))
            {
                jj_consume_token(CLIPSParserConstants_Fields.TILDA);
                body = typeExpr();
                while (true)
                {
                    jj_consume_token(CLIPSParserConstants_Fields.OR2);
                    orType(andor);
                    switch ((jj_ntk_Renamed_Field == - 1) ? jj_ntk() : jj_ntk_Renamed_Field)
                    {
                        case CLIPSParserConstants_Fields.OR2:
                            ;
                            break;

                        default:
                            jj_la1[50] = jj_gen;
                            //UPGRADE_NOTE: Labeled break statement was changed to a goto statement. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1012"'
                            goto label_25_brk;
                    }
                }
                //UPGRADE_NOTE: Label 'label_25_brk' was added. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1011"'
                label_25_brk:
                ;

                if (body != null)
                {
                    orc = new OrLiteralConstraint();
                    orc.Name = identifier.image;
                    mv = new MultiValue(body);
                    mv.Negated = true;
                    orc.addValue(mv);
                    orc.addValues(andor);
                    list.Add(orc);
                }
            }
            else if (jj_2_32(2147483647))
            {
                body = typeExpr();
                while (true)
                {
                    jj_consume_token(CLIPSParserConstants_Fields.AND2);
                    andType(andor);
                    switch ((jj_ntk_Renamed_Field == - 1) ? jj_ntk() : jj_ntk_Renamed_Field)
                    {
                        case CLIPSParserConstants_Fields.AND2:
                            ;
                            break;

                        default:
                            jj_la1[51] = jj_gen;
                            //UPGRADE_NOTE: Labeled break statement was changed to a goto statement. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1012"'
                            goto label_26_brk;
                    }
                }
                //UPGRADE_NOTE: Label 'label_26_brk' was added. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1011"'
                label_26_brk:
                ;

                if (body != null)
                {
                    andc = new AndLiteralConstraint();
                    andc.Name = identifier.image;
                    mv = new MultiValue(body);
                    andc.addValue(mv);
                    andc.addValues(andor);
                    list.Add(andc);
                }
            }
            else if (jj_2_33(2147483647))
            {
                jj_consume_token(CLIPSParserConstants_Fields.TILDA);
                body = typeExpr();
                while (true)
                {
                    jj_consume_token(CLIPSParserConstants_Fields.AND2);
                    andType(andor);
                    switch ((jj_ntk_Renamed_Field == - 1) ? jj_ntk() : jj_ntk_Renamed_Field)
                    {
                        case CLIPSParserConstants_Fields.AND2:
                            ;
                            break;

                        default:
                            jj_la1[52] = jj_gen;
                            //UPGRADE_NOTE: Labeled break statement was changed to a goto statement. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1012"'
                            goto label_27_brk;
                    }
                }
                //UPGRADE_NOTE: Label 'label_27_brk' was added. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1011"'
                label_27_brk:
                ;

                if (body != null)
                {
                    andc = new AndLiteralConstraint();
                    andc.Name = identifier.image;
                    mv = new MultiValue(body);
                    mv.Negated = true;
                    andc.addValue(mv);
                    andc.addValues(andor);
                    list.Add(andc);
                }
            }
            else if (jj_2_34(2147483647))
            {
                jj_consume_token(CLIPSParserConstants_Fields.TILDA);
                body = typeExpr();
                if (body != null)
                {
                    vc = new LiteralConstraint();
                    vc.Name = identifier.image;
                    vc.Value = body;
                    vc.Negated = true;
                    list.Add(vc);
                }
            }
            else if (jj_2_35(2147483647))
            {
                id = jj_consume_token(CLIPSParserConstants_Fields.IDENTIFIER);
                if (id != null)
                {
                    vc = new LiteralConstraint();
                    vc.Name = identifier.image;
                    vc.Value = id.image;
                    list.Add(vc);
                }
            }
            else if (jj_2_36(2147483647))
            {
                jj_consume_token(CLIPSParserConstants_Fields.TILDA);
                id = jj_consume_token(CLIPSParserConstants_Fields.IDENTIFIER);
                if (id != null)
                {
                    vc = new LiteralConstraint();
                    vc.Name = identifier.image;
                    vc.Value = id.image;
                    vc.Negated = true;
                    list.Add(vc);
                }
            }
            else
            {
                switch ((jj_ntk_Renamed_Field == - 1) ? jj_ntk() : jj_ntk_Renamed_Field)
                {
                    case CLIPSParserConstants_Fields.INTEGER_LITERAL:
                    case CLIPSParserConstants_Fields.FLOATING_POINT_LITERAL:
                    case CLIPSParserConstants_Fields.STRING_LITERAL:
                    case CLIPSParserConstants_Fields.PATH_LITERAL:
                        body = typeExpr();
                        if (body != null)
                        {
                            vc = new LiteralConstraint();
                            vc.Name = identifier.image;
                            vc.Value = body;
                            list.Add(vc);
                        }
                        break;

                    case CLIPSParserConstants_Fields.TRUE:
                    case CLIPSParserConstants_Fields.TRUE2:
                    case CLIPSParserConstants_Fields.FALSE:
                    case CLIPSParserConstants_Fields.FALSE2:
                        bval = trueFalse();
                        vc = new LiteralConstraint();
                        vc.Name = identifier.image;
                        vc.Value = bval;
                        list.Add(vc);
                        break;

                    default:
                        jj_la1[53] = jj_gen;
                        jj_consume_token(- 1);
                        throw new ParseException();
                }
            }
        }
Beispiel #3
0
 /*
 public virtual ObjectTypeNode findObjectTypeNode(String templateName)
 {
     IEnumerator itr = inputnodes.keySet().GetEnumerator();
     Template tmpl = null;
     while (itr.MoveNext())
     {
         tmpl = (Template)itr.Current;
         if (tmpl.Name.Equals(templateName))
         {
             break;
         }
     }
     if (tmpl != null)
     {
         return (ObjectTypeNode)inputnodes.Get(tmpl);
     }
     else
     {
         log.Debug(Messages.getString("RuleCompiler.deftemplate.error")); //$NON-NLS-1$
         return null;
     }
 }
 */
 /// <summary>
 /// method compiles a literalConstraint
 /// </summary>
 /// <param name="cnstr">The CNSTR.</param>
 /// <param name="templ">The templ.</param>
 /// <param name="rule">The rule.</param>
 /// <returns></returns>
 public virtual BaseAlpha2 compileConstraint(LiteralConstraint cnstr, ITemplate templ, Rule.IRule rule)
 {
     BaseAlpha2 current = null;
     if (templ.getSlot(cnstr.Name) != null)
     {
         Slot sl = (Slot) templ.getSlot(cnstr.Name).Clone();
         Object sval = ConversionUtils.convert(sl.ValueType, cnstr.Value);
         sl.Value = sval;
         if (rule.RememberMatch)
         {
             current = new AlphaNode(engine.nextNodeId());
         }
         else
         {
             current = new NoMemANode(engine.nextNodeId());
         }
         current.Slot = sl;
         current.Operator = Constants.EQUAL;
         current.incrementUseCount();
         // we increment the node use count when when create a new
         // AlphaNode for the LiteralConstraint
         templ.getSlot(sl.Id).incrementNodeCount();
     }
     return current;
 }