1 | ;
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const frontend = require("llparse-frontend");
|
4 | var source = frontend.source;
|
5 | exports.source = source;
|
6 | const compiler_1 = require("./compiler");
|
7 | // TODO(indutny): API for disabling/short-circuiting spans
|
8 | /**
|
9 | * LLParse graph builder and compiler.
|
10 | */
|
11 | class LLParse extends source.Builder {
|
12 | /**
|
13 | * The prefix controls the names of methods and state struct in generated
|
14 | * public C headers:
|
15 | *
|
16 | * ```c
|
17 | * // state struct
|
18 | * struct PREFIX_t {
|
19 | * ...
|
20 | * }
|
21 | *
|
22 | * int PREFIX_init(PREFIX_t* state);
|
23 | * int PREFIX_execute(PREFIX_t* state, const char* p, const char* endp);
|
24 | * ```
|
25 | *
|
26 | * @param prefix Prefix to be used when generating public API.
|
27 | */
|
28 | constructor(prefix = 'llparse') {
|
29 | super();
|
30 | this.prefix = prefix;
|
31 | }
|
32 | /**
|
33 | * Compile LLParse graph to the bitcode and C headers
|
34 | *
|
35 | * @param root Root node of the parse graph (see `.node()`)
|
36 | * @param options Compiler options.
|
37 | */
|
38 | build(root, options = {}) {
|
39 | const c = new compiler_1.Compiler(this.prefix, options);
|
40 | return c.compile(root, this.properties);
|
41 | }
|
42 | }
|
43 | exports.LLParse = LLParse;
|
44 | //# sourceMappingURL=api.js.map |
\ | No newline at end of file |