Skip to content

Commit

Permalink
[GR-45043] Import Prism (~0.29.0)
Browse files Browse the repository at this point in the history
PullRequest: truffleruby/4280
  • Loading branch information
andrykonchin committed May 31, 2024
2 parents d1ed116 + fe8756e commit 1175496
Show file tree
Hide file tree
Showing 57 changed files with 3,051 additions and 3,425 deletions.
2 changes: 1 addition & 1 deletion spec/ruby/language/case_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def test(v)
:bar
end
RUBY
}.should complain(/warning: duplicated .when' clause with line \d+ is ignored/, verbose: true)
}.should complain(/warning: (duplicated .when' clause with line \d+ is ignored|'when' clause on line \d+ duplicates 'when' clause on line \d+ and is ignored)/, verbose: true)
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/language/pattern_matching_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
true
end
RUBY
}.should raise_error(SyntaxError, /unexpected|expected a delimiter after the predicates of a `when` clause/)
}.should raise_error(SyntaxError, /unexpected|expected a delimiter after the patterns of an `in` clause/)
end

it "evaluates the case expression once for multiple patterns, caching the result" do
Expand Down
1 change: 0 additions & 1 deletion spec/tags/language/constants_tags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ fails:top-level constant lookup on a class does not search Object after searchin
fails:Module#private_constant marked constants sends #const_missing to the original class or module
fails:Literal (A::X) constant resolution uses the module or class #name to craft the error message
fails:Literal (A::X) constant resolution uses the module or class #inspect to craft the error message if they are anonymous
fails:Literal (A::X) constant resolution with dynamically assigned constants evaluates left-to-right
1 change: 0 additions & 1 deletion spec/tags/language/defined_tags.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
fails:The defined? keyword for a scoped constant returns nil when a constant is defined on top-level but not on the class
fails:The defined? keyword when called with a method name in a void context warns about the void context when parsing it
fails:The defined? keyword for an expression &&= returns 'expression' for assigning a fully qualified constant with '&&='
fails:The defined? keyword for an expression ||= returns 'expression' for assigning a fully qualified constant with '||='
9 changes: 0 additions & 9 deletions spec/tags/language/hash_tags.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,2 @@
fails:The ** operator makes a caller-side copy when calling a method taking a positional Hash
fails:Hash literal checks duplicated keys on initialization
fails:Hash literal checks duplicated float keys on initialization
fails(https://github.com/ruby/prism/issues/2005):Hash literal expands an '**{}' or '**obj' element with the last key/value pair taking precedence
fails(https://github.com/ruby/prism/issues/2005):Hash literal expands an '**{}' and warns when finding an additional duplicate key afterwards
fails(https://github.com/ruby/prism/issues/2005):Hash literal merges multiple nested '**obj' in Hash literals
fails(https://github.com/ruby/prism/issues/2129):Hash literal raises an EncodingError at parse time when Symbol key with invalid bytes
fails(https://github.com/ruby/prism/issues/2129):Hash literal raises an EncodingError at parse time when Symbol key with invalid bytes and 'key: value' syntax used
fails:The ** operator makes a copy when calling a method taking a positional Hash
fails:Hash literal raises a SyntaxError at parse time when Symbol key with invalid bytes
fails:Hash literal raises a SyntaxError at parse time when Symbol key with invalid bytes and 'key: value' syntax used
2 changes: 0 additions & 2 deletions spec/tags/language/pattern_matching_tags.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
fails:Pattern matching alternative pattern does not support variable binding
fails:Pattern matching Array pattern calls #deconstruct once for multiple patterns, caching the result
fails:Pattern matching warning when one-line form warns about pattern matching is experimental feature
fails:Pattern matching variable pattern does not support using variable name (except _) several times
fails:Pattern matching Hash pattern raise SyntaxError when keys duplicate in pattern
1 change: 0 additions & 1 deletion spec/tags/language/rescue_tags.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
fails:The rescue keyword raises SyntaxError when else is used without rescue and ensure
fails(cause not set):The rescue keyword suppresses exception from block when raises one from rescue expression
2 changes: 0 additions & 2 deletions spec/tags/language/symbol_tags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
slow:A Symbol literal inherits the encoding of the magic comment and can have a binary encoding
fails(https://github.com/ruby/prism/issues/2129):A Symbol literal raises an EncodingError at parse time when Symbol with invalid bytes
fails:A Symbol literal raises an SyntaxError at parse time when Symbol with invalid bytes
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ ast: |
flags = 0
sourceCharIndex = -1
sourceLength = 0
value = 314
value = 157
IntegerFixnumLiteralNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
value = 100
value = 50
]
receiver =
ReadConstantNode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ ast: |
IntegerFixnumLiteralNode
attributes:
flags = 0
sourceCharIndex = 0
sourceLength = 2
sourceCharIndex = -1
sourceLength = 0
value = 42
IntegerFixnumLiteralNode
attributes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ ast: |
attributes:
flags = 0
object = 18446744073709551617
sourceCharIndex = 0
sourceLength = 20
sourceCharIndex = -1
sourceLength = 0
IntegerFixnumLiteralNode
attributes:
flags = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ ast: |
flags = 0
sourceCharIndex = -1
sourceLength = 0
value = 42100500
value = 84201
IntegerFixnumLiteralNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
value = 1000000
value = 2000
]
receiver =
ReadConstantNode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ ast: |
flags = 0
sourceCharIndex = -1
sourceLength = 0
value = 42100500
value = 84201
IntegerFixnumLiteralNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
value = 1000000
value = 20000
]
receiver =
ReadConstantNode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ subject: "Rational number"
description: "with Integer value"
notes: >
Rational literal with Integer value is represented by `Rational.convert(Integer, 1)`.
Integer value is represented by LongFixnumLiteralNode.
Integer value is represented by IntegerFixnumLiteralNode.
focused_on_node: "org.truffleruby.language.dispatch.RubyCallNode"
ruby: |
42r
Expand All @@ -28,8 +28,8 @@ ast: |
IntegerFixnumLiteralNode
attributes:
flags = 0
sourceCharIndex = 0
sourceLength = 2
sourceCharIndex = -1
sourceLength = 0
value = 42
IntegerFixnumLiteralNode
attributes:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
subject: "Integer"
description: "with Long value (> 32 bits)"
notes: >
Rational literal with Integer value is represented by `Rational.convert(Integer, 1)`.
Long value is represented by LongFixnumLiteralNode.
focused_on_node: "org.truffleruby.language.dispatch.RubyCallNode"
ruby: |
2147483648r
ast: |
RubyCallNode
attributes:
descriptor = NoKeywordArgumentsDescriptor
dispatchConfig = PRIVATE
emptyKeywordsProfile = false
flags = 1
isAttrAssign = false
isSafeNavigation = false
isSplatted = false
isVCall = false
lastArgIsNotHashProfile = false
methodName = "convert"
notEmptyKeywordsProfile = false
notRuby2KeywordsHashProfile = false
sourceCharIndex = 0
sourceLength = 11
children:
arguments = [
LongFixnumLiteralNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
value = 2147483648
IntegerFixnumLiteralNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
value = 1
]
receiver =
ReadConstantNode
attributes:
flags = 0
name = "Rational"
sourceCharIndex = -1
sourceLength = 0
children:
moduleNode =
ObjectClassLiteralNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ ast: |
IntegerFixnumLiteralNode
attributes:
flags = 0
sourceCharIndex = 0
sourceLength = 3
sourceCharIndex = -1
sourceLength = 0
value = -42
IntegerFixnumLiteralNode
attributes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ ast: |
IntegerFixnumLiteralNode
attributes:
flags = 0
sourceCharIndex = 23
sourceLength = 2
sourceCharIndex = -1
sourceLength = 0
value = 42
IntegerFixnumLiteralNode
attributes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ ast: |
IntegerFixnumLiteralNode
attributes:
flags = 0
sourceCharIndex = 13
sourceLength = 2
sourceCharIndex = -1
sourceLength = 0
value = 42
IntegerFixnumLiteralNode
attributes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ ast: |
ToSNodeGen
children:
valueNode_ =
StringLiteralNode
FrozenStringLiteralNode
attributes:
encoding = UTF-8
definition = "expression" (ASCII-8BIT)
flags = 0
frozenString = "123" (UTF-8)
sourceCharIndex = 6
sourceLength = 7
tstring = 123
ToSNodeGen
children:
valueNode_ =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ ast: |
ToSNodeGen
children:
valueNode_ =
StringLiteralNode
FrozenStringLiteralNode
attributes:
encoding = UTF-8
definition = "expression" (ASCII-8BIT)
flags = 0
frozenString = "123" (UTF-8)
sourceCharIndex = 6
sourceLength = 5
tstring = 123
ToSNodeGen
children:
valueNode_ =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ ast: |
ToSNodeGen
children:
valueNode_ =
StringLiteralNode
FrozenStringLiteralNode
attributes:
encoding = UTF-8
definition = "expression" (ASCII-8BIT)
flags = 0
frozenString = "123" (UTF-8)
sourceCharIndex = 7
sourceLength = 7
tstring = 123
ToSNodeGen
children:
valueNode_ =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ ast: |
ToSNodeGen
children:
valueNode_ =
StringLiteralNode
FrozenStringLiteralNode
attributes:
encoding = UTF-8
definition = "expression" (ASCII-8BIT)
flags = 0
frozenString = "123" (UTF-8)
sourceCharIndex = 7
sourceLength = 5
tstring = 123
ToSNodeGen
children:
valueNode_ =
Expand Down
11 changes: 0 additions & 11 deletions src/main/c/yarp/include/prism.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,17 +219,6 @@ PRISM_EXPORTED_FUNCTION const char * pm_token_type_name(pm_token_type_t token_ty
*/
const char * pm_token_type_human(pm_token_type_t token_type);

/**
* Format the errors on the parser into the given buffer.
*
* @param parser The parser to format the errors for.
* @param error_list The list of errors to format.
* @param buffer The buffer to format the errors into.
* @param colorize Whether or not to colorize the errors with ANSI escape sequences.
* @param inline_messages Whether or not to inline the messages with the source.
*/
PRISM_EXPORTED_FUNCTION void pm_parser_errors_format(const pm_parser_t *parser, const pm_list_t *error_list, pm_buffer_t *buffer, bool colorize, bool inline_messages);

// We optionally support dumping to JSON. For systems that don't want or need
// this functionality, it can be turned off with the PRISM_EXCLUDE_JSON define.
#ifndef PRISM_EXCLUDE_JSON
Expand Down
Loading

0 comments on commit 1175496

Please sign in to comment.