UNPKG

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