-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.js
More file actions
40 lines (37 loc) · 776 Bytes
/
parser.js
File metadata and controls
40 lines (37 loc) · 776 Bytes
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
'use strict';
const createError = require('./parser-create-error');
function parse(text) {
try {
const glimmer = require('@glimmer/syntax').preprocess;
return glimmer(text, {
plugins: {
ast: []
},
mode: 'codemod'
});
/* istanbul ignore next */
} catch (error) {
const matches = error.message.match(/on line (\d+)/);
if (matches) {
throw createError(error.message, {
start: { line: Number(matches[1]), column: 0 }
});
} else {
throw error;
}
}
}
module.exports = {
parsers: {
hbs: {
parse,
astFormat: 'hbs',
locStart(node) {
return node.loc && node.loc.start;
},
locEnd(node) {
return node.loc && node.loc.end;
}
}
}
};