org.jruby.parser
Class ParserSupport

java.lang.Object
  extended by org.jruby.parser.ParserSupport
Direct Known Subclasses:
ParserSupport19

public class ParserSupport
extends java.lang.Object


Field Summary
protected  StaticScope currentScope
           
protected  IRubyWarnings warnings
           
 
Constructor Summary
ParserSupport()
           
 
Method Summary
 Node addRootNode(Node topOfAST, ISourcePosition position)
           
 void allowDubyExtension(ISourcePosition position)
           
 Node appendToBlock(Node head, Node tail)
           
 Node arg_add(ISourcePosition position, Node node1, Node node2)
           
 Node arg_blk_pass(Node firstNode, BlockPassNode secondNode)
           
 Node arg_concat(ISourcePosition position, Node node1, Node node2)
           
 Node aryset(Node receiver, Node index)
          Define an array set condition so we can return lhs
 AssignableNode assignable(Token lhs, Node value)
           
 Node attrset(Node receiver, java.lang.String name)
          Define an attribute set condition so we can return lhs
 void backrefAssignError(Node node)
           
 void checkExpression(Node node)
          Does this node represent an expression?
 void checkUselessStatement(Node node)
          Check to see if current node is an useless statement.
 void checkUselessStatements(BlockNode blockNode)
          Check all nodes but the last one in a BlockNode for useless (void context) statements.
 ISourcePosition createEmptyArgsNodePosition(ISourcePosition pos)
           
 Node getConditionNode(Node node)
           
 ParserConfiguration getConfiguration()
           
 StaticScope getCurrentScope()
           
 int getInSingle()
          Getter for property inSingle.
 Node getMatchNode(Node firstNode, Node secondNode)
           
 Node getOperatorCallNode(Node firstNode, java.lang.String operator)
           
 Node getOperatorCallNode(Node firstNode, java.lang.String operator, Node secondNode)
           
 Node getOperatorCallNode(Node firstNode, java.lang.String operator, Node secondNode, ISourcePosition defaultPosition)
           
 ArgumentNode getRestArgNode(Token token)
           
 RubyParserResult getResult()
          Gets the result.
 Node getReturnArgsNode(Node node)
           
 Node gettable(Token token)
          Create AST node representing variable type it represents.
 Node gettable2(Node node)
          We know for callers of this that it cannot be any of the specials checked in gettable.
protected  void getterIdentifierError(ISourcePosition position, java.lang.String identifier)
           
 void initTopLocalVariables()
          Description of the RubyMethod
 boolean isBreakStatement(Node node)
          Is the supplied node a break/control statement?
 boolean isInDef()
           
 boolean isInSingle()
          Getter for property inSingle.
 boolean isLiteral(Node node)
          Is this a literal in the sense that MRI has a NODE_LIT for.
 Node literal_concat(ISourcePosition position, Node head, Node tail)
           
protected  Node makeNullNil(Node node)
           
 FloatNode negateFloat(FloatNode floatNode)
           
 Node negateInteger(Node integerNode)
           
 Node new_args(ISourcePosition position, ListNode pre, ListNode optional, RestArgNode rest, ListNode post, BlockArgNode block)
           
 Node new_attrassign(ISourcePosition position, Node receiver, java.lang.String name, Node args)
           
 Node new_call(Node receiver, Token name, Node argsNode, Node iter)
           
 Colon2Node new_colon2(ISourcePosition position, Node leftNode, java.lang.String name)
           
 Colon3Node new_colon3(ISourcePosition position, java.lang.String name)
           
 Node new_fcall(Token operation, Node args, Node iter)
           
 Node new_opElementAsgnNode(ISourcePosition position, Node receiverNode, java.lang.String operatorName, Node argsNode, Node valueNode)
           
 Node new_super(Node args, Token operation)
           
 Node new_yield(ISourcePosition position, Node node)
           
 AndNode newAndNode(ISourcePosition position, Node left, Node right)
           
 ArrayNode newArrayNode(ISourcePosition position, Node firstNode)
           
 CaseNode newCaseNode(ISourcePosition position, Node expression, Node firstWhenNode)
          Ok I admit that this is somewhat ugly.
 Node newEvStrNode(ISourcePosition position, Node node)
           
 Node newline_node(Node node, ISourcePosition position)
          Wraps node with NEWLINE node.
 OrNode newOrNode(ISourcePosition position, Node left, Node right)
           
 SplatNode newSplatNode(ISourcePosition position, Node node)
           
 WhenNode newWhenNode(ISourcePosition position, Node expressionNodes, Node bodyNode, Node nextCase)
           
 Node node_assign(Node lhs, Node rhs)
           
 void popCurrentScope()
           
 ISourcePosition position(ISourcePositionHolder one, ISourcePositionHolder two)
           
 void pushBlockScope()
           
 void pushLocalScope()
           
 void reset()
           
 Node ret_args(Node node, ISourcePosition position)
           
 void setConfiguration(ParserConfiguration configuration)
          Sets the configuration.
 void setInDef(boolean inDef)
           
 void setInSingle(int inSingle)
          Setter for property inSingle.
 void setResult(RubyParserResult result)
          Sets the result.
 void setWarnings(IRubyWarnings warnings)
           
 Node unwrapNewlineNode(Node node)
           
 void warningUnlessEOption(IRubyWarnings.ID id, Node node, java.lang.String message)
           
 void warnUnlessEOption(IRubyWarnings.ID id, Node node, java.lang.String message)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentScope

protected StaticScope currentScope

warnings

protected IRubyWarnings warnings
Constructor Detail

ParserSupport

public ParserSupport()
Method Detail

reset

public void reset()

allowDubyExtension

public void allowDubyExtension(ISourcePosition position)

getCurrentScope

public StaticScope getCurrentScope()

getConfiguration

public ParserConfiguration getConfiguration()

popCurrentScope

public void popCurrentScope()

pushBlockScope

public void pushBlockScope()

pushLocalScope

public void pushLocalScope()

arg_concat

public Node arg_concat(ISourcePosition position,
                       Node node1,
                       Node node2)

arg_blk_pass

public Node arg_blk_pass(Node firstNode,
                         BlockPassNode secondNode)

gettable2

public Node gettable2(Node node)
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

gettable

public Node gettable(Token token)
Create AST node representing variable type it represents.

Parameters:
token - to check its variable type
Returns:
an AST node representing this new variable

getterIdentifierError

protected void getterIdentifierError(ISourcePosition position,
                                     java.lang.String identifier)

assignable

public AssignableNode assignable(Token lhs,
                                 Node value)

newline_node

public Node newline_node(Node node,
                         ISourcePosition position)
Wraps node with NEWLINE node.

Parameters:
node -
Returns:
a NewlineNode or null if node is null.

addRootNode

public Node addRootNode(Node topOfAST,
                        ISourcePosition position)

appendToBlock

public Node appendToBlock(Node head,
                          Node tail)

getOperatorCallNode

public Node getOperatorCallNode(Node firstNode,
                                java.lang.String operator)

getOperatorCallNode

public Node getOperatorCallNode(Node firstNode,
                                java.lang.String operator,
                                Node secondNode)

getOperatorCallNode

public Node getOperatorCallNode(Node firstNode,
                                java.lang.String operator,
                                Node secondNode,
                                ISourcePosition defaultPosition)

getMatchNode

public Node getMatchNode(Node firstNode,
                         Node secondNode)

aryset

public Node aryset(Node receiver,
                   Node index)
Define an array set condition so we can return lhs

Parameters:
receiver - array being set
index - node which should evalute to index of array set
Returns:
an AttrAssignNode

attrset

public Node attrset(Node receiver,
                    java.lang.String name)
Define an attribute set condition so we can return lhs

Parameters:
receiver - object which contains attribute
name - of the attribute being set
Returns:
an AttrAssignNode

backrefAssignError

public void backrefAssignError(Node node)

arg_add

public Node arg_add(ISourcePosition position,
                    Node node1,
                    Node node2)

node_assign

public Node node_assign(Node lhs,
                        Node rhs)

ret_args

public Node ret_args(Node node,
                     ISourcePosition position)

isBreakStatement

public boolean isBreakStatement(Node node)
Is the supplied node a break/control statement?

Parameters:
node - to be checked
Returns:
true if a control node, false otherwise

warnUnlessEOption

public void warnUnlessEOption(IRubyWarnings.ID id,
                              Node node,
                              java.lang.String message)

warningUnlessEOption

public void warningUnlessEOption(IRubyWarnings.ID id,
                                 Node node,
                                 java.lang.String message)

checkExpression

public void checkExpression(Node node)
Does this node represent an expression?

Parameters:
node - to be checked

isLiteral

public boolean isLiteral(Node node)
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

checkUselessStatement

public void checkUselessStatement(Node node)
Check to see if current node is an useless statement. If useless a warning if printed.

Parameters:
node - to be checked.

checkUselessStatements

public void checkUselessStatements(BlockNode blockNode)
Check all nodes but the last one in a BlockNode for useless (void context) statements.

Parameters:
blockNode - to be checked.

makeNullNil

protected Node makeNullNil(Node node)

getConditionNode

public Node getConditionNode(Node node)

newSplatNode

public SplatNode newSplatNode(ISourcePosition position,
                              Node node)

newArrayNode

public ArrayNode newArrayNode(ISourcePosition position,
                              Node firstNode)

position

public ISourcePosition position(ISourcePositionHolder one,
                                ISourcePositionHolder two)

newAndNode

public AndNode newAndNode(ISourcePosition position,
                          Node left,
                          Node right)

newOrNode

public OrNode newOrNode(ISourcePosition position,
                        Node left,
                        Node right)

newCaseNode

public CaseNode newCaseNode(ISourcePosition position,
                            Node expression,
                            Node firstWhenNode)
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

newWhenNode

public WhenNode newWhenNode(ISourcePosition position,
                            Node expressionNodes,
                            Node bodyNode,
                            Node nextCase)

getReturnArgsNode

public Node getReturnArgsNode(Node node)

new_opElementAsgnNode

public Node new_opElementAsgnNode(ISourcePosition position,
                                  Node receiverNode,
                                  java.lang.String operatorName,
                                  Node argsNode,
                                  Node valueNode)

new_attrassign

public Node new_attrassign(ISourcePosition position,
                           Node receiver,
                           java.lang.String name,
                           Node args)

new_call

public Node new_call(Node receiver,
                     Token name,
                     Node argsNode,
                     Node iter)

new_colon2

public Colon2Node new_colon2(ISourcePosition position,
                             Node leftNode,
                             java.lang.String name)

new_colon3

public Colon3Node new_colon3(ISourcePosition position,
                             java.lang.String name)

new_fcall

public Node new_fcall(Token operation,
                      Node args,
                      Node iter)

new_super

public Node new_super(Node args,
                      Token operation)

initTopLocalVariables

public void initTopLocalVariables()
Description of the RubyMethod


isInSingle

public boolean isInSingle()
Getter for property inSingle.

Returns:
Value of property inSingle.

setInSingle

public void setInSingle(int inSingle)
Setter for property inSingle.

Parameters:
inSingle - New value of property inSingle.

isInDef

public boolean isInDef()

setInDef

public void setInDef(boolean inDef)

getInSingle

public int getInSingle()
Getter for property inSingle.

Returns:
Value of property inSingle.

getResult

public RubyParserResult getResult()
Gets the result.

Returns:
Returns a RubyParserResult

setResult

public void setResult(RubyParserResult result)
Sets the result.

Parameters:
result - The result to set

setConfiguration

public void setConfiguration(ParserConfiguration configuration)
Sets the configuration.

Parameters:
configuration - The configuration to set

setWarnings

public void setWarnings(IRubyWarnings warnings)

literal_concat

public Node literal_concat(ISourcePosition position,
                           Node head,
                           Node tail)

newEvStrNode

public Node newEvStrNode(ISourcePosition position,
                         Node node)

new_yield

public Node new_yield(ISourcePosition position,
                      Node node)

negateInteger

public Node negateInteger(Node integerNode)

negateFloat

public FloatNode negateFloat(FloatNode floatNode)

createEmptyArgsNodePosition

public ISourcePosition createEmptyArgsNodePosition(ISourcePosition pos)

unwrapNewlineNode

public Node unwrapNewlineNode(Node node)

getRestArgNode

public ArgumentNode getRestArgNode(Token token)

new_args

public Node new_args(ISourcePosition position,
                     ListNode pre,
                     ListNode optional,
                     RestArgNode rest,
                     ListNode post,
                     BlockArgNode block)


Copyright © 2002-2007 JRuby Team. All Rights Reserved.