/// <summary>
        /// Constructs the sequence generator
        /// </summary>
        public LGSPSequenceGenerator(LGSPGrGen gen, IGraphModel model,
            Dictionary<String, List<IFilter>> rulesToFilters, Dictionary<String, List<String>> filterFunctionsToInputTypes,
            Dictionary<String, List<String>> rulesToInputTypes, Dictionary<String, List<String>> rulesToOutputTypes,
            Dictionary<String, List<String>> rulesToTopLevelEntities, Dictionary<String, List<String>> rulesToTopLevelEntityTypes, 
            Dictionary<String, List<String>> sequencesToInputTypes, Dictionary<String, List<String>> sequencesToOutputTypes,
            Dictionary<String, List<String>> proceduresToInputTypes, Dictionary<String, List<String>> proceduresToOutputTypes, Dictionary<String, bool> proceduresToIsExternal,
            Dictionary<String, List<String>> functionsToInputTypes, Dictionary<String, String> functionsToOutputType, Dictionary<String, bool> functionsToIsExternal)
        {
            this.gen = gen;
            this.model = model;
            this.rulesToFilters = rulesToFilters;
            this.filterFunctionsToInputTypes = filterFunctionsToInputTypes;
            this.rulesToInputTypes = rulesToInputTypes;
            this.rulesToOutputTypes = rulesToOutputTypes;
            this.rulesToTopLevelEntities = rulesToTopLevelEntities;
            this.rulesToTopLevelEntityTypes = rulesToTopLevelEntityTypes;
            this.sequencesToInputTypes = sequencesToInputTypes;
            this.sequencesToOutputTypes = sequencesToOutputTypes;
            this.proceduresToInputTypes = proceduresToInputTypes;
            this.proceduresToOutputTypes = proceduresToOutputTypes;
            this.proceduresToIsExternal = proceduresToIsExternal;
            this.functionsToInputTypes = functionsToInputTypes;
            this.functionsToOutputType = functionsToOutputType;
            this.functionsToIsExternal = functionsToIsExternal;

            // extract rule names from domain of rule names to input types map
            ruleNames = new String[rulesToInputTypes.Count];
            int i = 0;
            foreach(KeyValuePair<String, List<String>> ruleToInputTypes in rulesToInputTypes)
            {
                ruleNames[i] = ruleToInputTypes.Key;
                ++i;
         
            }
            // extract sequence names from domain of sequence names to input types map
            sequenceNames = new String[sequencesToInputTypes.Count];
            i = 0;
            foreach(KeyValuePair<String, List<String>> sequenceToInputTypes in sequencesToInputTypes)
            {
                sequenceNames[i] = sequenceToInputTypes.Key;
                ++i;
            }
            // extract procedure names from domain of procedure names to input types map
            procedureNames = new String[proceduresToInputTypes.Count];
            i = 0;
            foreach(KeyValuePair<String, List<String>> procedureToInputTypes in proceduresToInputTypes)
            {
                procedureNames[i] = procedureToInputTypes.Key;
                ++i;
            }
            // extract function names from domain of function names to input types map
            functionNames = new String[functionsToInputTypes.Count];
            i = 0;
            foreach(KeyValuePair<String, List<String>> functionToInputTypes in functionsToInputTypes)
            {
                functionNames[i] = functionToInputTypes.Key;
                ++i;
            }
            // extract function output types from range of function names to output types map
            functionOutputTypes = new String[functionsToOutputType.Count];
            i = 0;
            foreach(KeyValuePair<String, String> functionToOutputType in functionsToOutputType)
            {
                functionOutputTypes[i] = functionToOutputType.Value;
                ++i;
            }
            // extract filter function names from domain of filter functions to input types
            filterFunctionNames = new String[filterFunctionsToInputTypes.Count];
            i = 0;
            foreach(KeyValuePair<String, List<String>> filterFunctionToInputType in filterFunctionsToInputTypes)
            {
                filterFunctionNames[i] = filterFunctionToInputType.Key;
                ++i;
            }

            // create the environment for (type) checking the compiled sequences after parsing
            env = new SequenceCheckingEnvironmentCompiled(
                ruleNames, sequenceNames, procedureNames, functionNames,
                rulesToFilters, filterFunctionsToInputTypes,
                rulesToInputTypes, rulesToOutputTypes, 
                rulesToTopLevelEntities, rulesToTopLevelEntityTypes,
                sequencesToInputTypes, sequencesToOutputTypes,
                proceduresToInputTypes, proceduresToOutputTypes, proceduresToIsExternal,
                functionsToInputTypes, functionsToOutputType, functionsToIsExternal,
                model);
        }
示例#2
0
 /// <summary>
 /// Processes the given rule specification file and generates a model and actions library.
 /// </summary>
 /// <param name="specPath">The path to the rule specification file (.grg).</param>
 /// <param name="destDir">The directory, where the generated libraries are to be placed.</param>
 /// <param name="intermediateDir">A directory, where intermediate files can be placed.</param>
 /// <param name="statisticsPath">Optional path to a file containing the graph statistics to be used for building the matchers.</param>
 /// <param name="flags">Specifies how the specification is to be processed.</param>
 /// <param name="externalAssemblies">External assemblies to reference</param>
 /// <exception cref="System.Exception">Thrown, when an error occurred.</exception>
 public static void ProcessSpecification(String specPath, String destDir, String intermediateDir, String statisticsPath, ProcessSpecFlags flags, params String[] externalAssemblies)
 {
     ErrorType ret;
     try
     {
         ret = new LGSPGrGen(flags).ProcessSpecificationImpl(specPath, destDir, intermediateDir, statisticsPath, externalAssemblies);
     }
     catch(Exception ex)
     {
         Console.WriteLine(ex);
         throw ex;
     }
     if(ret != ErrorType.NoError)
     {
         if(ret == ErrorType.GrGenJavaError && File.Exists(intermediateDir + Path.DirectorySeparatorChar + "printOutput.txt"))
         {
             using(StreamReader sr = new StreamReader(intermediateDir + Path.DirectorySeparatorChar + "printOutput.txt"))
             {
                 String output = sr.ReadToEnd();
                 if(output.Length != 0)
                     throw new Exception("\nError while processing specification:\n" + output);
             }
         }
         throw new Exception("Error while processing specification!");
     }
 }