public void AddDef(IL.Variable var) { if (var != null) { Def.Add(var); } }
//<Program>// public Node Program() { var Def = new Def(); while (firstOfDeclaration.Contains(CurrentToken) | firstOfFunDef.Contains(CurrentToken)) { if (firstOfDeclaration.Contains(CurrentToken)) { Def.Add(VarDef()); } else { Def.Add(FunDef()); } } Expect(TokenCategory.EOF); return(new Program() { Def }); }
/// <summary>Create a Style instance by parsing html text</summary> public Style Parse(string css) { // Expects [<style>] names { key:value; ... } [</style>] foreach (var m in Regex.Matches(css, @"\s*(.*?)\s*{(.*?)}", RegexOptions.Singleline).Cast <Match>()) { var def = new Def(m.Groups[1].Value); foreach (var kv in Regex.Matches(m.Groups[2].Value, @"\s*(.+?)\s*:\s*(.*?);").Cast <Match>()) { def.Add(kv.Groups[1].Value, kv.Groups[2].Value); } Add(def); } return(this); }