Class ParserSupport

java.lang.Object
org.jruby.parser.ParserSupport

public class ParserSupport extends Object
  • Field Details

    • currentScope

      protected StaticScope currentScope
    • scopedParserState

      protected ScopedParserState scopedParserState
    • lexer

      protected RubyLexer lexer
    • inDefinition

      private boolean inDefinition
    • inClass

      private boolean inClass
    • warnOnUnusedVariables

      private boolean warnOnUnusedVariables
    • warnings

      protected IRubyWarnings warnings
    • configuration

      protected ParserConfiguration configuration
    • result

      private RubyParserResult result
    • isNextBreak

      public boolean isNextBreak
    • INTERNAL_ID

      public static final ByteList INTERNAL_ID
  • Constructor Details

    • ParserSupport

      public ParserSupport()
  • Method Details

    • 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 static Node arg_concat(Node node1, Node node2)
    • arg_blk_pass

      public static 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
    • declareIdentifier

      public Node declareIdentifier(ByteList byteName)
    • assignableLabelOrIdentifier

      public AssignableNode assignableLabelOrIdentifier(ByteList byteName, Node value)
    • addOrMarkVariable

      private void addOrMarkVariable(RubySymbol name, int slot)
    • assignableKeyword

      public AssignableNode assignableKeyword(ByteList name, Node value)
    • getterIdentifierError

      protected void getterIdentifierError(RubySymbol identifier)
    • newline_node

      public Node newline_node(Node node, int line)
      Wraps node with NEWLINE node.
    • addRootNode

      public Node addRootNode(Node topOfAST)
    • appendToBlock

      public Node appendToBlock(Node head, Node tail)
    • assignableInCurr

      public AssignableNode assignableInCurr(ByteList nameBytes, Node value)
    • getOperatorCallNode

      public Node getOperatorCallNode(Node firstNode, ByteList operator)
    • getOperatorCallNode

      public Node getOperatorCallNode(Node firstNode, ByteList operator, Node secondNode)
    • getOperatorCallNode

      public Node getOperatorCallNode(Node firstNode, ByteList operator, Node secondNode, int defaultPosition)
    • getOperatorCallNodeInner

      private Node getOperatorCallNodeInner(Node firstNode, ByteList operator, Node secondNode)
    • 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, ByteList 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
    • attrset

      public Node attrset(Node receiver, ByteList callType, ByteList name)
    • backrefAssignError

      public void backrefAssignError(Node node)
    • arg_add

      private static Node arg_add(int line, Node node1, Node node2)
    • node_assign

      public static Node node_assign(Node lhs, Node rhs)
    • ret_args

      public Node ret_args(Node node, int line)
    • isBreakStatement

      private static boolean isBreakStatement(Node node)
    • warnUnlessEOption

      public void warnUnlessEOption(IRubyWarnings.ID id, Node node, String message)
    • value_expr

      public boolean value_expr(RubyLexer lexer, Node node)
    • handleUselessWarn

      private void handleUselessWarn(Node node, String useless)
    • void_expr

      public void void_expr(Node node)
      Check to see if current node is an useless statement. If useless a warning if printed.
      Parameters:
      node - to be checked.
    • void_stmts

      public Node void_stmts(Node node)
      Check all nodes but the last one in a BlockNode for useless (void context) statements.
      Parameters:
      node - to be checked.
    • checkAssignmentInCondition

      private boolean checkAssignmentInCondition(Node node)
      assign_in_cond
    • isStaticContent

      private static boolean isStaticContent(Node node)
    • makeNullNil

      protected Node makeNullNil(Node node)
    • cond0

      private Node cond0(Node node, boolean method)
    • cond

      public Node cond(Node node)
    • method_cond

      public Node method_cond(Node node)
    • new_if

      public Node new_if(int line, Node condition, Node thenNode, Node elseNode)
    • getFlipConditionNode

      private Node getFlipConditionNode(Node node)
    • newSValueNode

      public SValueNode newSValueNode(int line, Node node)
    • newSplatNode

      public SplatNode newSplatNode(Node node)
    • newArrayNode

      public ArrayNode newArrayNode(int line, Node node)
    • position

      public int position(Node one, Node two)
    • newAndNode

      public AndNode newAndNode(Node left, Node right)
    • newOrNode

      public OrNode newOrNode(Node left, Node right)
    • newCaseNode

      public static CaseNode newCaseNode(int line, 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
    • simplifyMultipleArgumentWhenNodes

      private static void simplifyMultipleArgumentWhenNodes(WhenNode sourceWhen, ArrayNode cases)
    • newWhenNode

      public WhenNode newWhenNode(int line, Node expressionNodes, Node bodyNode, Node nextCase)
    • new_op_assign

      public Node new_op_assign(AssignableNode receiverNode, ByteList operatorName, Node valueNode)
    • new_ary_op_assign

      public Node new_ary_op_assign(Node receiverNode, ByteList operatorName, Node argsNode, Node valueNode)
    • new_attr_op_assign

      public Node new_attr_op_assign(Node receiverNode, ByteList callType, Node valueNode, ByteList variableName, ByteList operatorName)
    • new_const_op_assign

      public Node new_const_op_assign(int line, Node lhs, ByteList operatorName, Node rhs)
    • new_bodystmt

      public Node new_bodystmt(Node head, RescueBodyNode rescue, Node rescueElse, Node ensure)
    • symbolID

      public RubySymbol symbolID(ByteList identifierValue)
    • isLazy

      public boolean isLazy(String callType)
    • isLazy

      public boolean isLazy(ByteList callType)
    • new_attrassign

      public Node new_attrassign(int line, Node receiver, ByteList name, Node argsNode, boolean isLazy)
    • new_call

      public Node new_call(Node receiver, ByteList callType, ByteList name, Node argsNode, Node iter)
    • new_call

      public Node new_call(Node receiver, ByteList callType, ByteList name, Node argsNode, Node iter, int line)
    • new_call

      public Node new_call(Node receiver, ByteList name, Node argsNode, Node iter)
    • new_colon2

      public Colon2Node new_colon2(int line, Node leftNode, ByteList name)
    • new_colon3

      public Colon3Node new_colon3(int line, ByteList name)
    • frobnicate_fcall_args

      public void frobnicate_fcall_args(FCallNode fcall, Node args, Node iter)
    • fixpos

      public void fixpos(Node node, Node orig)
    • new_fcall

      public Node new_fcall(ByteList operation)
    • new_super

      public Node new_super(int line, Node args)
    • initTopLocalVariables

      public void initTopLocalVariables()
      Description of the RubyMethod
    • isInDef

      public boolean isInDef()
    • setInDef

      public void setInDef(boolean inDef)
    • isInClass

      public boolean isInClass()
    • setIsInClass

      public void setIsInClass(boolean inClass)
    • 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(RubyLexer lexer)
    • createDStrNode

      public DStrNode createDStrNode(int line)
    • createKeyValue

      public KeyValuePair<Node,Node> createKeyValue(Node key, Node value)
    • asSymbol

      public Node asSymbol(int line, ByteList value)
    • asSymbol

      public Node asSymbol(int line, Node value)
    • literal_concat

      public Node literal_concat(Node head, Node tail)
    • newRescueModNode

      public Node newRescueModNode(Node body, Node rescueBody)
    • newEvStrNode

      public Node newEvStrNode(int line, Node node)
    • new_yield

      public Node new_yield(int line, Node node)
    • negateInteger

      public NumericNode negateInteger(NumericNode integerNode)
    • negateFloat

      public FloatNode negateFloat(FloatNode floatNode)
    • negateComplexNode

      public ComplexNode negateComplexNode(ComplexNode complexNode)
    • negateRational

      public RationalNode negateRational(RationalNode rationalNode)
    • checkForNilNode

      private Node checkForNilNode(Node node, int defaultPosition)
    • new_args

      public Node new_args(int line, ListNode pre, ListNode optional, RestArgNode rest, ListNode post, ArgsTailHolder tail)
    • new_args_tail

      public ArgsTailHolder new_args_tail(int line, ListNode keywordArg, ByteList keywordRestArgName, BlockArgNode blockArg)
    • remove_duplicate_keys

      public Node remove_duplicate_keys(HashNode hash)
    • newAlias

      public static Node newAlias(int line, Node newNode, Node oldNode)
    • newUndef

      public static Node newUndef(int line, Node nameNode)
    • yyerror

      public void yyerror(String message)
      generate parsing error
    • yyerror

      public void yyerror(String message, ProductionState state)
    • 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.
    • getPosition

      public int getPosition(Node start)
    • warn

      public void warn(IRubyWarnings.ID id, int line, String message, Object... data)
    • warning

      public void warning(IRubyWarnings.ID id, int line, String message, Object... data)
    • is_local_id

      public static boolean is_local_id(ByteList name)
    • is_local_id

      @Deprecated public boolean is_local_id(String name)
      Deprecated.
    • list_append

      public ListNode list_append(Node list, Node item)
    • new_bv

      public Node new_bv(ByteList identifier)
    • arg_var

      public ArgumentNode arg_var(ByteList byteName)
    • formal_argument

      public ByteList formal_argument(ByteList identifier)
    • is_private_local_id

      public static boolean is_private_local_id(ByteList name)
    • shadowing_lvar

      public ByteList shadowing_lvar(ByteList nameBytes)
    • 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)
    • allocateNamedLocals

      private List<Integer> allocateNamedLocals(RegexpNode regexpNode)
    • compile_error

      public void compile_error(String message)
    • newRegexpNode

      public Node newRegexpNode(int line, Node contents, RegexpNode end)
    • createMaster

      private ByteList createMaster(RegexpOptions options)
    • associateEncoding

      public static int associateEncoding(ByteList buffer, org.jcodings.Encoding newEncoding, int codeRange)
    • negateNumeric

      public NumericNode negateNumeric(NumericNode node)
    • internalId

      @Deprecated public String internalId()
      Deprecated.