Skip to content

Commit fb02b94

Browse files
committed
Ensure consistent mapping of C actions to Java actions
1 parent 43ce485 commit fb02b94

File tree

7 files changed

+88
-85
lines changed

7 files changed

+88
-85
lines changed

graalpython/com.oracle.graal.python.pegparser.generator/pegjava/java_generator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def visit_Alt(self, node):
203203
types.discard("Token*") # heuristic. when tokens are in there, they are usually dropped
204204
if len(types) == 2:
205205
# might be a pair for gathering
206-
typ1, typ2 = sorted(types)
206+
typ1, typ2 = sorted(types, key=lambda x: x.count('*'))
207207
if (f"{typ1}*" == typ2 or
208208
typ2.startswith(f"asdl_{typ1.replace('_ty', '')}_seq")):
209209
types = {typ2.replace("**", "*")}
@@ -605,7 +605,7 @@ def generate(self, filename: str) -> None:
605605
if rule.left_recursive:
606606
self.print("// Left-recursive")
607607
self.visit(rule)
608-
608+
609609
self._generate_lookahead_methods()
610610
for todo in getattr(self, "_type_conversions", {}).keys():
611611
self.print(todo)

graalpython/com.oracle.graal.python.pegparser.test/testData/parser/goldenFiles/BasicTests/call09.tast

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ Module[0, 12]
33
Target: Name[0, 3] Value: "foo"
44
Args:
55
Starred[4, 11]
6+
Context: Load
67
Expr: Name[5, 11] Value: "mylist"

graalpython/com.oracle.graal.python.pegparser.test/testData/parser/goldenFiles/BasicTests/call10.tast

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Module[0, 23]
33
Target: Name[0, 3] Value: "foo"
44
Args:
55
Starred[4, 12]
6+
Context: Load
67
Expr: Name[5, 12] Value: "mylist1"
78
Starred[14, 22]
9+
Context: Load
810
Expr: Name[15, 22] Value: "mylist2"

graalpython/com.oracle.graal.python.pegparser.test/testData/parser/goldenFiles/ClassDefTests/classDef08.tast

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Module[0, 128]
2424
Target: Name[109, 113] Value: "self"
2525
Args:
2626
Starred[114, 119]
27+
Context: Load
2728
Expr: Name[115, 119] Value: "args"
2829
KWArgs:
2930
KeywordTy[121, 127]

graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/NodeFactory.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,6 @@ default ExprTy.Name createVariable(String name, int startOffset, int endOffset)
123123

124124
public ExprTy createSet(ExprTy[] values, int startOffset, int endOffset);
125125

126-
default ExprTy createStarred(ExprTy value, int startOffset, int endOffset) {
127-
return createStarred(value, null, startOffset, endOffset);
128-
}
129-
130126
public ExprTy createStarred(ExprTy value, ExprContext context, int startOffset, int endOffset);
131127

132128
public KeywordTy createKeyword(String arg, ExprTy value, int startOffset, int endOffset);

0 commit comments

Comments
 (0)