Exemplo n.º 1
0
        public SequenceExpression ParseSequenceExpression(String seqExprStr)
        {
            Dictionary <String, String>          predefinedVariables = new Dictionary <string, string>();
            SequenceParserEnvironmentInterpreted parserEnv           = new SequenceParserEnvironmentInterpreted(curActions);
            List <string>      warnings = new List <string>();
            SequenceExpression seqExpr  = SequenceParser.ParseSequenceExpression(seqExprStr, predefinedVariables, parserEnv, warnings);

            foreach (string warning in warnings)
            {
                System.Console.Error.WriteLine(warning);
            }
            return(seqExpr);
        }
Exemplo n.º 2
0
        private SequenceExpression DetermineCondition(SubruleDebuggingConfigurationRule cr,
                                                      SubruleDebuggingEvent sde, IAction action, GrGenType graphElementType)
        {
            // edit or keep condition if type action or graph change
            do
            {
                Console.WriteLine("Conditional rule via sequence expression?");
                if (cr != null && cr.IfClause != null)
                {
                    Console.WriteLine("Press enter to take over " + cr.IfClause.Symbol + ", enter \"-\" to clear the condition, otherwise enter the sequence expression to apply.");
                }
                else
                {
                    Console.WriteLine("Press enter if you don't want to add an if part, otherwise enter the sequence expression to apply.");
                }

                String ifClauseStr = Console.ReadLine();
                if (ifClauseStr.Length == 0)
                {
                    if (cr != null)
                    {
                        return(cr.IfClause);
                    }
                    else
                    {
                        return(null);
                    }
                }
                if (ifClauseStr == "-")
                {
                    return(null);
                }

                Dictionary <String, String> predefinedVariables = new Dictionary <String, String>();
                predefinedVariables.Add("this", "");
                string ruleOfMatchThis = null;
                if (sde == SubruleDebuggingEvent.Match)
                {
                    ruleOfMatchThis = action.Name;
                }
                string typeOfGraphElementThis = null;
                if (sde == SubruleDebuggingEvent.New || sde == SubruleDebuggingEvent.Delete ||
                    sde == SubruleDebuggingEvent.Retype || sde == SubruleDebuggingEvent.SetAttributes)
                {
                    typeOfGraphElementThis = "";
                    if (graphElementType != null)
                    {
                        typeOfGraphElementThis = graphElementType.PackagePrefixedName;
                    }
                }
                try
                {
                    SequenceParserEnvironmentInterpretedDebugEventCondition parserEnv = new SequenceParserEnvironmentInterpretedDebugEventCondition(shellProcEnv.ProcEnv.Actions, ruleOfMatchThis, typeOfGraphElementThis);
                    List <String>      warnings = new List <String>();
                    SequenceExpression ifClause = SequenceParser.ParseSequenceExpression(ifClauseStr, predefinedVariables, parserEnv, warnings);
                    foreach (string warning in warnings)
                    {
                        Console.WriteLine("The sequence expression for the if clause reported back: " + warning);
                    }
                    return(ifClause);
                }
                catch (SequenceParserException ex)
                {
                    Console.WriteLine("Unable to parse sequence expression");
                    env.HandleSequenceParserException(ex);
                }
                catch (de.unika.ipd.grGen.libGr.sequenceParser.ParseException ex)
                {
                    Console.WriteLine("Unable to parse sequence expression: " + ex.Message);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Unable to parse sequence expression : " + ex);
                }
            }while(true);
        }