Skip to content

Commit 70ce5c1

Browse files
committed
sem: don't map parenthesis of literals; fix bblfsh#56
Parenthisized literals result in this information saved in 'extra' field. Signed-off-by: Alexander Bezzubov <[email protected]>
1 parent ec04b0c commit 70ce5c1

File tree

5 files changed

+1306
-6
lines changed

5 files changed

+1306
-6
lines changed

driver/normalizer/normalizer.go

+12-6
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@ var Preprocessors = []Mapping{
3737
Part("_", Obj{
3838
uast.KeyType: String("StringLiteral"),
3939
"value": AnyNode(nil),
40-
"extra": Obj{
41-
"raw": Var("raw"),
42-
"rawValue": AnyNode(nil),
40+
"extra": Fields{
41+
{Name: "raw", Op: Var("raw")},
42+
{Name: "rawValue", Op: Any()},
43+
//FIXME(bzz): map parenthesis
44+
{Name: "parenthesized", Drop: true, Op: Any()},
45+
{Name: "parenStart", Drop: true, Op: Any()},
4346
},
4447
}),
4548
Part("_", Obj{
@@ -50,8 +53,11 @@ var Preprocessors = []Mapping{
5053
Map(
5154
Part("_", Obj{
5255
uast.KeyType: String("RegExpLiteral"),
53-
"extra": Obj{
54-
"raw": Var("raw"),
56+
"extra": Fields{
57+
{Name: "raw", Op: Var("raw")},
58+
//FIXME(bzz): map parenthesis
59+
{Name: "parenthesized", Drop: true, Op: Any()},
60+
{Name: "parenStart", Drop: true, Op: Any()},
5561
},
5662
}),
5763
Part("_", Obj{
@@ -61,7 +67,7 @@ var Preprocessors = []Mapping{
6167
),
6268
// drop extra info for other nodes (it duplicates other node fields)
6369
Map(
64-
Part("_", Obj{"extra": AnyNode(nil)}),
70+
Part("_", Obj{"extra": Any()}),
6571
Part("_", Obj{}),
6672
),
6773
// FIXME(bzz): make sure such comments are mapped properly

fixtures/issue56.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
this._dayOfMonthOrdinalParseLenient = new RegExp(
2+
(this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
3+
'|' + (/\d{1,2}/).source);

0 commit comments

Comments
 (0)