protected override List <CodeLexem> Parse(SourcePart text) { var list = new List <CodeLexem>(); while (text.Length > 0) { if (TryExtract(list, ref text, "<!--", LexemType.Comment)) { TryExtractTo(list, ref text, "-->", LexemType.Comment); } if (text.StartsWith("<", StringComparison.Ordinal)) { IsInsideBlock = false; } if (TryExtract(list, ref text, "\"{}", LexemType.Value)) { TryExtractTo(list, ref text, "\"", LexemType.Value); } if (TryExtract(list, ref text, "</", LexemType.Symbol) || TryExtract(list, ref text, "<", LexemType.Symbol) || TryExtract(list, ref text, "{", LexemType.Symbol)) { ParseXmlKeyWord(list, ref text, LexemType.Object); } if (TryExtract(list, ref text, "\"", LexemType.Quotes)) { ParseValue(list, ref text); } ParseXmlKeyWord(list, ref text, IsInsideBlock ? LexemType.PlainText : LexemType.Property); TryExtract(list, ref text, "\"", LexemType.Quotes); TryExtract(list, ref text, "}", LexemType.Symbol); if (text.StartsWith(">", StringComparison.Ordinal)) { IsInsideBlock = true; } ParseSymbol(list, ref text); TrySpace(list, ref text); TryExtract(list, ref text, "\n", LexemType.LineBreak); } return(list); }
protected bool TryExtract(List<CodeLexem> res, ref SourcePart text, string lex, LexemType type) { if (text.StartsWith(lex)) { res.Add(new CodeLexem(type, CutString(ref text, lex.Length))); return true; } return false; }
protected bool TryExtract(List<CodeLexem> res, ref SourcePart text, string lex) { if (text.StartsWith(lex)) { CutString(ref text, lex.Length); return true; } return false; }
protected bool TryExtract(List <CodeLexem> res, ref SourcePart text, string lex, LexemType type) { if (text.StartsWith(lex)) { res.Add(new CodeLexem(type, CutString(ref text, lex.Length))); return(true); } return(false); }
protected bool TryExtract(List <CodeLexem> res, ref SourcePart text, string lex) { if (text.StartsWith(lex)) { CutString(ref text, lex.Length); return(true); } return(false); }
protected override List<CodeLexem> Parse(SourcePart text) { var list = new List<CodeLexem>(); while (text.Length > 0) { if (TryExtract(list, ref text, "<!--", LexemType.Comment)) TryExtractTo(list, ref text, "-->", LexemType.Comment); if (text.StartsWith("<", StringComparison.Ordinal)) IsInsideBlock = false; if (TryExtract(list, ref text, "\"{}", LexemType.Value)) TryExtractTo(list, ref text, "\"", LexemType.Value); if (TryExtract(list, ref text, "</", LexemType.Symbol) || TryExtract(list, ref text, "<", LexemType.Symbol) || TryExtract(list, ref text, "{", LexemType.Symbol)) { ParseXmlKeyWord(list, ref text, LexemType.Object); } if (TryExtract(list, ref text, "\"", LexemType.Quotes)) { ParseValue(list, ref text); } ParseXmlKeyWord(list, ref text, IsInsideBlock ? LexemType.PlainText : LexemType.Property); TryExtract(list, ref text, "\"", LexemType.Quotes); TryExtract(list, ref text, "}", LexemType.Symbol); if (text.StartsWith(">", StringComparison.Ordinal)) IsInsideBlock = true; ParseSymbol(list, ref text); TrySpace(list, ref text); TryExtract(list, ref text, "\n", LexemType.LineBreak); } return list; }