/// <summary> Returns an array of the literal rep of the AST /// </summary> private static IList getASTAsStringArray(Node rootNode) { /* * this assumes that we are passed in the root * node of the code block */ Token t = rootNode.FirstToken; Token tLast = rootNode.LastToken; /* * now, run down the part of the tree bounded by * our first and last tokens */ ArrayList list = new ArrayList(); t = rootNode.FirstToken; while (t != tLast) { list.Add(NodeUtils.tokenLiteral(t)); t = t.next; } /* * make sure we get the last one... */ list.Add(NodeUtils.tokenLiteral(t)); return(list); }
public override System.Object init(InternalContextAdapter context, System.Object data) { Token t = FirstToken; System.String text = NodeUtils.tokenLiteral(t); ctext = text.ToCharArray(); return(data); }
/// <summary> gets the args to the VM from the instance-use AST /// </summary> private System.String[] getArgArray(INode node) { int numArgs = node.jjtGetNumChildren(); System.String[] args = new System.String[numArgs]; callingArgTypes = new int[numArgs]; /* * eat the args */ int i = 0; Token t = null; Token tLast = null; while (i < numArgs) { args[i] = ""; /* * we want string literalss to lose the quotes. #foo( "blargh" ) should have 'blargh' patched * into macro body. So for each arg in the use-instance, treat the stringlierals specially... */ callingArgTypes[i] = node.jjtGetChild(i).Type; if (false && node.jjtGetChild(i).Type == NVelocity.Runtime.Parser.ParserTreeConstants.JJTSTRINGLITERAL) { args[i] += node.jjtGetChild(i).FirstToken.image.Substring(1, (node.jjtGetChild(i).FirstToken.image.Length - 1) - (1)); } else { /* * just wander down the token list, concatenating everything together */ t = node.jjtGetChild(i).FirstToken; tLast = node.jjtGetChild(i).LastToken; while (t != tLast) { args[i] += t.image; t = t.next; } /* * don't forget the last one... :) */ args[i] += t.image; } i++; } return(args); }
// All additional methods public virtual System.String literal() { Token t = first; System.Text.StringBuilder sb = new System.Text.StringBuilder(t.image); while (t != last) { t = t.next; sb.Append(t.image); } return(sb.ToString()); }
public virtual void jjtOpen() { first = parser.getToken(1); // added }