Exemple #1
0
        private object CreateNewObject(GOLD.Reduction r)
        {
            object result = null;

            switch ((ProductionIndex)r.Parent.TableIndex()) {
                case ProductionIndex.Nl_Newline:
                    // <nl> ::= NewLine <nl>
                    break;

                case ProductionIndex.Nl_Newline2:
                    // <nl> ::= NewLine
                    break;

                case ProductionIndex.Regform_Pipepipe:
                    // <regForm> ::= <regForm> '||' <regFormSeq>
                    result = new UnionFormula((RegularFormula)r[0].Data, (RegularFormula)r[2].Data);
                    break;

                case ProductionIndex.Regform:
                    // <regForm> ::= <regFormSeq>
                    result = r[0].Data;
                    break;

                case ProductionIndex.Regformseq_Dot:
                    // <regFormSeq> ::= <regFormSeq> '.' <regFormValue>
                    result = new SequenceFormula((RegularFormula)r[0].Data, (RegularFormula)r[2].Data);
                    break;

                case ProductionIndex.Regformseq:
                    // <regFormSeq> ::= <regFormValue>
                    result = r[0].Data;
                    break;

                case ProductionIndex.Regformvalue_Identifier:
                    // <regFormValue> ::= Identifier <Multiplier>
                    result = new SingleAction((string)r[0].Data, (string)r[1].Data);
                    break;

                case ProductionIndex.Regformvalue_Not:
                    // <regFormValue> ::= not <regForm>
                    result = new NegateAction((RegularFormula)r[1].Data);
                    break;

                case ProductionIndex.Regformvalue_Lparen_Rparen:
                    // <regFormValue> ::= '(' <regForm> ')' <Multiplier>
                    if ((string)r[3].Data != "")
                        return new NestedFormula((RegularFormula)r[1].Data, (string)r[3].Data);
                    else // small optimization
                        result = r[1].Data;
                    break;

                case ProductionIndex.Multiplier_Plus:
                    // <Multiplier> ::= '+'
                    result = "+";
                    break;

                case ProductionIndex.Multiplier_Times:
                    // <Multiplier> ::= '*'
                    result = "*";
                    break;

                case ProductionIndex.Multiplier:
                    // <Multiplier> ::=
                    result = "";
                    break;

                case ProductionIndex.Muform_Identifier:
                    // <muForm> ::= Identifier
                    result = new Proposition((string)r[0].Data);
                    break;

                case ProductionIndex.Muform_Variable:
                    // <muForm> ::= Variable
                    result = new Variable((string)r[0].Data);
                    break;

                case ProductionIndex.Muform_Lparen_Pipepipe_Rparen:
                    // <muForm> ::= '(' <muForm> '||' <muForm> ')'
                    result = new Disjunction((MuFormula)r[1].Data, (MuFormula)r[3].Data);
                    break;

                case ProductionIndex.Muform_Lparen_Ampamp_Rparen:
                    // <muForm> ::= '(' <muForm> '&&' <muForm> ')'
                    result = new Conjunction((MuFormula)r[1].Data, (MuFormula)r[3].Data);
                    break;

                case ProductionIndex.Muform_Lt_Gt:
                    // <muForm> ::= '<' <regForm> '>' <muForm>
                    result = new Diamond((RegularFormula)r[1].Data, (MuFormula)r[3].Data);
                    break;

                case ProductionIndex.Muform_Lbracket_Rbracket:
                    // <muForm> ::= '[' <regForm> ']' <muForm>
                    result = new Box((RegularFormula)r[1].Data, (MuFormula)r[3].Data);
                    break;

                case ProductionIndex.Muform_Mu_Variable_Dot:
                    // <muForm> ::= mu Variable '.' <muForm>
                    result = new Mu(new Variable((string)r[1].Data), (MuFormula)r[3].Data);
                    break;

                case ProductionIndex.Muform_Nu_Variable_Dot:
                    // <muForm> ::= nu Variable '.' <muForm>
                    result = new Nu(new Variable((string)r[1].Data), (MuFormula)r[3].Data);
                    break;

                case ProductionIndex.Muform_Not:
                    // <muForm> ::= not <muForm>
                    result = new Negation((MuFormula)r[1].Data);
                    break;

                case ProductionIndex.Muform_Lparen_Rparen:
                    result = r[1].Data as MuFormula;
                    break;

                case ProductionIndex.Line_Commentl:
                    // <Line> ::= CommentL <nl>
                    break;

                case ProductionIndex.Line:
                    // <Line> ::= <muForm> <nl>
                    var form = (MuFormula)r[0].Data;
                    FormulaRewriter.ResetFreeVars();
                    form = FormulaRewriter.Rewrite(form);
                    form.SetParents(null /* root has no parent */);
                    formulas.Add(form);
                    break;

                case ProductionIndex.Line2:
                    // <Line> ::= <nl>
                    break;

                case ProductionIndex.Lines:
                    // <Lines> ::= <Line> <Lines>
                    break;

                case ProductionIndex.Lines2:
                    // <Lines> ::=
                    break;

            } //switch

            return result;
        }
Exemple #2
0
        private object CreateNewObject(GOLD.Reduction r)
        {
            object result = null;

            switch ((ProductionIndex)r.Parent.TableIndex())
            {
            case ProductionIndex.Nl_Newline:
                // <nl> ::= NewLine <nl>
                break;

            case ProductionIndex.Nl_Newline2:
                // <nl> ::= NewLine
                break;

            case ProductionIndex.Regform_Pipepipe:
                // <regForm> ::= <regForm> '||' <regFormSeq>
                result = new UnionFormula((RegularFormula)r[0].Data, (RegularFormula)r[2].Data);
                break;

            case ProductionIndex.Regform:
                // <regForm> ::= <regFormSeq>
                result = r[0].Data;
                break;

            case ProductionIndex.Regformseq_Dot:
                // <regFormSeq> ::= <regFormSeq> '.' <regFormValue>
                result = new SequenceFormula((RegularFormula)r[0].Data, (RegularFormula)r[2].Data);
                break;

            case ProductionIndex.Regformseq:
                // <regFormSeq> ::= <regFormValue>
                result = r[0].Data;
                break;

            case ProductionIndex.Regformvalue_Identifier:
                // <regFormValue> ::= Identifier <Multiplier>
                result = new SingleAction((string)r[0].Data, (string)r[1].Data);
                break;

            case ProductionIndex.Regformvalue_Not:
                // <regFormValue> ::= not <regForm>
                result = new NegateAction((RegularFormula)r[1].Data);
                break;

            case ProductionIndex.Regformvalue_Lparen_Rparen:
                // <regFormValue> ::= '(' <regForm> ')' <Multiplier>
                if ((string)r[3].Data != "")
                {
                    return(new NestedFormula((RegularFormula)r[1].Data, (string)r[3].Data));
                }
                else                         // small optimization
                {
                    result = r[1].Data;
                }
                break;

            case ProductionIndex.Multiplier_Plus:
                // <Multiplier> ::= '+'
                result = "+";
                break;

            case ProductionIndex.Multiplier_Times:
                // <Multiplier> ::= '*'
                result = "*";
                break;

            case ProductionIndex.Multiplier:
                // <Multiplier> ::=
                result = "";
                break;

            case ProductionIndex.Muform_Identifier:
                // <muForm> ::= Identifier
                result = new Proposition((string)r[0].Data);
                break;

            case ProductionIndex.Muform_Variable:
                // <muForm> ::= Variable
                result = new Variable((string)r[0].Data);
                break;

            case ProductionIndex.Muform_Lparen_Pipepipe_Rparen:
                // <muForm> ::= '(' <muForm> '||' <muForm> ')'
                result = new Disjunction((MuFormula)r[1].Data, (MuFormula)r[3].Data);
                break;

            case ProductionIndex.Muform_Lparen_Ampamp_Rparen:
                // <muForm> ::= '(' <muForm> '&&' <muForm> ')'
                result = new Conjunction((MuFormula)r[1].Data, (MuFormula)r[3].Data);
                break;

            case ProductionIndex.Muform_Lt_Gt:
                // <muForm> ::= '<' <regForm> '>' <muForm>
                result = new Diamond((RegularFormula)r[1].Data, (MuFormula)r[3].Data);
                break;

            case ProductionIndex.Muform_Lbracket_Rbracket:
                // <muForm> ::= '[' <regForm> ']' <muForm>
                result = new Box((RegularFormula)r[1].Data, (MuFormula)r[3].Data);
                break;

            case ProductionIndex.Muform_Mu_Variable_Dot:
                // <muForm> ::= mu Variable '.' <muForm>
                result = new Mu(new Variable((string)r[1].Data), (MuFormula)r[3].Data);
                break;

            case ProductionIndex.Muform_Nu_Variable_Dot:
                // <muForm> ::= nu Variable '.' <muForm>
                result = new Nu(new Variable((string)r[1].Data), (MuFormula)r[3].Data);
                break;

            case ProductionIndex.Muform_Not:
                // <muForm> ::= not <muForm>
                result = new Negation((MuFormula)r[1].Data);
                break;

            case ProductionIndex.Muform_Lparen_Rparen:
                result = r[1].Data as MuFormula;
                break;

            case ProductionIndex.Line_Commentl:
                // <Line> ::= CommentL <nl>
                break;


            case ProductionIndex.Line:
                // <Line> ::= <muForm> <nl>
                var form = (MuFormula)r[0].Data;
                FormulaRewriter.ResetFreeVars();
                form = FormulaRewriter.Rewrite(form);
                form.SetParents(null /* root has no parent */);
                formulas.Add(form);
                break;

            case ProductionIndex.Line2:
                // <Line> ::= <nl>
                break;

            case ProductionIndex.Lines:
                // <Lines> ::= <Line> <Lines>
                break;

            case ProductionIndex.Lines2:
                // <Lines> ::=
                break;
            }             //switch

            return(result);
        }