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

Commit b5e842c

Browse files
author
Juanjo Alvarez
committed
Removed the removal of # in normal UAST
Signed-off-by: Juanjo Alvarez <[email protected]>
1 parent 143f1d8 commit b5e842c

15 files changed

+129
-144
lines changed

driver/normalizer/annotation.go

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"gopkg.in/bblfsh/sdk.v2/uast/role"
66
. "gopkg.in/bblfsh/sdk.v2/uast/transformer"
77
"gopkg.in/bblfsh/sdk.v2/uast/transformer/positioner"
8-
"strings"
98
)
109

1110
var Native = Transformers([][]Transformer{
@@ -89,21 +88,6 @@ func loopAnnotate(typ string, mainRole role.Role, roles ...role.Role) Mapping {
8988
}), roles...)
9089
}
9190

92-
func uncomment_bash(s string) (string, error) {
93-
if strings.HasPrefix(s, "#") {
94-
s = s[1:]
95-
}
96-
return s, nil
97-
}
98-
99-
func comment_bash(s string) (string, error) {
100-
return "#" + s, nil
101-
}
102-
103-
func UncommentBashLike(vr string) Op {
104-
return StringConv(Var(vr), uncomment_bash, comment_bash)
105-
}
106-
10791
var Annotations = []Mapping{
10892
// FIXME: doesnt work
10993
AnnotateType("Module", nil, role.File, role.Module),
@@ -373,13 +357,13 @@ var Annotations = []Mapping{
373357
}, role.Noop),
374358

375359
AnnotateType("NoopLine", MapObj(Obj{
376-
"noop_line": UncommentBashLike("txt"),
360+
"noop_line": Var("txt"),
377361
}, Obj{
378362
uast.KeyToken: Var("txt"),
379363
}), role.Comment, role.Noop),
380364

381365
AnnotateType("NoopSameLine", MapObj(Obj{
382-
"s": UncommentBashLike("txt"),
366+
"s": Var("txt"),
383367
}, Obj{
384368
uast.KeyToken: Var("txt"),
385369
}), role.Comment, role.Noop),

driver/normalizer/normalizer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ func identifierWithPos(nameVar string) ObjectOp {
7272
})
7373
}
7474

75+
// Common for string types (Byte, Str, StrLiteral)
7576
func mapStr(nativeType string) Mapping {
7677
return Map(
7778
Part("_", Fields{

fixtures/aritmeticops.py.uast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@
426426
},
427427
lines: [
428428
{ '@type': "NoopLine",
429-
'@token': " 1@2 FIXME: matmul\n",
429+
'@token': "# 1@2 FIXME: matmul\n",
430430
'@role': [Comment, Noop],
431431
'@pos': { '@type': "uast:Positions",
432432
start: { '@type': "uast:Position",

fixtures/bench_gcd.py.uast

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
},
116116
'noop_lines': [
117117
{ '@type': "NoopSameLine",
118-
'@token': " u >= 0, v >= 0",
118+
'@token': "# u >= 0, v >= 0",
119119
'@role': [Comment, Noop],
120120
'@pos': { '@type': "uast:Positions",
121121
},
@@ -322,7 +322,7 @@
322322
},
323323
'noop_lines': [
324324
{ '@type': "NoopSameLine",
325-
'@token': " u >= v >= 0",
325+
'@token': "# u >= v >= 0",
326326
'@role': [Comment, Noop],
327327
'@pos': { '@type': "uast:Positions",
328328
},
@@ -916,7 +916,7 @@
916916
},
917917
'noop_lines': [
918918
{ '@type': "NoopSameLine",
919-
'@token': " u, v - even",
919+
'@token': "# u, v - even",
920920
'@role': [Comment, Noop],
921921
'@pos': { '@type': "uast:Positions",
922922
},

fixtures/bench_is_prime.py.uast

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@
299299
},
300300
'noop_lines': [
301301
{ '@type': "NoopSameLine",
302-
'@token': " manually test 2 and 3",
302+
'@token': "# manually test 2 and 3",
303303
'@role': [Comment, Noop],
304304
'@pos': { '@type': "uast:Positions",
305305
},
@@ -526,7 +526,7 @@
526526
},
527527
'noop_lines': [
528528
{ '@type': "NoopSameLine",
529-
'@token': " exclude multiples of 2 and 3",
529+
'@token': "# exclude multiples of 2 and 3",
530530
'@role': [Comment, Noop],
531531
'@pos': { '@type': "uast:Positions",
532532
},
@@ -1127,7 +1127,7 @@
11271127
},
11281128
'noop_lines': [
11291129
{ '@type': "NoopSameLine",
1130-
'@token': " this modifies 2 into 4 and viceversa",
1130+
'@token': "# this modifies 2 into 4 and viceversa",
11311131
'@role': [Comment, Noop],
11321132
'@pos': { '@type': "uast:Positions",
11331133
},

fixtures/bench_javaobs.py.uast

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
},
4444
lines: [
4545
{ '@type': "NoopLine",
46-
'@token': "!/usr/bin/python\n",
46+
'@token': "#!/usr/bin/python\n",
4747
'@role': [Comment, Noop],
4848
'@pos': { '@type': "uast:Positions",
4949
start: { '@type': "uast:Position",
@@ -54,7 +54,7 @@
5454
},
5555
},
5656
{ '@type': "NoopLine",
57-
'@token': " -- Content-Encoding: UTF-8 --\n",
57+
'@token': "# -- Content-Encoding: UTF-8 --\n",
5858
'@role': [Comment, Noop],
5959
'@pos': { '@type': "uast:Positions",
6060
start: { '@type': "uast:Position",
@@ -109,7 +109,7 @@
109109
},
110110
lines: [
111111
{ '@type': "NoopLine",
112-
'@token': " Standard library\n",
112+
'@token': "# Standard library\n",
113113
'@role': [Comment, Noop],
114114
'@pos': { '@type': "uast:Positions",
115115
start: { '@type': "uast:Position",
@@ -468,7 +468,7 @@
468468
},
469469
lines: [
470470
{ '@type': "NoopLine",
471-
'@token': " ------------------------------------------------------------------------------\n",
471+
'@token': "# ------------------------------------------------------------------------------\n",
472472
'@role': [Comment, Noop],
473473
'@pos': { '@type': "uast:Positions",
474474
start: { '@type': "uast:Position",
@@ -479,7 +479,7 @@
479479
},
480480
},
481481
{ '@type': "NoopLine",
482-
'@token': " Module version\n",
482+
'@token': "# Module version\n",
483483
'@role': [Comment, Noop],
484484
'@pos': { '@type': "uast:Positions",
485485
start: { '@type': "uast:Position",
@@ -785,7 +785,7 @@
785785
},
786786
lines: [
787787
{ '@type': "NoopLine",
788-
'@token': " Documentation strings format\n",
788+
'@token': "# Documentation strings format\n",
789789
'@role': [Comment, Noop],
790790
'@pos': { '@type': "uast:Positions",
791791
start: { '@type': "uast:Position",
@@ -858,7 +858,7 @@
858858
},
859859
lines: [
860860
{ '@type': "NoopLine",
861-
'@token': " ------------------------------------------------------------------------------\n",
861+
'@token': "# ------------------------------------------------------------------------------\n",
862862
'@role': [Comment, Noop],
863863
'@pos': { '@type': "uast:Positions",
864864
start: { '@type': "uast:Position",
@@ -869,7 +869,7 @@
869869
},
870870
},
871871
{ '@type': "NoopLine",
872-
'@token': " Setup the logger\n",
872+
'@token': "# Setup the logger\n",
873873
'@role': [Comment, Noop],
874874
'@pos': { '@type': "uast:Positions",
875875
start: { '@type': "uast:Position",
@@ -3436,7 +3436,7 @@
34363436
},
34373437
lines: [
34383438
{ '@type': "NoopLine",
3439-
'@token': " ------------------------------------------------------------------------------\n",
3439+
'@token': "# ------------------------------------------------------------------------------\n",
34403440
'@role': [Comment, Noop],
34413441
'@pos': { '@type': "uast:Positions",
34423442
start: { '@type': "uast:Position",
@@ -3529,7 +3529,7 @@
35293529
},
35303530
lines: [
35313531
{ '@type': "NoopLine",
3532-
'@token': " ------------------------------------------------------------------------------\n",
3532+
'@token': "# ------------------------------------------------------------------------------\n",
35333533
'@role': [Comment, Noop],
35343534
'@pos': { '@type': "uast:Positions",
35353535
start: { '@type': "uast:Position",
@@ -5284,7 +5284,7 @@
52845284
},
52855285
lines: [
52865286
{ '@type': "NoopLine",
5287-
'@token': " ------------------------------------------------------------------------------\n",
5287+
'@token': "# ------------------------------------------------------------------------------\n",
52885288
'@role': [Comment, Noop],
52895289
'@pos': { '@type': "uast:Positions",
52905290
start: { '@type': "uast:Position",
@@ -10846,7 +10846,7 @@
1084610846
},
1084710847
lines: [
1084810848
{ '@type': "NoopLine",
10849-
'@token': " ------------------------------------------------------------------------------\n",
10849+
'@token': "# ------------------------------------------------------------------------------\n",
1085010850
'@role': [Comment, Noop],
1085110851
'@pos': { '@type': "uast:Positions",
1085210852
start: { '@type': "uast:Position",
@@ -11678,7 +11678,7 @@
1167811678
},
1167911679
'noop_lines': [
1168011680
{ '@type': "NoopSameLine",
11681-
'@token': " if SC_SERIALIZABLE",
11681+
'@token': "# if SC_SERIALIZABLE",
1168211682
'@role': [Comment, Noop],
1168311683
'@pos': { '@type': "uast:Positions",
1168411684
},
@@ -11741,7 +11741,7 @@
1174111741
},
1174211742
'noop_lines': [
1174311743
{ '@type': "NoopSameLine",
11744-
'@token': " if SC_EXTERNALIZABLE",
11744+
'@token': "# if SC_EXTERNALIZABLE",
1174511745
'@role': [Comment, Noop],
1174611746
'@pos': { '@type': "uast:Positions",
1174711747
},
@@ -11952,7 +11952,7 @@
1195211952
},
1195311953
'noop_lines': [
1195411954
{ '@type': "NoopSameLine",
11955-
'@token': " 0x42",
11955+
'@token': "# 0x42",
1195611956
'@role': [Comment, Noop],
1195711957
'@pos': { '@type': "uast:Positions",
1195811958
},
@@ -12020,7 +12020,7 @@
1202012020
},
1202112021
'noop_lines': [
1202212022
{ '@type': "NoopSameLine",
12023-
'@token': " 0x43",
12023+
'@token': "# 0x43",
1202412024
'@role': [Comment, Noop],
1202512025
'@pos': { '@type': "uast:Positions",
1202612026
},
@@ -12088,7 +12088,7 @@
1208812088
},
1208912089
'noop_lines': [
1209012090
{ '@type': "NoopSameLine",
12091-
'@token': " 0x44",
12091+
'@token': "# 0x44",
1209212092
'@role': [Comment, Noop],
1209312093
'@pos': { '@type': "uast:Positions",
1209412094
},
@@ -12156,7 +12156,7 @@
1215612156
},
1215712157
'noop_lines': [
1215812158
{ '@type': "NoopSameLine",
12159-
'@token': " 0x46",
12159+
'@token': "# 0x46",
1216012160
'@role': [Comment, Noop],
1216112161
'@pos': { '@type': "uast:Positions",
1216212162
},
@@ -12224,7 +12224,7 @@
1222412224
},
1222512225
'noop_lines': [
1222612226
{ '@type': "NoopSameLine",
12227-
'@token': " 0x49",
12227+
'@token': "# 0x49",
1222812228
'@role': [Comment, Noop],
1222912229
'@pos': { '@type': "uast:Positions",
1223012230
},
@@ -12292,7 +12292,7 @@
1229212292
},
1229312293
'noop_lines': [
1229412294
{ '@type': "NoopSameLine",
12295-
'@token': " 0x4A",
12295+
'@token': "# 0x4A",
1229612296
'@role': [Comment, Noop],
1229712297
'@pos': { '@type': "uast:Positions",
1229812298
},
@@ -12360,7 +12360,7 @@
1236012360
},
1236112361
'noop_lines': [
1236212362
{ '@type': "NoopSameLine",
12363-
'@token': " 0x53",
12363+
'@token': "# 0x53",
1236412364
'@role': [Comment, Noop],
1236512365
'@pos': { '@type': "uast:Positions",
1236612366
},
@@ -12428,7 +12428,7 @@
1242812428
},
1242912429
'noop_lines': [
1243012430
{ '@type': "NoopSameLine",
12431-
'@token': " 0x5A",
12431+
'@token': "# 0x5A",
1243212432
'@role': [Comment, Noop],
1243312433
'@pos': { '@type': "uast:Positions",
1243412434
},
@@ -12496,7 +12496,7 @@
1249612496
},
1249712497
'noop_lines': [
1249812498
{ '@type': "NoopSameLine",
12499-
'@token': " 0x4C",
12499+
'@token': "# 0x4C",
1250012500
'@role': [Comment, Noop],
1250112501
'@pos': { '@type': "uast:Positions",
1250212502
},
@@ -12564,7 +12564,7 @@
1256412564
},
1256512565
'noop_lines': [
1256612566
{ '@type': "NoopSameLine",
12567-
'@token': " 0x5B",
12567+
'@token': "# 0x5B",
1256812568
'@role': [Comment, Noop],
1256912569
'@pos': { '@type': "uast:Positions",
1257012570
},
@@ -15033,7 +15033,7 @@
1503315033
},
1503415034
lines: [
1503515035
{ '@type': "NoopLine",
15036-
'@token': " ------------------------------------------------------------------------------\n",
15036+
'@token': "# ------------------------------------------------------------------------------\n",
1503715037
'@role': [Comment, Noop],
1503815038
'@pos': { '@type': "uast:Positions",
1503915039
start: { '@type': "uast:Position",
@@ -49725,7 +49725,7 @@
4972549725
},
4972649726
lines: [
4972749727
{ '@type': "NoopLine",
49728-
'@token': " ------------------------------------------------------------------------------\n",
49728+
'@token': "# ------------------------------------------------------------------------------\n",
4972949729
'@role': [Comment, Noop],
4973049730
'@pos': { '@type': "uast:Positions",
4973149731
start: { '@type': "uast:Position",
@@ -74460,7 +74460,7 @@
7446074460
},
7446174461
lines: [
7446274462
{ '@type': "NoopLine",
74463-
'@token': " ------------------------------------------------------------------------------\n",
74463+
'@token': "# ------------------------------------------------------------------------------\n",
7446474464
'@role': [Comment, Noop],
7446574465
'@pos': { '@type': "uast:Positions",
7446674466
start: { '@type': "uast:Position",

fixtures/bench_power_set.py.uast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@
549549
},
550550
lines: [
551551
{ '@type': "NoopLine",
552-
'@token': " the above function in one statement\n",
552+
'@token': "# the above function in one statement\n",
553553
'@role': [Comment, Noop],
554554
'@pos': { '@type': "uast:Positions",
555555
start: { '@type': "uast:Position",

0 commit comments

Comments
 (0)