Exemplo n.º 1
0
 public Grammar()
 {
     Symbols     = new Symbols();
     SkipSymbols = new Symbols();
     Directives  = new Directives();
 }
Exemplo n.º 2
0
        private void SetupDirectives()
        {
            Directive d = Directives.Find("TinyPG");

            if (d == null)
            {
                d = new Directive("TinyPG");
                Directives.Insert(0, d);
            }
            if (!d.ContainsKey("Namespace"))
            {
                d["Namespace"] = "TinyPG";                 // set default namespace
            }
            if (!d.ContainsKey("OutputPath"))
            {
                d["OutputPath"] = "." + Path.DirectorySeparatorChar;                 // write files to current path
            }
            if (!d.ContainsKey("Language"))
            {
                d["Language"] = "C#";                 // set default language
            }
            if (!d.ContainsKey("TemplatePath"))
            {
                switch (d["Language"].ToLower(CultureInfo.InvariantCulture))
                {
                // set the default templates directory
                case "visualbasic":
                case "vbnet":
                case "vb.net":
                case "vb":
                    d["TemplatePath"] = AppDomain.CurrentDomain.BaseDirectory +
                                        Path.Combine("Templates", "VB") + Path.DirectorySeparatorChar;
                    break;

                case "java":
                    d["TemplatePath"] = AppDomain.CurrentDomain.BaseDirectory +
                                        Path.Combine("Templates", "Java") + Path.DirectorySeparatorChar;
                    break;

                default:
                    d["TemplatePath"] = AppDomain.CurrentDomain.BaseDirectory +
                                        Path.Combine("Templates", "C#") + Path.DirectorySeparatorChar;
                    break;
                }
            }

            d = Directives.Find("Parser");
            if (d == null)
            {
                d = new Directive("Parser");
                Directives.Insert(1, d);
            }
            if (!d.ContainsKey("Generate"))
            {
                d["Generate"] = "True";                 // generate parser by default
            }
            if (!d.ContainsKey("CustomCode"))
            {
                d["CustomCode"] = "";                 // no custom code by default
            }
            d = Directives.Find("Scanner");
            if (d == null)
            {
                d = new Directive("Scanner");
                Directives.Insert(1, d);
            }
            if (!d.ContainsKey("Generate"))
            {
                d["Generate"] = "True";                 // generate scanner by default
            }
            if (!d.ContainsKey("CustomCode"))
            {
                d["CustomCode"] = "";                 // no custom code by default
            }
            d = Directives.Find("ParseTree");
            if (d == null)
            {
                d = new Directive("ParseTree");
                Directives.Add(d);
            }
            if (!d.ContainsKey("Generate"))
            {
                d["Generate"] = "True";                 // generate parsetree by default
            }
            if (!d.ContainsKey("CustomCode"))
            {
                d["CustomCode"] = "";                 // no custom code by default
            }
            d = Directives.Find("TextHighlighter");
            if (d == null)
            {
                d = new Directive("TextHighlighter");
                Directives.Add(d);
            }
            if (!d.ContainsKey("Generate"))
            {
                d["Generate"] = "False";                 // do NOT generate a text highlighter by default
            }
            if (!d.ContainsKey("CustomCode"))
            {
                d["CustomCode"] = "";                 // no custom code by default
            }
        }