public static void CreateASTNodesForCmd(CommonTree ast, ASTNode cmdNode, int depth) { if (DetectNullNode(ast)) { //not sure why this happens in ANTLR: some empty CommonTree nodes //we filter them out: otherwise they just create empty //lines in the generated C# code (with linenumber=0 which is no good either) //No children = we are not cutting anything real from the AST tree anyway return; } cmdNode.Text = ast.Text; if (ast.Text != null) { bool flag = false; if (ast.Text.Contains("¤")) { if (ast.Text.StartsWith("ASTMETA" + "¤")) //Handles SERIES, that is ASTGENR/ASTUPD { flag = true; } else if (ast.Text.StartsWith("ASTSHOW" + "¤")) { flag = true; } else if (ast.Text.StartsWith("ASTPRTELEMENT" + "¤")) { flag = true; } else if (ast.Text.StartsWith("ASTOLSELEMENT" + "¤")) { flag = true; } else if (ast.Text.StartsWith("ASTDECOMP" + "¤")) { flag = true; } else if (ast.Text.StartsWith("ASTLIST" + "¤")) { flag = true; } } if (flag) { string[] ss = ast.Text.Split('¤'); for (int i = 0; i < ss.Length; i++) { ss[i] = G.ReplaceGlueNew(ss[i]); } cmdNode.Text = ss[0]; cmdNode.specialExpressionAndLabelInfo = ss; } } if (cmdNode.Text != null) { if (Globals.addGlue) { cmdNode.Text = G.ReplaceGlueNew(cmdNode.Text); } } cmdNode.Line = ast.Line; if (ast.Children == null) { return; } int num = ast.Children.Count; cmdNode.CreateChildren(num); for (int i = 0; i < num; ++i) { CommonTree d = (CommonTree)(ast.Children[i]); if (DetectNullNode(d)) { continue; } ASTNode cmdNodeChild = new ASTNode(null); //unknown text cmdNodeChild.Parent = cmdNode; cmdNode.Add(cmdNodeChild); CreateASTNodesForCmd(d, cmdNodeChild, depth + 1); } }