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 StaticScopestatic final ByteListbooleanprotected RubyLexerstatic ByteListstatic final ByteListprotected static final intprotected ScopedParserStateprotected ParserType -
Constructor Summary
ConstructorsConstructorDescriptionRubyParserBase(Ruby runtime, LexerSource source, DynamicScope scope, ParserType type) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRootNode(Node topOfAST) protected NodeExitsappendToBlock(Node head, Node tail) arg_append(Node node1, Node node2) static Nodearg_blk_pass(Node firstNode, BlockPassNode secondNode) static Nodearg_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 intassociateEncoding(ByteList buffer, org.jcodings.Encoding newEncoding, int codeRange) Define an attribute set condition so we can return lhsvoidbackref_error(Node node) protected voidbegin_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) booleanvoidcheck_literal_when(Node one) protected voidclear_block_exit(boolean value) voidcompile_error(String message) protected ConstDeclNodevoidcoverLine(int i) Zero out coverable lines as they're encounteredcreateDStrNode(int line) createKeyValue(Node key, Node value) protected StrNodedeclareIdentifier(ByteList byteName) protected booleanvoidendless_method_name(DefHolder name, ProductionState loc) voidvoiderror_duplicate_pattern_variable(ByteList variable) protected ByteListextractByteList(Object value) voidfinalizeDynamicScope(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.voidformal_argument(ByteList identifier, Object _unused) protected voidforwarding_arg_check(ByteList rest, ByteList all, String var) voidfrobnicate_fcall_args(FCallNode fcall, Node args, Node iter) protected intprotected StackStateprotected StackStateprotected ByteListprotected org.jcodings.Encodingprotected StringgetFile()protected intprotected intprotected LexContextprotected intintgetPosition(Node start) Gets the result.protected intgetState()protected StrTermWe know for callers of this that it cannot be any of the specials checked in gettable.protected voidgetterIdentifierError(RubySymbol identifier) protected TokenInfogetTopStaticScope(String file) Returns the static scope which represents the top of the parse.voidgrowCoverageLines(int i) Called by coverLine to grow it large enough to add new covered line.booleanprotected voidheredoc_dedent(Node node) static RubyParserBase.IDTypeprotected NodeExitsvoidDescription of the RubyMethodDeprecated.booleanis_local_id(String name) Deprecated.static booleanis_local_id(ByteList name) static booleanis_private_local_id(ByteList name) booleanisArgsInfoEmpty(ArgsNode argsNode) booleanbooleanprotected booleanisEval()booleanbooleanprotected Nodeit_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) booleanprotected NodemakeNullNil(Node node) method_cond(Node node) voidnd_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 ArgsTailHoldernew_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 NodeNEW_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 NodenewArrayNode(int line, Node node) static CaseNodenewCaseNode(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 PatternCaseNodenewPatternCaseNode(int line, Node expression, Node firstWhenNode) newRescueModNode(Node body, Node rescueBody) newSplatNode(Node node) newSValueNode(int line, Node node) static NodenewWhenNode(int line, Node expressionNodes, Node bodyNode, Node nextCase) protected voidnext_rescue_context(LexContext context, LexContext.InRescue value) nil()static Nodenode_assign(Node lhs, Node rhs, LexContext _lexContext) none()voidnumparam_name(RubySymbol name) voidnumparam_name(ByteList name) voidnumparam_pop(Node previousInner) voidparse()voidvoidvoidintprotected voidpush_end_expect_token_locations(int line) voidvoidreduce_nodes(Node body) remove_begin(Node node) rescued_expr(int line, Node arg, Node rescue) voidreset()intrest_arg_append(Node args, Node restArg) protected voidrestore_block_exit(NodeExits nodeExits) voidrestore_defun(DefHolder holder) intrestoreMaxNumParam(int maxNum) protected voidprotected voidsetBraceNest(int value) protected voidsetCommandStart(boolean value) protected voidsetCurrentArg(RubySymbol value) protected voidsetHeredocIndent(int value) protected voidsetHeredocLineIndent(int indent) protected voidsetLeftParenBegin(int value) protected voidsetLexContext(LexContext lexContext) protected voidsetState(int value) voidsetStringStyle(Boolean frozen) protected voidsetStrTerm(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 intsrc_line()protected voidtoken_info_drop(String value, ProductionState loc) protected voidtoken_info_pop(String value, ProductionState loc) protected voidtoken_info_push(String value, ProductionState loc) protected voidtoken_info_setup(String value, ProductionState loc) protected voidtoken_info_warn(String name, int same, ProductionState loc) booleanvalue_expr(Node node) voidCheck 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.voidvoidprotected voidvoidvoidwarning(IRubyWarnings.ID id, String file, int line, String message) voidwarnUnlessEOption(IRubyWarnings.ID id, Node node, String message) voidgenerate parsing errorvoidgenerate parsing errorvoidyyerror(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()
-