Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit a28480f

Browse files
author
Juanjo Alvarez
committed
Added Binary(ish) role to the Boolean operators, move Comprehensions incomplete to the inner node
1 parent b3950cb commit a28480f

File tree

7 files changed

+30
-30
lines changed

7 files changed

+30
-30
lines changed

ANNOTATION.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='BitOr'\] | Binary, Operator, Bitwise, Or |
3030
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='BitXor'\] | Binary, Operator, Bitwise, Xor |
3131
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='BitAnd'\] | Binary, Operator, Bitwise, And |
32-
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='And'\] | Operator, Boolean, And |
33-
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='Or'\] | Operator, Boolean, Or |
34-
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='Not'\] | Operator, Boolean, Not |
35-
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='UnaryOp'\] | Operator, Unary, Expression |
32+
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='And'\] | Binary, Operator, Boolean, And |
33+
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='Or'\] | Binary, Operator, Boolean, Or |
34+
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='Not'\] | Binary, Operator, Boolean, Not |
35+
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='UnaryOp'\] | Binary, Operator, Unary, Expression |
3636
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='Invert'\] | Operator, Unary, Bitwise, Not |
3737
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='UAdd'\] | Operator, Unary, Positive |
3838
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='USub'\] | Operator, Unary, Negative |
@@ -160,10 +160,10 @@
160160
| /self::\*\[@InternalType='Module'\]//\*\[@internalRole\]\[@internalRole='annotation'\] | Comment, Incomplete |
161161
| /self::\*\[@InternalType='Module'\]//\*\[@internalRole\]\[@internalRole='returns'\] | Comment, Incomplete |
162162
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='Ellipsis'\] | Identifier, Incomplete |
163-
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='ListComp'\] | List, For, Expression, Incomplete |
164-
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='DictComp'\] | Map, For, Expression, Incomplete |
165-
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='SetComp'\] | Set, For, Expression, Incomplete |
166-
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='comprehension'\] | For, Iterator, Expression |
163+
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='ListComp'\] | List, For, Expression |
164+
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='DictComp'\] | Map, For, Expression |
165+
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='SetComp'\] | Set, For, Expression |
166+
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='comprehension'\] | For, Iterator, Expression, Incomplete |
167167
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='comprehension'\]/\*\[@internalRole\]\[@internalRole='iter'\] | For, Update, Statement |
168168
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='comprehension'\]/\*\[@internalRole\]\[@internalRole='target'\] | For, Expression |
169169
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='comprehension'\]/\*\[@InternalType='Compare'\] | If, Condition, Expression, Binary |

driver/normalizer/annotation.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ var AnnotationRules = On(Any).Self(
8282
// Not applying the "Binary" role since even while in the Python code
8383
// boolean operators use (seemingly binary) infix notation, the generated
8484
// AST nodes use prefix.
85-
On(pyast.And).Roles(uast.Operator, uast.Boolean, uast.And),
86-
On(pyast.Or).Roles(uast.Operator, uast.Boolean, uast.Or),
87-
On(pyast.Not).Roles(uast.Operator, uast.Boolean, uast.Not),
88-
On(pyast.UnaryOp).Roles(uast.Operator, uast.Unary, uast.Expression),
85+
On(pyast.And).Roles(uast.Binary, uast.Operator, uast.Boolean, uast.And),
86+
On(pyast.Or).Roles(uast.Binary, uast.Operator, uast.Boolean, uast.Or),
87+
On(pyast.Not).Roles(uast.Binary, uast.Operator, uast.Boolean, uast.Not),
88+
On(pyast.UnaryOp).Roles(uast.Binary, uast.Operator, uast.Unary, uast.Expression),
8989

9090
// Unary operators
9191
On(pyast.Invert).Roles(uast.Operator, uast.Unary, uast.Bitwise, uast.Not),
@@ -300,10 +300,10 @@ var AnnotationRules = On(Any).Self(
300300
// uast.List/uast.Map/uast.Set comprehensions. We map the "for x in y" to uast.For, uast.Iterator (foreach)
301301
// roles and the "if something" to uast.If* roles. FIXME: missing the top comprehension
302302
// roles in the UAST, change once they've been merged
303-
On(pyast.ListComp).Roles(uast.List, uast.For, uast.Expression, uast.Incomplete),
304-
On(pyast.DictComp).Roles(uast.Map, uast.For, uast.Expression, uast.Incomplete),
305-
On(pyast.SetComp).Roles(uast.Set, uast.For, uast.Expression, uast.Incomplete),
306-
On(pyast.Comprehension).Roles(uast.For, uast.Iterator, uast.Expression).Children(
303+
On(pyast.ListComp).Roles(uast.List, uast.For, uast.Expression),
304+
On(pyast.DictComp).Roles(uast.Map, uast.For, uast.Expression),
305+
On(pyast.SetComp).Roles(uast.Set, uast.For, uast.Expression),
306+
On(pyast.Comprehension).Roles(uast.For, uast.Iterator, uast.Expression, uast.Incomplete).Children(
307307
On(HasInternalRole("iter")).Roles(uast.For, uast.Update, uast.Statement),
308308
On(HasInternalRole("target")).Roles(uast.For, uast.Expression),
309309
// FIXME: see the comment on uast.If, uast.Condition above

tests/comparisonop.py.uast

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ Module {
170170
. . . }
171171
. . . Children: {
172172
. . . . 0: UnaryOp {
173-
. . . . . Roles: Operator,Unary,Expression
173+
. . . . . Roles: Binary,Operator,Unary,Expression
174174
. . . . . StartPosition: {
175175
. . . . . . Offset: 14
176176
. . . . . . Line: 3
@@ -198,7 +198,7 @@ Module {
198198
. . . . . . . }
199199
. . . . . . }
200200
. . . . . . 1: Not {
201-
. . . . . . . Roles: Operator,Boolean,Not
201+
. . . . . . . Roles: Binary,Operator,Boolean,Not
202202
. . . . . . . TOKEN "!"
203203
. . . . . . . Properties: {
204204
. . . . . . . . internalRole: op

tests/comprehension_dict.py.uast

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Module {
1616
. . . }
1717
. . . Children: {
1818
. . . . 0: DictComp {
19-
. . . . . Roles: Map,For,Expression,Incomplete
19+
. . . . . Roles: Map,For,Expression
2020
. . . . . StartPosition: {
2121
. . . . . . Offset: 0
2222
. . . . . . Line: 1
@@ -27,7 +27,7 @@ Module {
2727
. . . . . }
2828
. . . . . Children: {
2929
. . . . . . 0: comprehension {
30-
. . . . . . . Roles: For,Iterator,Expression
30+
. . . . . . . Roles: For,Iterator,Expression,Incomplete
3131
. . . . . . . Properties: {
3232
. . . . . . . . internalRole: generators
3333
. . . . . . . . is_async: 0

tests/comprehension_list.py.uast

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Module {
1616
. . . }
1717
. . . Children: {
1818
. . . . 0: ListComp {
19-
. . . . . Roles: List,For,Expression,Incomplete
19+
. . . . . Roles: List,For,Expression
2020
. . . . . StartPosition: {
2121
. . . . . . Offset: 1
2222
. . . . . . Line: 1
@@ -82,7 +82,7 @@ Module {
8282
. . . . . . . }
8383
. . . . . . }
8484
. . . . . . 1: comprehension {
85-
. . . . . . . Roles: For,Iterator,Expression
85+
. . . . . . . Roles: For,Iterator,Expression,Incomplete
8686
. . . . . . . Properties: {
8787
. . . . . . . . internalRole: generators
8888
. . . . . . . . is_async: 0
@@ -207,7 +207,7 @@ Module {
207207
. . . }
208208
. . . Children: {
209209
. . . . 0: ListComp {
210-
. . . . . Roles: List,For,Expression,Incomplete
210+
. . . . . Roles: List,For,Expression
211211
. . . . . StartPosition: {
212212
. . . . . . Offset: 32
213213
. . . . . . Line: 2
@@ -273,7 +273,7 @@ Module {
273273
. . . . . . . }
274274
. . . . . . }
275275
. . . . . . 1: comprehension {
276-
. . . . . . . Roles: For,Iterator,Expression
276+
. . . . . . . Roles: For,Iterator,Expression,Incomplete
277277
. . . . . . . Properties: {
278278
. . . . . . . . internalRole: generators
279279
. . . . . . . . is_async: 0
@@ -318,7 +318,7 @@ Module {
318318
. . . . . . . }
319319
. . . . . . }
320320
. . . . . . 2: comprehension {
321-
. . . . . . . Roles: For,Iterator,Expression
321+
. . . . . . . Roles: For,Iterator,Expression,Incomplete
322322
. . . . . . . Properties: {
323323
. . . . . . . . internalRole: generators
324324
. . . . . . . . is_async: 0

tests/comprehension_set.py.uast

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Module {
1616
. . . }
1717
. . . Children: {
1818
. . . . 0: SetComp {
19-
. . . . . Roles: Set,For,Expression,Incomplete
19+
. . . . . Roles: Set,For,Expression
2020
. . . . . StartPosition: {
2121
. . . . . . Offset: 0
2222
. . . . . . Line: 1
@@ -82,7 +82,7 @@ Module {
8282
. . . . . . . }
8383
. . . . . . }
8484
. . . . . . 1: comprehension {
85-
. . . . . . . Roles: For,Iterator,Expression
85+
. . . . . . . Roles: For,Iterator,Expression,Incomplete
8686
. . . . . . . Properties: {
8787
. . . . . . . . internalRole: generators
8888
. . . . . . . . is_async: 0

tests/unary.py.uast

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Module {
1616
. . . }
1717
. . . Children: {
1818
. . . . 0: UnaryOp {
19-
. . . . . Roles: Operator,Unary,Expression
19+
. . . . . Roles: Binary,Operator,Unary,Expression
2020
. . . . . StartPosition: {
2121
. . . . . . Offset: 0
2222
. . . . . . Line: 1
@@ -66,7 +66,7 @@ Module {
6666
. . . }
6767
. . . Children: {
6868
. . . . 0: UnaryOp {
69-
. . . . . Roles: Operator,Unary,Expression
69+
. . . . . Roles: Binary,Operator,Unary,Expression
7070
. . . . . StartPosition: {
7171
. . . . . . Offset: 3
7272
. . . . . . Line: 2
@@ -117,7 +117,7 @@ Module {
117117
. . . }
118118
. . . Children: {
119119
. . . . 0: UnaryOp {
120-
. . . . . Roles: Operator,Unary,Expression
120+
. . . . . Roles: Binary,Operator,Unary,Expression
121121
. . . . . StartPosition: {
122122
. . . . . . Offset: 6
123123
. . . . . . Line: 3

0 commit comments

Comments
 (0)