Skip to content

Commit

Permalink
sem: don't map parenthesis of literals; fix bblfsh#56
Browse files Browse the repository at this point in the history
Parenthisized literals result in this information saved
in 'extra' field.

Signed-off-by: Alexander Bezzubov <bzz@apache.org>
  • Loading branch information
bzz committed Mar 3, 2019
1 parent ec04b0c commit 70ce5c1
Show file tree
Hide file tree
Showing 5 changed files with 1,306 additions and 6 deletions.
18 changes: 12 additions & 6 deletions driver/normalizer/normalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ var Preprocessors = []Mapping{
Part("_", Obj{
uast.KeyType: String("StringLiteral"),
"value": AnyNode(nil),
"extra": Obj{
"raw": Var("raw"),
"rawValue": AnyNode(nil),
"extra": Fields{
{Name: "raw", Op: Var("raw")},
{Name: "rawValue", Op: Any()},
//FIXME(bzz): map parenthesis
{Name: "parenthesized", Drop: true, Op: Any()},
{Name: "parenStart", Drop: true, Op: Any()},
},
}),
Part("_", Obj{
Expand All @@ -50,8 +53,11 @@ var Preprocessors = []Mapping{
Map(
Part("_", Obj{
uast.KeyType: String("RegExpLiteral"),
"extra": Obj{
"raw": Var("raw"),
"extra": Fields{
{Name: "raw", Op: Var("raw")},
//FIXME(bzz): map parenthesis
{Name: "parenthesized", Drop: true, Op: Any()},
{Name: "parenStart", Drop: true, Op: Any()},
},
}),
Part("_", Obj{
Expand All @@ -61,7 +67,7 @@ var Preprocessors = []Mapping{
),
// drop extra info for other nodes (it duplicates other node fields)
Map(
Part("_", Obj{"extra": AnyNode(nil)}),
Part("_", Obj{"extra": Any()}),
Part("_", Obj{}),
),
// FIXME(bzz): make sure such comments are mapped properly
Expand Down
3 changes: 3 additions & 0 deletions fixtures/issue56.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
this._dayOfMonthOrdinalParseLenient = new RegExp(
(this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
'|' + (/\d{1,2}/).source);
Loading

0 comments on commit 70ce5c1

Please sign in to comment.