Skip to content

Commit e941116

Browse files
committed
[GR-45043] Integrate YARP parser [Part 1]
PullRequest: truffleruby/3888
2 parents 6707372 + c862867 commit e941116

File tree

85 files changed

+3493
-375
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+3493
-375
lines changed

mx.truffleruby/suite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@
206206
"org.yarp.libyarp": {
207207
"class": "YARPNativeProject",
208208
"dir": "src/main/c/yarp",
209-
"makeTarget": "all-no-debug", # Comment this out to build with asserts and no optimizations
209+
# "makeTarget": "all-no-debug", # Can use this to build without asserts
210210
"results": ["build/librubyparser.a"],
211211
"description": "YARP used as a static library"
212212
},

spec/ruby/language/alias_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ def self.klass_method; 7; end
5252
@obj.a.should == 5
5353
end
5454

55+
it "works with an interpolated symbol with non-literal embedded expression on the left-hand side" do
56+
@meta.class_eval do
57+
eval %Q{
58+
alias :"#{'a' + ''.to_s}" value
59+
}
60+
end
61+
@obj.a.should == 5
62+
end
63+
5564
it "works with a simple symbol on the right-hand side" do
5665
@meta.class_eval do
5766
alias a :value
@@ -80,6 +89,15 @@ def self.klass_method; 7; end
8089
@obj.a.should == 5
8190
end
8291

92+
it "works with an interpolated symbol with non-literal embedded expression on the right-hand side" do
93+
@meta.class_eval do
94+
eval %Q{
95+
alias a :"#{'value' + ''.to_s}"
96+
}
97+
end
98+
@obj.a.should == 5
99+
end
100+
83101
it "adds the new method to the list of methods" do
84102
original_methods = @obj.methods
85103
@meta.class_eval do

spec/ruby/language/undef_spec.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,19 @@ def meth(o); o; end
3838
-> { @obj.meth(5) }.should raise_error(NoMethodError)
3939
end
4040

41-
it "with a interpolated symbol" do
41+
it "with an interpolated symbol" do
4242
@undef_class.class_eval do
4343
undef :"#{'meth'}"
4444
end
4545
-> { @obj.meth(5) }.should raise_error(NoMethodError)
4646
end
47+
48+
it "with an interpolated symbol when interpolated expression is not a String literal" do
49+
@undef_class.class_eval do
50+
undef :"#{'meth'.to_sym.to_s}"
51+
end
52+
-> { @obj.meth(5) }.should raise_error(NoMethodError)
53+
end
4754
end
4855

4956
it "allows undefining multiple methods at a time" do

spec/tags/truffle/parsing/parsing_tags.txt

Lines changed: 316 additions & 0 deletions
Large diffs are not rendered by default.

spec/truffle/parsing/fixtures/aliases/with_dynamic_symbols.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,14 @@ ast: |
77
ModuleNodes$AliasKeywordNode
88
attributes:
99
flags = 1
10-
newName = :a
11-
oldName = :b
10+
children:
11+
newName =
12+
ObjectLiteralNode
13+
attributes:
14+
flags = 0
15+
object = :a
16+
oldName =
17+
ObjectLiteralNode
18+
attributes:
19+
flags = 0
20+
object = :b
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
subject: "Alias"
2+
description: "alias (dynamic) Symbols with interpolation when expressions are arbitrary (not Strings)"
3+
focused_on_node: "org.truffleruby.core.module.ModuleNodes$AliasKeywordNode"
4+
ruby: |
5+
alias :"a" :"ab#{ 42 }cd"
6+
ast: |
7+
ModuleNodes$AliasKeywordNode
8+
attributes:
9+
flags = 1
10+
children:
11+
newName =
12+
ObjectLiteralNode
13+
attributes:
14+
flags = 0
15+
object = :a
16+
oldName =
17+
StringToSymbolNodeGen
18+
attributes:
19+
flags = 0
20+
children:
21+
stringNode_ =
22+
InterpolatedStringNode
23+
attributes:
24+
emptyTString = ""
25+
encoding = UTF-8
26+
flags = 0
27+
children:
28+
children = [
29+
ToSNodeGen
30+
children:
31+
valueNode_ =
32+
StringLiteralNode
33+
attributes:
34+
encoding = UTF-8
35+
flags = 0
36+
tstring = ab
37+
ToSNodeGen
38+
children:
39+
valueNode_ =
40+
IntegerFixnumLiteralNode
41+
attributes:
42+
flags = 0
43+
value = 42
44+
ToSNodeGen
45+
children:
46+
valueNode_ =
47+
StringLiteralNode
48+
attributes:
49+
encoding = UTF-8
50+
flags = 0
51+
tstring = cd
52+
]

spec/truffle/parsing/fixtures/aliases/with_keywords.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,14 @@ ast: |
77
ModuleNodes$AliasKeywordNode
88
attributes:
99
flags = 1
10-
newName = :a
11-
oldName = :b
10+
children:
11+
newName =
12+
ObjectLiteralNode
13+
attributes:
14+
flags = 0
15+
object = :a
16+
oldName =
17+
ObjectLiteralNode
18+
attributes:
19+
flags = 0
20+
object = :b

spec/truffle/parsing/fixtures/aliases/with_symbols.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,14 @@ ast: |
77
ModuleNodes$AliasKeywordNode
88
attributes:
99
flags = 1
10-
newName = :a
11-
oldName = :b
10+
children:
11+
newName =
12+
ObjectLiteralNode
13+
attributes:
14+
flags = 0
15+
object = :a
16+
oldName =
17+
ObjectLiteralNode
18+
attributes:
19+
flags = 0
20+
object = :b
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
subject: "Array"
2+
description: "%I String array literal"
3+
focused_on_node: "org.truffleruby.core.array.ArrayLiteralNode$UninitialisedArrayLiteralNode"
4+
ruby: |
5+
%I{foo bar}
6+
ast: |
7+
ArrayLiteralNode$UninitialisedArrayLiteralNode
8+
attributes:
9+
flags = 1
10+
language = org.truffleruby.RubyLanguage@...
11+
children:
12+
values = [
13+
ObjectLiteralNode
14+
attributes:
15+
flags = 0
16+
object = :foo
17+
ObjectLiteralNode
18+
attributes:
19+
flags = 0
20+
object = :bar
21+
]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
subject: "Array"
2+
description: "%W String array literal"
3+
focused_on_node: "org.truffleruby.core.array.ArrayLiteralNode$UninitialisedArrayLiteralNode"
4+
ruby: |
5+
%W{foo bar}
6+
ast: |
7+
ArrayLiteralNode$UninitialisedArrayLiteralNode
8+
attributes:
9+
flags = 1
10+
language = org.truffleruby.RubyLanguage@...
11+
children:
12+
values = [
13+
StringLiteralNode
14+
attributes:
15+
encoding = UTF-8
16+
flags = 0
17+
tstring = foo
18+
StringLiteralNode
19+
attributes:
20+
encoding = UTF-8
21+
flags = 0
22+
tstring = bar
23+
]

0 commit comments

Comments
 (0)