public StatementExcavator(ParserOption options, string sourceCode) { Options = options; SourceCode = sourceCode; if (Cached == null) Cached = new Dictionary<Guid, CompilerResults>(); }
public void ParserTest() { var builder = new DBBuilder(new DBConnection { Account = "gonnatour", DBType = DataBaseType.MSSQL, Name = "gonnatour", Password = "******", Server = "localhost" }); DataBase database = builder.Build(); var options = new ParserOption(); foreach (Table table in database.Tables) { options.VariableParameter = table; table.Columns = table.Columns.OrderByDescending(t => t.PrimaryKey).ThenBy(t => t.Name).ToList(); options.StatementParameters = new object[] { database, table }; options.Namesapces.Add("xCoder.DB2Project.Data"); options.References.Add("System.dll"); options.References.Add(@".\xCoder.DB2Project.dll"); options.SourceCode = new FileInfo("./testdata/test2.tpl"); var parser = new Parser(options); string temp = parser.Parse(ParserType.XCODER); Console.WriteLine(temp); } }
public override string[] Build() { var options = new ParserOption(); var currentAssembly = GetType().Assembly; var name = new FileInfo(currentAssembly.Location).Name; var namespaces = currentAssembly.GetTypes().Select(t => t.Namespace).ToArray(); options.Namesapces.AddRange(namespaces); options.References.Add("System.dll"); options.References.Add(@".\" + name); options.SourceCode = Parameters.Template; options.VariableCollection.Add("Namespace", string.IsNullOrEmpty(Parameters.Namespace) ? "" : Parameters.Namespace); var tmp = new List<string>(); foreach (Table table in Parameters.DataBase.Tables) { options.VariableParameter = table; options.StatementParameters = new object[] {Parameters.DataBase, table}; var parser = new Parser.Parser(options); string temp = parser.Parse(ParserType.XCODER); string fileName = Path.Combine(Parameters.OutputDirectory.FullName, table.Name) + Extension; File.WriteAllText(fileName, temp); tmp.Add(fileName); } return tmp.ToArray(); }
protected ParserBase(ParserOption options, string tagRegx) { Options = options; TagRegx = tagRegx; BaseRegex = new Regex(TagRegx.Replace(@"\r", string.Empty).Replace("\n", string.Empty), RegxOptions); if ((Options.SourceCode == null || !Options.SourceCode.Exists) && Options.Code == null) { throw new InvalidDataException("XCoderOptions: Code File To be parsed can not be found"); } TemplateContent = Options.Code != null ? Options.Code.ToString() : File.ReadAllText(options.SourceCode.FullName); Results = new List<string>(); }
public Parser(ParserOption options) { Options = options; }
public VariableParser(ParserOption options) : base(options, "<#(.[^#>]*[^<#]{0})#>") { }