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

Commit 4b33f7e

Browse files
author
Juanjo Alvarez
committed
Fix None nodes having <nil> token
1 parent 7a8c4c0 commit 4b33f7e

File tree

8 files changed

+91
-42
lines changed

8 files changed

+91
-42
lines changed

driver/normalizer/tonode.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,52 @@ var ToNode = &uast.ObjectToNode{
7171
"While": "while",
7272
"With": "with",
7373
"Yield": "yield",
74+
"Add": "+",
75+
"Assert": "assert",
76+
"AugAssign": "?=",
77+
"BitAnd": "&",
78+
"BitOr": "|",
79+
"BitXor": "^",
80+
"Break": "break",
81+
"Continue": "continue",
82+
"Delete": "delete",
83+
"Div": "/",
84+
"Ellipsis": "...",
85+
"Eq": "==",
86+
"False": "false",
87+
"For": "for",
88+
"FloorDiv": "//",
89+
"Global": "global",
90+
"Gt": ">",
91+
"GtE": ">=",
92+
"If": "if",
93+
"In": "in",
94+
"Invert": "~",
95+
"Is": "is",
96+
"IsNot": "not is",
97+
"LShift": "<<",
98+
"Lt": "<",
99+
"LtE": "<=",
100+
"Mod": "%%",
101+
"Mult": "*",
102+
"NoneLiteral": "None",
103+
"Nonlocal": "nonlocal",
104+
"Not": "!",
105+
"NotEq": "!=",
106+
"NotIn": "not in",
107+
"Pass": "pass",
108+
"Pow": "**",
109+
"Print": "print",
110+
"Raise": "raise",
111+
"Return": "return",
112+
"RShift": ">>",
113+
"Sub": "-",
114+
"True": "true",
115+
"UAdd": "+",
116+
"USub": "-",
117+
"While": "while",
118+
"With": "with",
119+
"Yield": "yield",
74120
},
75121
PromoteAllPropertyLists: false,
76122
PromotedPropertyLists: map[string]map[string]bool{

fixtures/functiondef_defaultparams.py.native

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"s": "polompos"
7474
},
7575
{
76-
"LiteralValue": null,
76+
"LiteralValue": "None",
7777
"ast_type": "NoneLiteral",
7878
"col_offset": 56,
7979
"end_col_offset": 59,

fixtures/functiondef_defaultparams.py.uast

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Status: ok
22
Errors:
33
UAST:
44
Module {
5-
. Roles: File,Module
5+
. Roles: File
66
. Children: {
77
. . 0: FunctionDef {
88
. . . Roles: Function,Declaration,Name,Identifier
@@ -23,7 +23,7 @@ Module {
2323
. . . }
2424
. . . Children: {
2525
. . . . 0: arguments {
26-
. . . . . Roles: Function,Declaration,Incomplete,Argument
26+
. . . . . Roles: Function,Declaration,Argument,Name,Identifier
2727
. . . . . Properties: {
2828
. . . . . . internalRole: args
2929
. . . . . . kwarg: <nil>
@@ -127,7 +127,7 @@ Module {
127127
. . . . . . . }
128128
. . . . . . . Children: {
129129
. . . . . . . . 0: Num {
130-
. . . . . . . . . Roles: Literal,Number,Expression,Primitive
130+
. . . . . . . . . Roles: Literal,Number,Expression
131131
. . . . . . . . . TOKEN "1"
132132
. . . . . . . . . StartPosition: {
133133
. . . . . . . . . . Offset: 30
@@ -141,7 +141,7 @@ Module {
141141
. . . . . . . . . }
142142
. . . . . . . . }
143143
. . . . . . . . 1: Str {
144-
. . . . . . . . . Roles: Literal,String,Expression,Primitive
144+
. . . . . . . . . Roles: Literal,String,Expression
145145
. . . . . . . . . TOKEN "polompos"
146146
. . . . . . . . . StartPosition: {
147147
. . . . . . . . . . Offset: 38
@@ -155,7 +155,7 @@ Module {
155155
. . . . . . . . . }
156156
. . . . . . . . }
157157
. . . . . . . . 2: NoneLiteral {
158-
. . . . . . . . . Roles: Literal,Null,Expression,Primitive
158+
. . . . . . . . . Roles: Literal,Null,Expression
159159
. . . . . . . . . TOKEN "<nil>"
160160
. . . . . . . . . StartPosition: {
161161
. . . . . . . . . . Offset: 55
@@ -218,14 +218,14 @@ Module {
218218
. . . }
219219
. . . Children: {
220220
. . . . 0: arguments {
221-
. . . . . Roles: Function,Declaration,Incomplete,Argument
221+
. . . . . Roles: Function,Declaration,Argument,Name,Identifier
222222
. . . . . Properties: {
223223
. . . . . . internalRole: args
224224
. . . . . . kwarg: <nil>
225225
. . . . . }
226226
. . . . . Children: {
227227
. . . . . . 0: Num {
228-
. . . . . . . Roles: Literal,Number,Expression,Primitive
228+
. . . . . . . Roles: Literal,Number,Expression
229229
. . . . . . . TOKEN "3"
230230
. . . . . . . StartPosition: {
231231
. . . . . . . . Offset: 92
@@ -306,3 +306,4 @@ Module {
306306
. }
307307
}
308308

309+

fixtures/issue58.py.native

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"n": 0
5252
},
5353
{
54-
"LiteralValue": null,
54+
"LiteralValue": "None",
5555
"ast_type": "NoneLiteral",
5656
"col_offset": 11,
5757
"end_col_offset": 14,

fixtures/issue58.py.uast

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Status: ok
22
Errors:
33
UAST:
44
Module {
5-
. Roles: File,Module
5+
. Roles: File
66
. Children: {
77
. . 0: Assign {
88
. . . Roles: Binary,Assignment,Expression
@@ -16,7 +16,7 @@ Module {
1616
. . . }
1717
. . . Children: {
1818
. . . . 0: Tuple {
19-
. . . . . Roles: Literal,Tuple,Expression,Primitive,Left
19+
. . . . . Roles: Literal,Tuple,Expression,Left
2020
. . . . . StartPosition: {
2121
. . . . . . Offset: 0
2222
. . . . . . Line: 1
@@ -66,7 +66,7 @@ Module {
6666
. . . . . }
6767
. . . . }
6868
. . . . 1: Tuple {
69-
. . . . . Roles: Literal,Tuple,Expression,Primitive,Right
69+
. . . . . Roles: Literal,Tuple,Expression,Right
7070
. . . . . StartPosition: {
7171
. . . . . . Offset: 7
7272
. . . . . . Line: 1
@@ -78,7 +78,7 @@ Module {
7878
. . . . . }
7979
. . . . . Children: {
8080
. . . . . . 0: Num {
81-
. . . . . . . Roles: Literal,Number,Expression,Primitive
81+
. . . . . . . Roles: Literal,Number,Expression
8282
. . . . . . . TOKEN "0"
8383
. . . . . . . StartPosition: {
8484
. . . . . . . . Offset: 7
@@ -95,7 +95,7 @@ Module {
9595
. . . . . . . }
9696
. . . . . . }
9797
. . . . . . 1: NoneLiteral {
98-
. . . . . . . Roles: Literal,Null,Expression,Primitive
98+
. . . . . . . Roles: Literal,Null,Expression
9999
. . . . . . . TOKEN "<nil>"
100100
. . . . . . . StartPosition: {
101101
. . . . . . . . Offset: 10
@@ -119,3 +119,4 @@ Module {
119119
. }
120120
}
121121

122+

fixtures/literals_assign.py.native

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
}
126126
],
127127
"value": {
128-
"LiteralValue": null,
128+
"LiteralValue": "None",
129129
"ast_type": "NoneLiteral",
130130
"col_offset": 5,
131131
"end_col_offset": 8,

0 commit comments

Comments
 (0)