public object TryParse(string query) { if (query.Length > SuffixString.Length && query.EndsWith(SuffixString)) { var remainderString = query.Substring(0, query.Length - SuffixString.Length); var parsedRemainder = StructureParser.Parse(remainderString); return(new Suffix(SuffixString, remainderString, parsedRemainder)); } return(null); }
public CompileError Parse() { CompileError error; StartMeasureTime(); Source.ProceedModuleNames(IncludeDirectories); var source = Source.GetSource(out error); if (error != null) { return(error); } EndMeasureTime(ElapsedTimeType.SourceReading); List <Token> tokens; try { StartMeasureTime(); tokens = Tokenizer.Tokenize(source, Source.FileName, this); if (Verbose) { Console.WriteLine(string.Join("\n", tokens)); } EndMeasureTime(ElapsedTimeType.Tokenizing); } catch (CompileException ex) { return(ex.ToError()); } StartMeasureTime(); Lexemes = Lexemizer.Lexemize(tokens, out error, Verbose, PrototypesOnly); EndMeasureTime(ElapsedTimeType.Lexemizing); if (error != null) { return(error); } StartMeasureTime(); if ((error = StructureParser.Parse(this, PrototypesOnly)) != null) { return(error); } EndMeasureTime(ElapsedTimeType.StructureParsing); return(null); }
private void button1_Click(object sender, EventArgs e) { StructureParser parser = new StructureParser(this.richTextBox1.Text); StructureTree root = parser.Parse(); MetaModel metamodel = root.Build(); MetaTemplateConverter converter = new MetaTemplateConverter(); TemplateContainer container = converter.Convert(metamodel); string template = "Domains:\n========\n[%foreach(domain in Domains)%]\n Id: [%domain.Id%]\n Name: [%domain.Name%]\n IsIdentity: [%domain.IsIdentity%]\n DataType: [%domain.DataType%]\n Length: [%domain.DataTypeLength%]\n Decimals: [%domain.DataTypeDecimals%]\n[%end%]\n"; template += "Tables:\n=======\n[%foreach(table in Tables)%]\n Id: [%table.Id%]\n Name: [%table.Name%]\n LogicalName: [%table.LogicalName%]\n PhysicalName: [%table.PhysicalName%]\n [\n[%foreach(column in table.Columns)%] TableId: [%column.TableId%]\n Ix: [%column.Ix%]\n Name: [%column.Name%]\n LogicalName: [%column.LogicalName%]\n PhysicalName: [%column.PhysicalName%]\n IsPrimaryKey: [%column.IsPrimaryKey%]\n IsNullable: [%column.IsNullable%]\n IsIdentity: [%column.IsIdentity%]\n DataType: [%column.DataType%]\n Length: [%column.DataTypeLength%]\n Decimals: [%column.DataTypeDecimals%]\n IsForeignKey: [%column.IsForeignKey%]\n [%end%]\n][%end%]\n"; template = TemplateTransformer.Transform(template); template = JavascriptEvaluator.ReplaceString(template, container); this.richTextBox2.Text = template; }
public object TryParse(string query) { var trimmed = query.Trim(); int openParen = trimmed.IndexOf('('); int closeParen = trimmed.LastIndexOf(')'); if (openParen > 0 && closeParen == trimmed.Length - 1) { var argumentListString = trimmed.Substring(openParen + 1, closeParen - openParen - 1); var argumentListParsed = StructureParser.Parse(argumentListString); var prefix = trimmed.Substring(0, openParen).TrimEnd(); return(new Invocation(prefix, argumentListString, argumentListParsed)); } return(null); }
public object TryParse(string query) { var index = query.IndexOf(OperatorText); if (index < 1 || index == query.Length - OperatorText.Length) { return(null); } LeftString = query.Substring(0, index); RightString = query.Substring(index + OperatorText.Length, query.Length - index - OperatorText.Length); var left = StructureParser.Parse(LeftString); var right = StructureParser.Parse(RightString); if (left != null && right != null) { return(new InfixOperator(LeftString, left, OperatorText, RightString, right)); } return(null); }
public void foo(string s) { var parser = new StructureParser(); var result = parser.Parse(new TextParser(0, s)); }