Refactor parser compile functions #10597
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refactor parser compile functions to reduce the dependence
on ruby functions.
This commit includes these changes
gets
,input
andgets_
ofparser_params
Parser needs two different data structure to get next line, function (
gets
) and input data (input
).However
gets_
is used for both function (call
) and input data (ptr
).call
is used for managing general callback function whenrb_ruby_parser_compile_generic
is used.ptr
is used for managing the current pointer on String whenparser_compile_string
is used.This commit changes parser to used only
gets
andinput
then removesgets_
.gets
functions from parse.y to ruby_parser.cThis change reduces the dependence on ruby functions from parser.
VALUE input
GC markMove the responsibility of calling
rb_gc_mark
forVALUE input
from parser to ruby_parser and ripper.input
is arbitrary data pointer from the viewpoint of parser.Caller of
rb_parser_compile_generic
needs to take care about GC because ruby_parser doesn’t knowabout the detail of
lex_gets
andinput
.Introduce
rb_parser_compile_array
to reduce the complexity of ast.c.