Пример #1
0
        /// <summary>
        /// Constructor of the grammar node.
        /// </summary>
        /// <param name="p">Parent master grammar.</param>
        public NumericExprT(MasterGrammar p) : base(p)
        {
            // NON-TERMINAL AND TERMINAL SYMBOLS

            var numericExprT        = new NonTerminal("Timed numeric expression", typeof(TransientAstNode));
            var numericExprTSimple  = new NonTerminal("Simple timed numeric expression", typeof(TimedNumericExpressionAstNode));
            var numericExprTComplex = new NonTerminal("Product of timed numeric expression", typeof(TransientAstNode));

            var numericExprTProduct         = new NonTerminal("Product variant of timed numeric expression", typeof(TimedNumericExpressionAstNode));
            var numericExprTProductVariant  = new NonTerminal("Either product variant of timed numeric expression", typeof(TransientAstNode));
            var numericExprTProductVariant1 = new NonTerminal("Product variant 1 of timed numeric expression", typeof(TransientAstNode));
            var numericExprTProductVariant2 = new NonTerminal("Product variant 2 of timed numeric expression", typeof(TransientAstNode));

            // USED SUB-TREES

            var numericExpr = new NumericExpr(p);

            // RULES

            numericExprT.Rule        = numericExprTSimple | numericExprTComplex;
            numericExprTSimple.Rule  = p.ToTerm("#t");
            numericExprTComplex.Rule = p.ToTerm("(") + numericExprTProduct + ")";

            numericExprTProduct.Rule         = p.ToTerm("*") + numericExprTProductVariant;
            numericExprTProductVariant.Rule  = numericExprTProductVariant1 | numericExprTProductVariant2;
            numericExprTProductVariant1.Rule = p.ToTerm("#t") + numericExpr;
            numericExprTProductVariant2.Rule = numericExpr + "#t";

            p.MarkTransient(numericExprT, numericExprTComplex, numericExprTProductVariant);

            Rule = numericExprT;
        }
Пример #2
0
        /// <summary>
        /// Constructor of the grammar node.
        /// </summary>
        /// <param name="p">Parent master grammar.</param>
        public PreGd(MasterGrammar p) : base(p)
        {
            // NON-TERMINAL AND TERMINAL SYMBOLS

            var preGd         = new NonTerminal("Pre-GD", typeof(TransientAstNode));
            var preGdBase     = new NonTerminal("Pre-GD base", typeof(TransientAstNode));
            var preGdStarList = new NonTerminal("Pre-GD star-list", typeof(TransientAstNode));

            var prefPreGdBase   = new NonTerminal("Preference expression (pre-GD)", typeof(PreferenceGdAstNode));
            var prefNameOrEmpty = new NonTerminal("Optional preference name", typeof(TransientAstNode));
            var prefName        = new IdentifierTerminal("Preference name", IdentifierType.CONSTANT);

            var andPreGdBase    = new NonTerminal("AND expression (pre-GDs)", typeof(AndGdAstNode));
            var forallPreGdBase = new NonTerminal("FORALL expression (pre-GD)", typeof(ForallGdAstNode));
            var orGdBase        = new NonTerminal("OR expression (pre-GD)", typeof(OrGdAstNode));
            var notGdBase       = new NonTerminal("NOT expression (pre-GD)", typeof(NotGdAstNode));
            var implyGdBase     = new NonTerminal("IMPLY expression (pre-GD)", typeof(ImplyGdAstNode));
            var existsGdBase    = new NonTerminal("EXISTS expression (pre-GD)", typeof(ExistsGdAstNode));
            var equalsOpGdBase  = new NonTerminal("Equals operator (pre-GD)", typeof(EqualsOpGdAstNode));

            var numCompGdBase  = new NonTerminal("Numeric comparison expression (pre-GD)", typeof(NumCompGdAstNode));
            var binaryComparer = new NonTerminal("Binary comparer", typeof(TransientAstNode));

            var gdStarList = new NonTerminal("GD star-list", typeof(TransientAstNode));

            // USED SUB-TREES

            var typedList       = new TypedList(p);
            var gd              = new Gd(p);
            var predicateGdBase = new PredicateGd(p, BForm.BASE);
            var numericExpr     = new NumericExpr(p);
            var valueOrTerm     = new ValueOrTerm(p);

            // RULES

            preGd.Rule     = p.ToTerm("(") + preGdBase + ")";
            preGdBase.Rule = prefPreGdBase | andPreGdBase | forallPreGdBase | orGdBase | notGdBase | implyGdBase | existsGdBase | predicateGdBase | equalsOpGdBase | numCompGdBase;

            prefPreGdBase.Rule   = p.ToTerm("preference") + prefNameOrEmpty + gd;
            prefNameOrEmpty.Rule = prefName | p.Empty;

            andPreGdBase.Rule    = p.ToTerm("and") + preGdStarList;
            forallPreGdBase.Rule = p.ToTerm("forall") + "(" + typedList + ")" + preGd;
            orGdBase.Rule        = p.ToTerm("or") + gdStarList;
            notGdBase.Rule       = p.ToTerm("not") + gd;
            implyGdBase.Rule     = p.ToTerm("imply") + gd + gd;
            existsGdBase.Rule    = p.ToTerm("exists") + "(" + typedList + ")" + gd;
            equalsOpGdBase.Rule  = p.ToTerm("=") + valueOrTerm + valueOrTerm;

            numCompGdBase.Rule  = binaryComparer + numericExpr + numericExpr;
            binaryComparer.Rule = p.ToTerm(">") | "<" | ">=" | "<=";

            preGdStarList.Rule = p.MakeStarRule(preGdStarList, preGd);
            gdStarList.Rule    = p.MakeStarRule(gdStarList, gd);

            p.MarkTransient(preGd, preGdBase, gd, numericExpr, binaryComparer);

            Rule = preGd;
        }
Пример #3
0
        /// <summary>
        /// Constructor of the grammar node.
        /// </summary>
        /// <param name="p">Parent master grammar.</param>
        public NumericExprDa(MasterGrammar p) : base(p)
        {
            var durationVar = new NonTerminal("Duration variable term (duration numeric expression)", typeof(DurationVariableTermAstNode))
            {
                Rule = p.ToTerm("?duration")
            };

            Rule = NumericExpr.ConstructNumericExprRule(p, durationVar);
        }
Пример #4
0
        /// <summary>
        /// Constructor of the grammar node.
        /// </summary>
        /// <param name="p">Parent master grammar.</param>
        public DurConstr(MasterGrammar p) : base(p)
        {
            // NON-TERMINAL AND TERMINAL SYMBOLS

            var durationConstr     = new NonTerminal("Duration-constraint", typeof(TransientAstNode));
            var durationConstrBase = new NonTerminal("Duration-constraint base", typeof(TransientAstNode));

            var simpleDurationConstr     = new NonTerminal("Simple duration-constraint", typeof(TransientAstNode));
            var simpleDurationConstrBase = new NonTerminal("Simple duration-constraint base", typeof(TransientAstNode));

            var andSimpleDurationConstrsBase  = new NonTerminal("AND expression (duration-constraints)", typeof(AndSimpleDurationConstraintsAstNode));
            var simpleDurationConstrsPlusList = new NonTerminal("Simple duration constraints plus-list", typeof(TransientAstNode));

            var atSimpleDurationConstr     = new NonTerminal("AT expression (duration-constraint)", typeof(AtSimpleDurationConstraintAstNode));
            var compOpSimpleDurationConstr = new NonTerminal("CompareOp (duration-constraint)", typeof(CompOpSimpleDurationConstraintAstNode));
            var timeSpecifier = new NonTerminal("Time specifier", typeof(TransientAstNode));

            var durCompareOp  = new NonTerminal("Compare operator for duration-constraint", typeof(TransientAstNode));
            var durCompareVal = new NonTerminal("Value for duration-constraint", typeof(TransientAstNode));

            // USED SUB-TREES

            var numericExpr = new NumericExpr(p);

            // RULES

            durationConstr.Rule     = p.ToTerm("(") + durationConstrBase + ")";
            durationConstrBase.Rule = andSimpleDurationConstrsBase | simpleDurationConstrBase;

            andSimpleDurationConstrsBase.Rule  = p.ToTerm("and") + simpleDurationConstrsPlusList;
            simpleDurationConstrsPlusList.Rule = p.MakeStarRule(simpleDurationConstrsPlusList, simpleDurationConstr);

            simpleDurationConstr.Rule     = p.ToTerm("(") + simpleDurationConstrBase + ")";
            simpleDurationConstrBase.Rule = atSimpleDurationConstr | compOpSimpleDurationConstr;

            atSimpleDurationConstr.Rule     = p.ToTerm("at") + timeSpecifier + simpleDurationConstr;
            compOpSimpleDurationConstr.Rule = durCompareOp + "?duration" + durCompareVal;
            timeSpecifier.Rule = p.ToTerm("start") | p.ToTerm("end");

            durCompareOp.Rule  = p.ToTerm("<=") | ">=" | "=";
            durCompareVal.Rule = numericExpr;

            p.MarkTransient(durationConstr, durationConstrBase, simpleDurationConstr, simpleDurationConstrBase, durCompareVal);

            Rule = durationConstr;
        }
Пример #5
0
        /// <summary>
        /// Constructor of the grammar node.
        /// </summary>
        /// <param name="p">Parent master grammar.</param>
        public Gd(MasterGrammar p) : base(p)
        {
            // NON-TERMINAL AND TERMINAL SYMBOLS

            var gd         = new NonTerminal("GD", typeof(TransientAstNode));
            var gdBase     = new NonTerminal("GD base", typeof(TransientAstNode));
            var gdStarList = new NonTerminal("GD star-list", typeof(TransientAstNode));

            var andGdBase      = new NonTerminal("AND expression (GDs)", typeof(AndGdAstNode));
            var orGdBase       = new NonTerminal("OR expression (GD)", typeof(OrGdAstNode));
            var notGdBase      = new NonTerminal("NOT expression (GD)", typeof(NotGdAstNode));
            var implyGdBase    = new NonTerminal("IMPLY expression (GD)", typeof(ImplyGdAstNode));
            var existsGdBase   = new NonTerminal("EXISTS expression (GD)", typeof(ExistsGdAstNode));
            var forallGdBase   = new NonTerminal("FORALL expression (GD)", typeof(ForallGdAstNode));
            var equalsOpGdBase = new NonTerminal("Equals operator (GD)", typeof(EqualsOpGdAstNode));
            var numCompGdBase  = new NonTerminal("Numeric comparison expression (GD)", typeof(NumCompGdAstNode));
            var binaryComparer = new NonTerminal("Binary comparer", typeof(TransientAstNode));

            // USED SUB-TREES

            var typedList       = new TypedList(p);
            var numericExpr     = new NumericExpr(p);
            var valueOrTerm     = new ValueOrTerm(p);
            var predicateGdBase = new PredicateGd(p, BForm.BASE);

            // RULES

            gd.Rule     = p.ToTerm("(") + gdBase + ")";
            gdBase.Rule = andGdBase | orGdBase | notGdBase | implyGdBase | existsGdBase | forallGdBase | predicateGdBase | equalsOpGdBase | numCompGdBase;

            andGdBase.Rule      = p.ToTerm("and") + gdStarList;
            orGdBase.Rule       = p.ToTerm("or") + gdStarList;
            notGdBase.Rule      = p.ToTerm("not") + gd;
            implyGdBase.Rule    = p.ToTerm("imply") + gd + gd;
            existsGdBase.Rule   = p.ToTerm("exists") + "(" + typedList + ")" + gd;
            forallGdBase.Rule   = p.ToTerm("forall") + "(" + typedList + ")" + gd;
            equalsOpGdBase.Rule = p.ToTerm("=") + valueOrTerm + valueOrTerm;
            numCompGdBase.Rule  = binaryComparer + numericExpr + numericExpr;
            binaryComparer.Rule = p.ToTerm(">") | "<" | ">=" | "<=";

            gdStarList.Rule = p.MakeStarRule(gdStarList, gd);

            p.MarkTransient(gd, gdBase, binaryComparer);

            Rule = gd;
        }