package org.jruby.parser;
return node2 == null ? node1 : new ArgsCatNode(position, node1, node2);
if (secondNode != null) {
We know for callers of this that it cannot be any of the specials checked in gettable.
- Parameters:
node
to check its variable type- Returns:
- an AST node representing this new variable
Create AST node representing variable type it represents.
- Parameters:
token
to check its variable type- Returns:
- an AST node representing this new variable
"identifier " + identifier + " is not valid", identifier);
Wraps node with NEWLINE node.
- Parameters:
node
- Returns:
- a NewlineNode or null if node is null.
if (node == null) return null;
position = topOfAST != null ? topOfAST.getPosition() : position;
if (topOfAST != null) newTopOfAST.add(topOfAST);
if (tail == null) return head;
if (head == null) return tail;
if (defaultPosition != null) {
Define an array set condition so we can return lhs
- Parameters:
receiver
array being setindex
node which should evalute to index of array set- Returns:
- an AttrAssignNode
Define an attribute set condition so we can return lhs
- Parameters:
receiver
object which contains attributename
of the attribute being set- Returns:
- an AttrAssignNode
"Can't set variable " + varName + '.', varName);
if (lhs == null) return null;
Is the supplied node a break/control statement?
- Parameters:
node
to be checked- Returns:
- true if a control node, false otherwise
if (node == null) return false;
boolean conditional = false;
"void value expression");
"void value expression");
Is this a literal in the sense that MRI has a NODE_LIT for. This is different than
ILiteralNode. We should pick a different name since ILiteralNode is something we created
which is similiar but used for a slightly different condition (can I do singleton things).
- Parameters:
node
to be tested- Returns:
- true if it is a literal
Check to see if current node is an useless statement. If useless a warning if printed.
- Parameters:
node
to be checked.
if (node == null) return;
if (name == "+" || name == "-" || name == "*" || name == "/" || name == "%" ||
name == "**" || name == "+@" || name == "-@" || name == "|" || name == "^" ||
name == "&" || name == "<=>" || name == ">" || name == ">=" || name == "<" ||
name == "<=" || name == "==" || name == "!=") {
Check all nodes but the last one in a BlockNode for useless (void context) statements.
- Parameters:
blockNode
to be checked.
for (int i = 0; i < blockNode.size(); i++) {
Node currentNode = blockNode.get(i);
if (lastNode != currentNode ) {
Ok I admit that this is somewhat ugly. We post-process a chain of when nodes and analyze
them to re-insert them back into our new CaseNode the way we want. The grammar is being
difficult and until I go back into the depths of that this is where things are.
- Parameters:
expression
of the case node (e.g. case foo)firstWhenNode
first when (which could also be the else)- Returns:
- a new case node
} else if (current instanceof WhenNode) {
if (expressionNodes instanceof ListNode) {
for (int i = 0; i < list.size(); i++) {
cases.add(new WhenNode(position, expression, bodyNode, null));
return new WhenNode(position, expressionNodes, bodyNode, nextCase);
return new WhenNode(position, expressionNodes, bodyNode, nextCase);
if (operatorName.equals("||")) {
} else if (operatorName.equals("&&")) {
return new OpElementAsgnNode(position, receiverNode, operatorName, argsNode, valueNode);
switch (argsNode.size()) {
case '+': case '-': case '*': case '/': case '<': case '>':
} else if (name.length() == 2) {
case '<': case '>': case '=':