-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_parser.js
More file actions
58 lines (54 loc) · 906 Bytes
/
build_parser.js
File metadata and controls
58 lines (54 loc) · 906 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import fs from "fs";
import peg from "pegjs";
const grammar = fs.readFileSync('./grammar.peg', 'utf8');
const typedefs = `{
CELL,
STR_ESCAPED,
STR_PLAIN,
AGGREGATE,
SUBTOTAL,
NUMBER,
COMPLEX_NUMBER,
LIST,
MATRIX,
STRING,
ANY,
BOOLEAN,
FUNCTION,
ARGUMENTS,
NULL,
ARRAY,
ERROR,
DATE,
TIME,
DATETIME,
TRACE,
CELL_TRACE,
HYPERLINK,
NAVALUE,
VVALUE,
REFVALUE,
NUMVALUE,
DIV0,
NULLE,
NAMEE,
GETTINGDATA,
INLINE,
HIDDEN,
NATURALREF,
CIRCULAR,
OPERATION,
R1C1PARTIAL,
FUNCTIONCALL,
RANGE,
CC2Currency
}`;
const parserSource = peg.generate(grammar, {
dependencies: {
[typedefs]: "./types.js",
"functionDefinitions": "./functions.js"
},
format: "es",
output: "source"
});
fs.writeFileSync('./parser.js', parserSource);