-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathparser.js
43 lines (40 loc) · 937 Bytes
/
parser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'use strict';
var Parser = require('../lib/parser');
var parser = new Parser()
.set('at', function() {
var pos = this.position();
var match = this.match(/^@/);
if (match) {
return pos({val: match[0]});
}
})
.set('slash', function() {
var pos = this.position();
var match = this.match(/^\//);
if (match) {
return pos({val: match[0]});
}
})
.set('text', function() {
var pos = this.position();
var match = this.match(/^\w+/);
if (match) {
return pos({val: match[0]});
}
})
.set('dot', function() {
var pos = this.position();
var match = this.match(/^\./);
if (match) {
return pos({val: match[0]});
}
})
.set('colon', function() {
var pos = this.position();
var match = this.match(/^:/);
if (match) {
return pos({val: match[0]});
}
})
var ast = parser.parse('[email protected]:foo/bar.git');
console.log(ast);