Package org.jruby.parser
Class RubyParserBase
java.lang.Object
org.jruby.parser.RubyParserBase
- Direct Known Subclasses:
RubyParser
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StaticScope
static final ByteList
boolean
protected RubyLexer
static ByteList
static final ByteList
protected static final int
protected ScopedParserState
protected ParserType
-
Constructor Summary
ConstructorsConstructorDescriptionRubyParserBase
(Ruby runtime, LexerSource source, DynamicScope scope, ParserType type) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addRootNode
(Node topOfAST) protected NodeExits
appendToBlock
(Node head, Node tail) arg_append
(Node node1, Node node2) static Node
arg_blk_pass
(Node firstNode, BlockPassNode secondNode) static Node
arg_concat
(Node node1, Node node2) arg_var
(RubySymbol name) args_with_numbered
(ArgsNode args, int paramCount, Node itNode) Define an array set condition so we can return lhsassignableInCurr
(ByteList nameBytes, Node value) assignableKeyword
(ByteList name, Node value) assignableLabelOrIdentifier
(ByteList byteName, Node value) static int
associateEncoding
(ByteList buffer, org.jcodings.Encoding newEncoding, int codeRange) Define an attribute set condition so we can return lhsvoid
backref_error
(Node node) protected void
begin_definition
(String name) call_bin_op
(Node firstNode, ByteList operator, Node secondNode) call_bin_op
(Node firstNode, ByteList operator, Node secondNode, int defaultPosition) call_uni_op
(Node firstNode, ByteList operator) boolean
void
check_literal_when
(Node one) protected void
clear_block_exit
(boolean value) void
compile_error
(String message) protected ConstDeclNode
void
coverLine
(int i) Zero out coverable lines as they're encounteredcreateDStrNode
(int line) createKeyValue
(Node key, Node value) protected StrNode
declareIdentifier
(ByteList byteName) protected boolean
void
endless_method_name
(DefHolder name, ProductionState loc) void
void
error_duplicate_pattern_variable
(ByteList variable) protected ByteList
extractByteList
(Object value) void
finalizeDynamicScope
(StaticScope staticScope) finishCoverage
(String file, int lines) At end of a parse if coverage is enabled we will do final processing of the primitive coverage array and make sure runtimes coverage data has been updated with this new data.void
formal_argument
(ByteList identifier, Object _unused) protected void
forwarding_arg_check
(ByteList rest, ByteList all, String var) void
frobnicate_fcall_args
(FCallNode fcall, Node args, Node iter) protected int
protected StackState
protected StackState
protected ByteList
protected org.jcodings.Encoding
protected String
getFile()
protected int
protected int
protected LexContext
protected int
int
getPosition
(Node start) Gets the result.protected int
getState()
protected StrTerm
We know for callers of this that it cannot be any of the specials checked in gettable.protected void
getterIdentifierError
(RubySymbol identifier) protected TokenInfo
getTopStaticScope
(String file) Returns the static scope which represents the top of the parse.void
growCoverageLines
(int i) Called by coverLine to grow it large enough to add new covered line.boolean
protected void
heredoc_dedent
(Node node) static RubyParserBase.IDType
protected NodeExits
void
Description of the RubyMethodDeprecated.boolean
is_local_id
(String name) Deprecated.static boolean
is_local_id
(ByteList name) static boolean
is_private_local_id
(ByteList name) boolean
isArgsInfoEmpty
(ArgsNode argsNode) boolean
boolean
protected boolean
isEval()
boolean
boolean
protected Node
it_id()
last_arg_append
(Node args, Node lastArg) list_append
(Node list, Node item) list_concat
(Node first, Node second) literal_concat
(Node head, Node tail) boolean
protected Node
makeNullNil
(Node node) method_cond
(Node node) void
nd_set_first_loc
(Node node, int line) negateComplexNode
(ComplexNode complexNode) negateFloat
(FloatNode floatNode) negateInteger
(NumericNode integerNode) negateNumeric
(NumericNode node) negateRational
(RationalNode rationalNode) new_args
(int line, ListNode pre, ListNode optional, RestArgNode rest, ListNode post, ArgsTailHolder tail) new_args_forward_call
(int line, Node leadingArgs) new_args_tail
(int line, ListNode keywordArg, ByteList keywordRestArgName, BlockArgNode blockArg) protected ArgsTailHolder
new_args_tail
(int line, ListNode keywordArg, ByteList keywordRestArgName, ByteList block) new_array_pattern
(int line, Node constant, Node preArg, ArrayPatternNode arrayPattern) new_array_pattern_tail
(int line, ListNode preArgs, boolean hasRest, ByteList restArg, ListNode postArgs) new_ary_op_assign
(Node receiverNode, Node argsNode, ByteList operatorName, Node valueNode) new_attr_op_assign
(Node receiverNode, ByteList callType, ByteList variableName, ByteList operatorName, Node valueNode) new_attrassign
(int line, Node receiver, ByteList name, Node argsNode, boolean isLazy) new_bodystmt
(Node head, RescueBodyNode rescue, Node rescueElse, Node ensure) new_colon2
(int line, Node leftNode, ByteList name) new_colon3
(int line, ByteList name) new_const_op_assign
(int line, Node lhs, ByteList operatorName, Node rhs, LexContext _lexContext) new_defined
(long line, Node node) protected Node
NEW_ERROR
(ProductionState loc) new_find_pattern
(Node constant, FindPatternNode findPattern) new_find_pattern_tail
(int line, ByteList preRestArg, ListNode postArgs, ByteList postRestArg) new_hash_pattern
(Node constant, HashPatternNode hashPatternNode) new_hash_pattern_tail
(int line, HashNode keywordArgs, ByteList keywordRestArg) new_op_assign
(AssignableNode receiverNode, ByteList operatorName, Node valueNode, LexContext _lexContext) new_regexp
(int line, Node contents, RegexpNode end) static Node
newArrayNode
(int line, Node node) static CaseNode
newCaseNode
(int line, Node expression, Node firstWhenNode) We post-process a chain of when nodes and analyze them to re-insert them back into our new CaseNode as a list.newEvStrNode
(int line, Node node) newline_node
(Node node, int line) Wraps node with NEWLINE node.static PatternCaseNode
newPatternCaseNode
(int line, Node expression, Node firstWhenNode) newRescueModNode
(Node body, Node rescueBody) newSplatNode
(Node node) newSValueNode
(int line, Node node) static Node
newWhenNode
(int line, Node expressionNodes, Node bodyNode, Node nextCase) protected void
next_rescue_context
(LexContext context, LexContext.InRescue value) nil()
static Node
node_assign
(Node lhs, Node rhs, LexContext _lexContext) none()
void
numparam_name
(RubySymbol name) void
numparam_name
(ByteList name) void
numparam_pop
(Node previousInner) void
parse()
void
void
void
int
protected void
push_end_expect_token_locations
(int line) void
void
reduce_nodes
(Node body) remove_begin
(Node node) rescued_expr
(int line, Node arg, Node rescue) void
reset()
int
rest_arg_append
(Node args, Node restArg) protected void
restore_block_exit
(NodeExits nodeExits) void
restore_defun
(DefHolder holder) int
restoreMaxNumParam
(int maxNum) protected void
protected void
setBraceNest
(int value) protected void
setCommandStart
(boolean value) protected void
setCurrentArg
(RubySymbol value) protected void
setHeredocIndent
(int value) protected void
setHeredocLineIndent
(int indent) protected void
setLeftParenBegin
(int value) protected void
setLexContext
(LexContext lexContext) protected void
setState
(int value) void
setStringStyle
(Boolean frozen) protected void
setStrTerm
(StrTerm value) shadowing_lvar
(ByteList nameBytes) splat_array
(Node node) If node is a splat and it is splatting a literal array then return the literal array.protected int
src_line()
protected void
token_info_drop
(String value, ProductionState loc) protected void
token_info_pop
(String value, ProductionState loc) protected void
token_info_push
(String value, ProductionState loc) protected void
token_info_setup
(String value, ProductionState loc) protected void
token_info_warn
(String name, int same, ProductionState loc) boolean
value_expr
(Node node) void
Check to see if current node is an useless statement.void_stmts
(Node node) Check all nodes but the last one in a BlockNode for useless (void context) statements.void
void
protected void
void
void
warning
(IRubyWarnings.ID id, String file, int line, String message) void
warnUnlessEOption
(IRubyWarnings.ID id, Node node, String message) void
generate parsing errorvoid
generate parsing errorvoid
yyerror
(String message, ProductionState state) protected abstract Object
-
Field Details
-
currentScope
-
scopedParserState
-
lexer
-
isNextBreak
public boolean isNextBreak -
case_labels
-
ORDINAL_PARAM
protected static final int ORDINAL_PARAM- See Also:
-
type
-
INTERNAL_ID
-
NIL
-
NOT
-
-
Constructor Details
-
RubyParserBase
-
-
Method Details
-
reset
public void reset() -
getCurrentScope
-
popCurrentScope
public void popCurrentScope() -
pushBlockScope
public void pushBlockScope() -
pushLocalScope
public void pushLocalScope() -
numparam_push
-
numparam_pop
-
args_with_numbered
-
resetMaxNumParam
public int resetMaxNumParam() -
restoreMaxNumParam
public int restoreMaxNumParam(int maxNum) -
ordinalMaxNumParam
public void ordinalMaxNumParam() -
arg_concat
-
arg_blk_pass
-
gettable2
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
-
hasNumParam
public boolean hasNumParam() -
numparam_name
-
numparam_name
-
declareIdentifier
-
isArgsInfoEmpty
-
assignableLabelOrIdentifier
-
assignableKeyword
-
getterIdentifierError
-
newline_node
Wraps node with NEWLINE node. -
addRootNode
-
appendToBlock
-
assignableInCurr
-
call_uni_op
-
call_bin_op
-
call_bin_op
-
new_defined
-
match_op
-
aryset
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
-
attrset
Define an attribute set condition so we can return lhs- Parameters:
receiver
- object which contains attributename
- of the attribute being set- Returns:
- an AttrAssignNode
-
attrset
-
backref_error
-
node_assign
-
ret_args
-
warnUnlessEOption
-
value_expr
-
void_expr
Check to see if current node is an useless statement. If useless a warning if printed.- Parameters:
node
- to be checked.
-
gettable
-
void_stmts
Check all nodes but the last one in a BlockNode for useless (void context) statements.- Parameters:
node
- to be checked.
-
makeNullNil
-
cond
-
method_cond
-
new_if
-
newSValueNode
-
newSplatNode
-
newArrayNode
-
position
-
logop
-
newCaseNode
We post-process a chain of when nodes and analyze them to re-insert them back into our new CaseNode as a list. The grammar is more amenable to linked list style so we correct it at this point.- Parameters:
expression
- of the case node (e.g. case foo)firstWhenNode
- first when (which could also be the else)- Returns:
- a new case node
-
newPatternCaseNode
-
newWhenNode
-
new_op_assign
public Node new_op_assign(AssignableNode receiverNode, ByteList operatorName, Node valueNode, LexContext _lexContext) -
new_ary_op_assign
-
new_attr_op_assign
-
new_const_op_assign
public Node new_const_op_assign(int line, Node lhs, ByteList operatorName, Node rhs, LexContext _lexContext) -
new_bodystmt
-
symbolID
-
isLazy
-
isLazy
-
new_attrassign
-
new_call
-
new_call
-
new_call
-
new_colon2
-
new_colon3
-
frobnicate_fcall_args
-
fixpos
-
new_fcall
-
new_super
-
initTopLocalVariables
public void initTopLocalVariables()Description of the RubyMethod -
isEval
protected boolean isEval() -
finalizeDynamicScope
public void finalizeDynamicScope() -
getResult
Gets the result.- Returns:
- Returns a RubyParserResult
-
createDStrNode
-
createKeyValue
-
asSymbol
-
asSymbol
-
literal_concat
-
newRescueModNode
-
newEvStrNode
-
new_yield
-
negateInteger
-
negateFloat
-
negateComplexNode
-
negateRational
-
new_args
public ArgsNode 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) -
new_args_tail
protected ArgsTailHolder new_args_tail(int line, ListNode keywordArg, ByteList keywordRestArgName, ByteList block) -
remove_duplicate_keys
-
newAlias
-
newUndef
-
yyerror
generate parsing error -
yyerror
-
yyerror
generate parsing error- Parameters:
message
- text to be displayed.expected
- list of acceptable tokens, if available.
-
getPosition
-
warn
-
warn
-
warning
-
warning
-
is_local_id
-
is_local_id
Deprecated. -
list_append
-
new_bv
-
arg_var
-
arg_var
-
formal_argument
-
id_type
-
is_private_local_id
-
shadowing_lvar
-
list_concat
-
splat_array
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
-
compile_error
-
new_regexp
-
associateEncoding
public static int associateEncoding(ByteList buffer, org.jcodings.Encoding newEncoding, int codeRange) -
negateNumeric
-
internalId
Deprecated. -
begin_definition
-
push_pvtbl
-
pop_pvtbl
-
push_pktbl
-
pop_pktbl
-
newIn
-
endless_method_name
-
reduce_nodes
-
restore_defun
-
new_array_pattern
public ArrayPatternNode new_array_pattern(int line, Node constant, Node preArg, ArrayPatternNode arrayPattern) -
new_hash_pattern
-
none
-
new_hash_pattern_tail
public HashPatternNode new_hash_pattern_tail(int line, HashNode keywordArgs, ByteList keywordRestArg) -
rescued_expr
-
new_array_pattern_tail
public ArrayPatternNode new_array_pattern_tail(int line, ListNode preArgs, boolean hasRest, ByteList restArg, ListNode postArgs) -
error_duplicate_pattern_key
-
error_duplicate_pattern_variable
-
new_find_pattern
-
new_find_pattern_tail
-
local_id
-
check_forwarding_args
public boolean check_forwarding_args() -
add_forwarding_args
public void add_forwarding_args() -
new_args_forward_call
-
check_literal_when
-
last_arg_append
-
rest_arg_append
-
remove_begin
-
nd_set_first_loc
-
parse
- Throws:
IOException
-
yyparse
- Throws:
IOException
-
getLexContext
-
setLexContext
-
src_line
protected int src_line() -
getHeredocIndent
protected int getHeredocIndent() -
setHeredocIndent
protected void setHeredocIndent(int value) -
getBraceNest
protected int getBraceNest() -
setBraceNest
protected void setBraceNest(int value) -
getState
protected int getState() -
setState
protected void setState(int value) -
getEncoding
protected org.jcodings.Encoding getEncoding() -
setCommandStart
protected void setCommandStart(boolean value) -
getCurrentArg
-
setCurrentArg
-
createStr
-
getCmdArgumentState
-
getConditionState
-
getLeftParenBegin
protected int getLeftParenBegin() -
getParenNest
protected int getParenNest() -
extractByteList
-
setLeftParenBegin
protected void setLeftParenBegin(int value) -
getFile
-
heredoc_dedent
-
getStrTerm
-
setStrTerm
-
setHeredocLineIndent
protected void setHeredocLineIndent(int indent) -
cont_decl
-
getRuntime
-
nil
-
get_id
-
getWarnings
-
isEndSeen
public boolean isEndSeen() -
getStringStyle
-
setStringStyle
-
finalizeDynamicScope
-
getTopStaticScope
Returns the static scope which represents the top of the parse. If an eval then we will have an existing scope to return. If not then we make a new one since we are starting from scratch.- Parameters:
file
- to name top scope if we have a new scope- Returns:
- a static scope
-
isCoverageEnabled
public boolean isCoverageEnabled() -
coverLine
public void coverLine(int i) Zero out coverable lines as they're encountered -
growCoverageLines
public void growCoverageLines(int i) Called by coverLine to grow it large enough to add new covered line. Also called at end up parse to pick up any extra non-code lines which should be marked -1 for not valid code lines. -
finishCoverage
At end of a parse if coverage is enabled we will do final processing of the primitive coverage array and make sure runtimes coverage data has been updated with this new data. -
token_info_setup
-
token_info_push
-
token_info_pop
-
token_info_drop
-
token_info_warn
-
getTokenInfo
-
push_end_expect_token_locations
protected void push_end_expect_token_locations(int line) -
allow_block_exit
-
clear_block_exit
protected void clear_block_exit(boolean value) -
next_rescue_context
-
it_id
-
set_it_id
-
init_block_exit
-
restore_block_exit
-
NEW_ERROR
-
forwarding_arg_check
-
WARN_EOL
-
dyna_in_block
protected boolean dyna_in_block()
-