Example #1
0
        public override string OutputXML(int level)
        {
            string output = "";

            FileFormatter.AddIndentation(ref output, level);
            output += "<" + XMLTags.ClassDefinitionNodeTag + " Name=\"" + m_name + "\"";
            if (ImplementsWorld)
            {
                output += " " + XMLTags.worldAttribute + "=\"" + m_world + "\"";
            }
            output += ">\n";

            foreach (string baseClass in m_baseClasses)
            {
                ParameterizedObject baseClassObject = CppSourceParser.GetNamedParamObject(baseClass);
                if (baseClassObject != null)
                {
                    foreach (IParameter param in baseClassObject.Parameters)
                    {
                        base.addParameter(param);//output += baseClassObject.outputChildrenXML(level + 1);
                    }
                }
                else
                {
                    Console.WriteLine("Warning." + m_name + " class extends base class " + baseClass
                                      + " but definition has not been found. Ignore if the base class is a template class without any parameters.");
                }
            }
            output += OutputChildrenXML(level + 1);
            FileFormatter.AddIndentation(ref output, level);
            output += "</" + XMLTags.ClassDefinitionNodeTag + ">\n";
            return(output);
        }
Example #2
0
        static int Main(string[] args)
        {
            //not to read 23.232 as 23232
            Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;

            if (!ParseArguments(args))
            {
                Console.WriteLine("ERROR. Usage: SimionSrcParser lang=[cpp|csharp] source-dir=<dir> [out-defs=<path-to-xml>]");
                return(0);
            }

            //Create the appropriate parser
            SimionSrcParser parser = null;

            parser = new CppSourceParser();

            foreach (string sourceDir in sourceDirectories)
            {
                parser.ParseSourceFilesInDir(sourceDir);
            }

            int numErrors = parser.PostProcess();

            if (numErrors == 0)
            {
                string inputSourceDirectories = "{ ";
                foreach (string sourceDir in sourceDirectories)
                {
                    inputSourceDirectories += sourceDir + "; ";
                }
                inputSourceDirectories += "}";

                if (outDefinitionsFile != null && parser.GetParameterizedObjects() != null)
                {
                    Console.WriteLine("Saving object definitions for Badger: " + inputSourceDirectories + " ->" + outDefinitionsFile);
                    DocumentationExporter.ExportGUIParameters(outDefinitionsFile, parser.GetParameterizedObjects());
                }

                Console.WriteLine("Finished: {0} Kbs of code read.", parser.GetNumBytesProcessed() / 1000);
            }
            return(0);
        }
Example #3
0
        public void parse(ParameterizedObject parent, string srcCode)
        {
            string sPattern = @"CHOICE\s*<\s*(\w+)\s*>\(([^,]+),([^,]+),([^,]+),([^;]*);";

            foreach (Match match in Regex.Matches(srcCode, sPattern))
            {
                string className = match.Groups[1].Value.Trim(' ', '"');
                string choiceName = match.Groups[3].Value.Trim(' ', '"');
                string comment = match.Groups[4].Value.Trim(' ', '"');
                string choiceElements, prefix;
                choiceElements = match.Groups[5].Value.Trim(' ', '"', '\t', '\n');
                CppSourceParser.GetEnclosedBody(match.Groups[5].Value.Trim(' ', '"', '\t', '\n'), 0, "{", "}", out choiceElements, out prefix);
                choiceElements = choiceElements.Trim(' ', '"', '\t', '\n');
                ChoiceParameter newChoice = new ChoiceParameter(className, choiceName, comment);

                foreach (ChoiceElementParser choiceElementParser in m_choiceElementParsers)
                {
                    choiceElementParser.parse(choiceElements, newChoice);
                }

                parent.addParameter(newChoice);
            }
        }