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  ParserConfiguration configuration
           
protected  StaticScope currentScope
           
protected  RubyYaccLexer lexer
           
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_append(Node node1, Node node2)
           
 Node arg_blk_pass(Node firstNode, BlockPassNode secondNode)
           
 Node arg_concat(ISourcePosition position, Node node1, Node node2)
           
 ArgumentNode arg_var(Token identifier)
           
 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)
           
 boolean checkExpression(Node node)
           
protected  void checkRegexpSyntax(org.jruby.util.ByteList value, RegexpOptions options)
           
 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.
 DStrNode createDStrNode(ISourcePosition position)
           
 ISourcePosition createEmptyArgsNodePosition(ISourcePosition pos)
           
 Token formal_argument(Token identifier)
           
 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)
           
 ISourcePosition getPosition(ISourcePositionHolder start)
           
 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 is_local_id(Token identifier)
           
 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.
 ListNode list_append(Node list, Node item)
           
 ListNode list_concat(Node first, Node second)
           
 Node literal_concat(ISourcePosition position, Node head, Node tail)
           
protected  Node makeNullNil(Node node)
           
 FloatNode negateFloat(FloatNode floatNode)
           
 Node negateInteger(Node integerNode)
           
 Node new_aref(Node receiver, Token name, Node argsNode)
           
 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_bv(Token identifier)
           
 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)
           
 IterNode new_iter(ISourcePosition position, Node vars, StaticScope scope, Node body)
           
 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)
           
 Node newAlias(ISourcePosition position, Node newNode, Node oldNode)
           
 AndNode newAndNode(ISourcePosition position, Node left, Node right)
           
 ArrayNode newArrayNode(ISourcePosition position, Node firstNode)
           
 BlockArgNode newBlockArg(ISourcePosition position, Token nameToken)
           
 BlockArg18Node newBlockArg18(ISourcePosition position, Node blockValue, Node args)
           
 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)
           
 Node newRegexpNode(ISourcePosition position, Node contents, RegexpNode end)
           
 SplatNode newSplatNode(ISourcePosition position, Node node)
           
 SValueNode newSValueNode(ISourcePosition position, Node node)
           
 Node newUndef(ISourcePosition position, Node nameNode)
           
 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 regexpFragmentCheck(RegexpNode end, org.jruby.util.ByteList value)
           
 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 setLexer(RubyYaccLexer lexer)
           
 void setResult(RubyParserResult result)
          Sets the result.
 void setWarnings(IRubyWarnings warnings)
           
 Token shadowing_lvar(Token identifier)
           
 Node splat_array(Node node)
          If node is a splat and it is splatting a literal array then return the literal array.
 Node unwrapNewlineNode(Node node)
           
 void warn(IRubyWarnings.ID id, ISourcePosition position, java.lang.String message, java.lang.Object... data)
           
 void warning(IRubyWarnings.ID id, ISourcePosition position, java.lang.String message, java.lang.Object... data)
           
 void warningUnlessEOption(IRubyWarnings.ID id, Node node, java.lang.String message)
           
 void warnUnlessEOption(IRubyWarnings.ID id, Node node, java.lang.String message)
           
 void yyerror(java.lang.String message)
          generate parsing error
 void yyerror(java.lang.String message, java.lang.String[] expected, java.lang.String found)
          generate parsing error
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentScope

protected StaticScope currentScope

lexer

protected RubyYaccLexer lexer

warnings

protected IRubyWarnings warnings

configuration

protected ParserConfiguration configuration
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 boolean checkExpression(Node node)

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)

newSValueNode

public SValueNode newSValueNode(ISourcePosition position,
                                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_aref

public Node new_aref(Node receiver,
                     Token name,
                     Node argsNode)

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)

setLexer

public void setLexer(RubyYaccLexer lexer)

createDStrNode

public DStrNode createDStrNode(ISourcePosition position)

literal_concat

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

newEvStrNode

public Node newEvStrNode(ISourcePosition position,
                         Node node)

new_iter

public IterNode new_iter(ISourcePosition position,
                         Node vars,
                         StaticScope scope,
                         Node body)

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)

new_args

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

newAlias

public Node newAlias(ISourcePosition position,
                     Node newNode,
                     Node oldNode)

newUndef

public Node newUndef(ISourcePosition position,
                     Node nameNode)

newBlockArg18

public BlockArg18Node newBlockArg18(ISourcePosition position,
                                    Node blockValue,
                                    Node args)

newBlockArg

public BlockArgNode newBlockArg(ISourcePosition position,
                                Token nameToken)

yyerror

public void yyerror(java.lang.String message)
generate parsing error


yyerror

public void yyerror(java.lang.String message,
                    java.lang.String[] expected,
                    java.lang.String found)
generate parsing error

Parameters:
message - text to be displayed.
expected - list of acceptable tokens, if available.

getPosition

public ISourcePosition getPosition(ISourcePositionHolder start)

warn

public void warn(IRubyWarnings.ID id,
                 ISourcePosition position,
                 java.lang.String message,
                 java.lang.Object... data)

warning

public void warning(IRubyWarnings.ID id,
                    ISourcePosition position,
                    java.lang.String message,
                    java.lang.Object... data)

is_local_id

public boolean is_local_id(Token identifier)

list_append

public ListNode list_append(Node list,
                            Node item)

new_bv

public Node new_bv(Token identifier)

arg_var

public ArgumentNode arg_var(Token identifier)

formal_argument

public Token formal_argument(Token identifier)

shadowing_lvar

public Token shadowing_lvar(Token identifier)

list_concat

public ListNode list_concat(Node first,
                            Node second)

splat_array

public Node splat_array(Node node)
If node is a splat and it is splatting a literal array then return the literal array. Otherwise return null. This allows grammar to not splat into a Ruby Array if splatting a literal array.


arg_append

public Node arg_append(Node node1,
                       Node node2)

regexpFragmentCheck

public void regexpFragmentCheck(RegexpNode end,
                                org.jruby.util.ByteList value)

checkRegexpSyntax

protected void checkRegexpSyntax(org.jruby.util.ByteList value,
                                 RegexpOptions options)

newRegexpNode

public Node newRegexpNode(ISourcePosition position,
                          Node contents,
                          RegexpNode end)


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