Sync to latest prism
This commit is contained in:
parent
40642cd3bc
commit
0b5be2f9e9
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Gem::Specification.new do |spec|
|
Gem::Specification.new do |spec|
|
||||||
spec.name = "prism"
|
spec.name = "prism"
|
||||||
spec.version = "0.20.0"
|
spec.version = "0.21.0"
|
||||||
spec.authors = ["Shopify"]
|
spec.authors = ["Shopify"]
|
||||||
spec.email = ["ruby@shopify.com"]
|
spec.email = ["ruby@shopify.com"]
|
||||||
|
|
||||||
|
@ -614,9 +614,7 @@ module Prism
|
|||||||
# foo => [*, bar, *]
|
# foo => [*, bar, *]
|
||||||
# ^^^^^^^^^^^
|
# ^^^^^^^^^^^
|
||||||
def visit_find_pattern_node(node)
|
def visit_find_pattern_node(node)
|
||||||
elements = [*node.requireds]
|
elements = [node.left, *node.requireds, node.right]
|
||||||
elements << node.rest if !node.rest.nil? && !node.rest.is_a?(ImplicitRestNode)
|
|
||||||
elements.concat(node.posts)
|
|
||||||
|
|
||||||
if node.constant
|
if node.constant
|
||||||
builder.const_pattern(visit(node.constant), token(node.opening_loc), builder.find_pattern(nil, visit_all(elements), nil), token(node.closing_loc))
|
builder.const_pattern(visit(node.constant), token(node.opening_loc), builder.find_pattern(nil, visit_all(elements), nil), token(node.closing_loc))
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef PRISM_EXT_NODE_H
|
#ifndef PRISM_EXT_NODE_H
|
||||||
#define PRISM_EXT_NODE_H
|
#define PRISM_EXT_NODE_H
|
||||||
|
|
||||||
#define EXPECTED_PRISM_VERSION "0.20.0"
|
#define EXPECTED_PRISM_VERSION "0.21.0"
|
||||||
|
|
||||||
#include <ruby.h>
|
#include <ruby.h>
|
||||||
#include <ruby/encoding.h>
|
#include <ruby/encoding.h>
|
||||||
|
@ -5435,7 +5435,7 @@ pm_source_file_node_create(pm_parser_t *parser, const pm_token_t *file_keyword)
|
|||||||
.flags = PM_NODE_FLAG_STATIC_LITERAL,
|
.flags = PM_NODE_FLAG_STATIC_LITERAL,
|
||||||
.location = PM_LOCATION_TOKEN_VALUE(file_keyword),
|
.location = PM_LOCATION_TOKEN_VALUE(file_keyword),
|
||||||
},
|
},
|
||||||
.filepath = parser->filepath,
|
.filepath = parser->filepath
|
||||||
};
|
};
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
@ -10779,14 +10779,6 @@ match4(const pm_parser_t *parser, pm_token_type_t type1, pm_token_type_t type2,
|
|||||||
return match1(parser, type1) || match1(parser, type2) || match1(parser, type3) || match1(parser, type4);
|
return match1(parser, type1) || match1(parser, type2) || match1(parser, type3) || match1(parser, type4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the current token is any of the five given types.
|
|
||||||
*/
|
|
||||||
static inline bool
|
|
||||||
match5(const pm_parser_t *parser, pm_token_type_t type1, pm_token_type_t type2, pm_token_type_t type3, pm_token_type_t type4, pm_token_type_t type5) {
|
|
||||||
return match1(parser, type1) || match1(parser, type2) || match1(parser, type3) || match1(parser, type4) || match1(parser, type5);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the current token is any of the six given types.
|
* Returns true if the current token is any of the six given types.
|
||||||
*/
|
*/
|
||||||
@ -11423,7 +11415,7 @@ parse_statements(pm_parser_t *parser, pm_context_t context) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have a terminator, then we will parse all consequtive terminators
|
// If we have a terminator, then we will parse all consecutive terminators
|
||||||
// and then continue parsing the statements list.
|
// and then continue parsing the statements list.
|
||||||
if (accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON)) {
|
if (accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON)) {
|
||||||
// If we have a terminator, then we will continue parsing the statements
|
// If we have a terminator, then we will continue parsing the statements
|
||||||
@ -14073,7 +14065,7 @@ parse_pattern(pm_parser_t *parser, bool top_pattern, pm_diagnostic_id_t diag_id)
|
|||||||
// Gather up all of the patterns into the list.
|
// Gather up all of the patterns into the list.
|
||||||
while (accept1(parser, PM_TOKEN_COMMA)) {
|
while (accept1(parser, PM_TOKEN_COMMA)) {
|
||||||
// Break early here in case we have a trailing comma.
|
// Break early here in case we have a trailing comma.
|
||||||
if (match5(parser, PM_TOKEN_KEYWORD_THEN, PM_TOKEN_BRACE_RIGHT, PM_TOKEN_BRACKET_RIGHT, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON)) {
|
if (match6(parser, PM_TOKEN_KEYWORD_THEN, PM_TOKEN_BRACE_RIGHT, PM_TOKEN_BRACKET_RIGHT, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON, PM_TOKEN_EOF)) {
|
||||||
node = (pm_node_t *) pm_implicit_rest_node_create(parser, &parser->previous);
|
node = (pm_node_t *) pm_implicit_rest_node_create(parser, &parser->previous);
|
||||||
pm_node_list_append(&nodes, node);
|
pm_node_list_append(&nodes, node);
|
||||||
break;
|
break;
|
||||||
|
@ -20,7 +20,7 @@ module Prism
|
|||||||
|
|
||||||
# The minor version of prism that we are expecting to find in the serialized
|
# The minor version of prism that we are expecting to find in the serialized
|
||||||
# strings.
|
# strings.
|
||||||
MINOR_VERSION = 20
|
MINOR_VERSION = 21
|
||||||
|
|
||||||
# The patch version of prism that we are expecting to find in the serialized
|
# The patch version of prism that we are expecting to find in the serialized
|
||||||
# strings.
|
# strings.
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
/**
|
/**
|
||||||
* The minor version of the Prism library as an int.
|
* The minor version of the Prism library as an int.
|
||||||
*/
|
*/
|
||||||
#define PRISM_VERSION_MINOR 20
|
#define PRISM_VERSION_MINOR 21
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The patch version of the Prism library as an int.
|
* The patch version of the Prism library as an int.
|
||||||
@ -24,6 +24,6 @@
|
|||||||
/**
|
/**
|
||||||
* The version of the Prism library as a constant string.
|
* The version of the Prism library as a constant string.
|
||||||
*/
|
*/
|
||||||
#define PRISM_VERSION "0.20.0"
|
#define PRISM_VERSION "0.21.0"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -88,6 +88,10 @@ foo => bar, *baz, qux
|
|||||||
foo => bar, baz, *qux
|
foo => bar, baz, *qux
|
||||||
foo => *bar, baz, *qux
|
foo => *bar, baz, *qux
|
||||||
|
|
||||||
|
foo => bar,
|
||||||
|
|
||||||
|
; # end the previous pattern for ParseTest#test_filepath_patterns.txt which parses the whole file at once
|
||||||
|
|
||||||
foo => []
|
foo => []
|
||||||
foo => [[[[[]]]]]
|
foo => [[[[[]]]]]
|
||||||
|
|
||||||
@ -124,6 +128,10 @@ foo in __LINE__
|
|||||||
foo in __ENCODING__
|
foo in __ENCODING__
|
||||||
foo in -> { bar }
|
foo in -> { bar }
|
||||||
|
|
||||||
|
foo in bar,
|
||||||
|
|
||||||
|
; # end the previous pattern for ParseTest#test_filepath_patterns.txt which parses the whole file at once
|
||||||
|
|
||||||
case foo; in bar then end
|
case foo; in bar then end
|
||||||
case foo; in 1 then end
|
case foo; in 1 then end
|
||||||
case foo; in 1.0 then end
|
case foo; in 1.0 then end
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user