org.jrubyparser.parser
Class ParserSupport

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

public class ParserSupport
extends Object


Field Summary
protected  StaticScope currentScope
           
protected  Lexer lexer
           
protected  IRubyWarnings warnings
           
 
Constructor Summary
ParserSupport()
           
 
Method Summary
 Node addRootNode(Node topOfAST, SourcePosition position)
           
 Node appendToBlock(Node head, Node tail)
           
 Node arg_add(SourcePosition position, Node node1, Node node2)
           
 Node arg_append(Node node1, Node node2)
           
 Node arg_blk_pass(Node firstNode, BlockPassNode secondNode)
           
 Node arg_concat(SourcePosition 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 asSymbol(SourcePosition position, Node value)
           
 Node attrset(Node receiver, String name)
          Define an attribute set condition so we can return lhs
 void backrefAssignError(Node node)
           
 boolean checkExpression(Node node)
          Does this node represent an expression?
protected  void checkRegexpSyntax(String 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.
 SourcePosition createEmptyArgsNodePosition(SourcePosition 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, String operator, Node secondNode)
           
 Node getOperatorCallNode(Node firstNode, String operator, Node secondNode, SourcePosition defaultPosition)
           
 Node getOperatorCallNode(SourcePosition position, Node firstNode, String operator)
           
 Node getOperatorCallNode(Token operator, Node receiver)
           
 SourcePosition getPosition(ISourcePositionHolder start)
           
 SourcePosition getPosition(ISourcePositionHolder start, boolean inclusive)
           
 SourcePosition getPosition2(ISourcePositionHolder pos)
          Since we can recieve positions at times we know can be null we need an extra safety net here.
 ParserResult 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(SourcePosition position, String identifier)
           
 Node getUnaryCallNode(Node receiver, Token operator)
           
 void initTopLocalVariables()
          Description of the RubyMethod
 boolean is_local_id(Token identifier)
           
 boolean isBreakStatement(Node node)
          Is the supplied node a break/control statement?
static boolean isConstant(String id)
           
 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.
 KeywordArgNode keyword_arg(SourcePosition position, AssignableNode assignable)
           
 ListNode list_append(Node list, Node item)
           
 ListNode list_concat(Node first, Node second)
           
 Node literal_concat(SourcePosition position, Node head, Node tail)
           
 FloatNode negateFloat(FloatNode floatNode)
           
 Node negateInteger(Node integerNode)
           
 Node new_aref(Node receiver, Token name, Node argsNode)
           
 ArgsTailHolder new_args_tail(SourcePosition position, ListNode keywordArg, Token keywordRestArgName, BlockArgNode blockArg)
           
 Node new_args(SourcePosition position, ListNode pre, ListNode optional, RestArgNode rest, ListNode post, ArgsTailHolder tail)
           
 Node new_args(SourcePosition position, ListNode pre, ListNode optional, RestArgNode rest, ListNode post, BlockArgNode block)
           
 Node new_attrassign(SourcePosition position, Node receiver, String name, Node args)
           
 Node new_bv(Token identifier)
           
 Node new_call(Node receiver, Token name, Node args, Node iter)
           
 Colon2Node new_colon2(SourcePosition position, Node leftNode, String name)
           
 Colon3Node new_colon3(SourcePosition position, String name)
           
 Node new_fcall(Token operation, Node args, Node iter)
           
 IterNode new_iter(SourcePosition position, Node vars, StaticScope scope, Node body)
           
 Node new_opElementAsgnNode(SourcePosition position, Node receiverNode, String operatorName, Node argsNode, Node valueNode)
           
 Node new_super(Node args, Token operation)
           
 Node new_yield(SourcePosition position, Node node)
           
 Node newAlias(SourcePosition position, Node newNode, Node oldNode)
           
 AndNode newAndNode(SourcePosition position, Node left, Node right)
           
 ArrayNode newArrayNode(SourcePosition position, Node firstNode)
           
 BlockArgNode newBlockArg(SourcePosition position, Token nameToken)
           
 BlockArg18Node newBlockArg18(SourcePosition position, Node blockValue, Node args)
           
 CaseNode newCaseNode(SourcePosition position, Node expression, Node firstWhenNode)
          Ok I admit that this is somewhat ugly.
 Node newEvStrNode(SourcePosition position, Node node)
           
 Node newline_node(Node node, SourcePosition position)
          Wraps node with NEWLINE node.
 OrNode newOrNode(SourcePosition position, Node left, Node right)
           
 Node newRegexpNode(SourcePosition position, Node contents, RegexpNode end)
           
 SplatNode newSplatNode(SourcePosition position, Node node)
           
 Node newUndef(SourcePosition position, Node nameNode)
           
 WhenNode newWhenNode(SourcePosition position, Node expressionNodes, Node bodyNode, Node nextCase)
           
 Node node_assign(Node lhs, Node rhs)
           
 void popCurrentScope()
           
 void pushBlockScope()
           
 void pushLocalScope()
           
 void regexpFragmentCheck(RegexpNode end, String value)
           
 void reset()
           
 Node ret_args(Node node, SourcePosition position)
           
 void setConfiguration(ParserConfiguration configuration)
          Sets the configuration.
 void setInDef(boolean inDef)
           
 void setInSingle(int inSingle)
          Setter for property inSingle.
 void setLexer(Lexer lexer)
           
 void setResult(ParserResult 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.
 SourcePosition union(ISourcePositionHolder first, ISourcePositionHolder second)
           
 SourcePosition union(SourcePosition first, SourcePosition second)
           
 Node unwrapNewlineNode(Node node)
           
 void warn(IRubyWarnings.ID id, SourcePosition position, String message, Object... data)
           
 void warning(IRubyWarnings.ID id, SourcePosition position, String message, Object... data)
           
 void warningUnlessEOption(IRubyWarnings.ID id, Node node, String message)
           
 void warnUnlessEOption(IRubyWarnings.ID id, Node node, String message)
           
 void yyerror(String message)
          generate parsing error
 void yyerror(String message, String[] expected, 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

lexer

protected Lexer lexer

currentScope

protected StaticScope currentScope

warnings

protected IRubyWarnings warnings
Constructor Detail

ParserSupport

public ParserSupport()
Method Detail

isConstant

public static boolean isConstant(String id)

reset

public void reset()

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(SourcePosition 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(SourcePosition position,
                                     String identifier)

assignable

public AssignableNode assignable(Token lhs,
                                 Node value)

newline_node

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

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

union

public SourcePosition union(ISourcePositionHolder first,
                            ISourcePositionHolder second)

union

public SourcePosition union(SourcePosition first,
                            SourcePosition second)

addRootNode

public Node addRootNode(Node topOfAST,
                        SourcePosition position)

appendToBlock

public Node appendToBlock(Node head,
                          Node tail)

getUnaryCallNode

public Node getUnaryCallNode(Node receiver,
                             Token operator)

getOperatorCallNode

public Node getOperatorCallNode(Token operator,
                                Node receiver)

getOperatorCallNode

public Node getOperatorCallNode(SourcePosition position,
                                Node firstNode,
                                String operator)

getOperatorCallNode

public Node getOperatorCallNode(Node firstNode,
                                String operator,
                                Node secondNode)

getOperatorCallNode

public Node getOperatorCallNode(Node firstNode,
                                String operator,
                                Node secondNode,
                                SourcePosition 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,
                    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(SourcePosition position,
                    Node node1,
                    Node node2)

node_assign

public Node node_assign(Node lhs,
                        Node rhs)

ret_args

public Node ret_args(Node node,
                     SourcePosition 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,
                              String message)

warningUnlessEOption

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

checkExpression

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

Parameters:
node - to be checked
Returns:
true if an expression, false otherwise

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.

getConditionNode

public Node getConditionNode(Node node)

newSplatNode

public SplatNode newSplatNode(SourcePosition position,
                              Node node)

newArrayNode

public ArrayNode newArrayNode(SourcePosition position,
                              Node firstNode)

newAndNode

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

newOrNode

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

newCaseNode

public CaseNode newCaseNode(SourcePosition 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(SourcePosition position,
                            Node expressionNodes,
                            Node bodyNode,
                            Node nextCase)

getReturnArgsNode

public Node getReturnArgsNode(Node node)

new_opElementAsgnNode

public Node new_opElementAsgnNode(SourcePosition position,
                                  Node receiverNode,
                                  String operatorName,
                                  Node argsNode,
                                  Node valueNode)

new_attrassign

public Node new_attrassign(SourcePosition position,
                           Node receiver,
                           String name,
                           Node args)

new_call

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

new_aref

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

new_colon2

public Colon2Node new_colon2(SourcePosition position,
                             Node leftNode,
                             String name)

new_colon3

public Colon3Node new_colon3(SourcePosition position,
                             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 ParserResult getResult()
Gets the result.

Returns:
Returns a RubyParserResult

setResult

public void setResult(ParserResult 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

setLexer

public void setLexer(Lexer lexer)

setWarnings

public void setWarnings(IRubyWarnings warnings)

literal_concat

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

newEvStrNode

public Node newEvStrNode(SourcePosition position,
                         Node node)

new_yield

public Node new_yield(SourcePosition position,
                      Node node)

negateInteger

public Node negateInteger(Node integerNode)

negateFloat

public FloatNode negateFloat(FloatNode floatNode)

createEmptyArgsNodePosition

public SourcePosition createEmptyArgsNodePosition(SourcePosition pos)

unwrapNewlineNode

public Node unwrapNewlineNode(Node node)

asSymbol

public Node asSymbol(SourcePosition position,
                     Node value)

new_args_tail

public ArgsTailHolder new_args_tail(SourcePosition position,
                                    ListNode keywordArg,
                                    Token keywordRestArgName,
                                    BlockArgNode blockArg)

new_args

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

new_args

public Node new_args(SourcePosition position,
                     ListNode pre,
                     ListNode optional,
                     RestArgNode rest,
                     ListNode post,
                     ArgsTailHolder tail)

newAlias

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

newUndef

public Node newUndef(SourcePosition position,
                     Node nameNode)

newBlockArg18

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

newBlockArg

public BlockArgNode newBlockArg(SourcePosition position,
                                Token nameToken)

new_iter

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

yyerror

public void yyerror(String message)
generate parsing error


yyerror

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

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

warn

public void warn(IRubyWarnings.ID id,
                 SourcePosition position,
                 String message,
                 Object... data)

warning

public void warning(IRubyWarnings.ID id,
                    SourcePosition position,
                    String message,
                    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,
                                String value)

checkRegexpSyntax

protected void checkRegexpSyntax(String value,
                                 RegexpOptions options)

newRegexpNode

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

getPosition2

public SourcePosition getPosition2(ISourcePositionHolder pos)
Since we can recieve positions at times we know can be null we need an extra safety net here.


getPosition

public SourcePosition getPosition(ISourcePositionHolder start)

getPosition

public SourcePosition getPosition(ISourcePositionHolder start,
                                  boolean inclusive)

keyword_arg

public KeywordArgNode keyword_arg(SourcePosition position,
                                  AssignableNode assignable)


Copyright © 2013. All Rights Reserved.