public List <Glyph> ProcessGlyph(Glyph g, List <Glyph> glyphs) { var result = new List <Glyph>(); var gstr = g.Value; foreach (var glyph in glyphs) { if (glyph.GetType() == typeof(Glyph)) { var content = glyph.Value; var items = content.Split(new string[] { gstr }, StringSplitOptions.None); for (int i = 0; i < items.Length; i++) { var itemglyph = GlyphFactory.Create <Glyph>(items[i]); AddGlyph(itemglyph, result); if (i < items.Length - 1) { result.Add(g); } } } else { result.Add(glyph); } } return(result); }
public List <Glyph> ProcessSeparators(List <Glyph> glyphs) { List <Glyph> result = glyphs; var s_enum = GlyphFactory.Create <Separator>(Syntax.Separators, "Enumeration"); var s_logic = GlyphFactory.Create <Separator>(Syntax.Separators, "Logical"); result = ProcessGlyph(s_enum, result); result = ProcessGlyph(s_logic, result); return(result); }
public List <Glyph> ProcessLiterals(List <Glyph> glyphs) { List <Glyph> result = glyphs; var sep = GlyphFactory.Create <Separator>(Syntax.Separators["Literal"]); result = ProcessLiteral(sep, result); sep = GlyphFactory.Create <Separator>(Syntax.Separators["Literal2"]); result = ProcessLiteral(sep, result); return(result); }
public List <Glyph> ProcessOperators(List <Glyph> glyphs) { List <Glyph> result = glyphs; foreach (var kv in Syntax.Operators) { var glyph = GlyphFactory.Create <Operator>(Syntax.Operators, kv.Key); result = ProcessGlyph(glyph, result); } return(result); }
public List <Glyph> ProcessKeywords(List <Glyph> glyphs) { List <Glyph> result = glyphs; foreach (var kv in Syntax.Keywords) { var glyph = GlyphFactory.Create <KeyWord>(Syntax.Keywords, kv.Key); result = ProcessGlyph(glyph, result); } return(result); }
public List <Glyph> ProcessSymbols(List <Glyph> glyphs) { var result = new List <Glyph>(); foreach (var glyph in glyphs) { if (glyph.Value.StartsWith("$") && glyph.GetType() != typeof(Literal)) { var symbol = GlyphFactory.Create <Symbol>(glyph.Value); result.Add(symbol); } else { result.Add(glyph); } } return(result); }
public List <Glyph> ProcessLiteral(Separator sep, List <Glyph> glyphs) { var result = new List <Glyph>(); var separator = sep.Value; foreach (var glyph in glyphs) { if (glyph.GetType() == typeof(Glyph)) { var content = glyph.Value; //TODO handle escaped separators var x1 = 0; var literals = Utilities.Strings.TextsBetween(content, separator, separator); var six = 0; foreach (var literal in literals) { var fp = separator + literal + separator; var ix = content.IndexOf(fp, six); var l = ix - six; var gstr = content.Substring(six, l); if (!String.IsNullOrEmpty(gstr)) { result.Add(new Glyph(gstr)); } result.Add(GlyphFactory.Create <Literal>(literal)); six = ix + fp.Length; } if (content.Length - six > 0) { var gstr = content.Substring(six); result.Add(new Glyph(gstr)); } } else { result.Add(glyph); } } return(result); }
public List <Glyph> ProcessFunctions(List <Glyph> glyphs) { List <Glyph> result = glyphs; var enumeration_left = Syntax.Boundaries["Enumeration"].Left; for (int i = 1; i < glyphs.Count; i++) { var glyph = glyphs[i]; if (glyph.GetType() == typeof(BoundarySeparator)) { if (glyph.Value == enumeration_left) { var prevglyph = glyphs[i - 1]; if (prevglyph.GetType() == typeof(Glyph) && !String.IsNullOrEmpty(prevglyph.Value)) { glyphs[i - 1] = GlyphFactory.Create <FunctionName>(prevglyph.Value); } } } } return(result); }