diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-11-04 15:54:18 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-11-04 15:54:18 -0800 |
commit | 913dfe73a9fad60e8498160fcabb715cb966bc97 (patch) | |
tree | b136100f8daea4be05580d1bd4335b852426abb9 /src/wasm-s-parser.h | |
parent | 7f4bc21e8068a0463dfdff442a0d8d0f17d48fae (diff) | |
download | binaryen-913dfe73a9fad60e8498160fcabb715cb966bc97.tar.gz binaryen-913dfe73a9fad60e8498160fcabb715cb966bc97.tar.bz2 binaryen-913dfe73a9fad60e8498160fcabb715cb966bc97.zip |
refactor s-expression parser
Diffstat (limited to 'src/wasm-s-parser.h')
-rw-r--r-- | src/wasm-s-parser.h | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index a181278ab..2456c5cca 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -105,12 +105,12 @@ class SExpressionParser { public: // Assumes control of and modifies the input. - SExpressionParser(char* input) : beginning(input), input(input) {} - - Element* parseEverything() { - return parseInnerList(); + SExpressionParser(char* input) : beginning(input), input(input) { + root = parseInnerList(); } + Element* root; + private: // parses the internal part of a list, inside the parens. Element* parseInnerList() { @@ -181,18 +181,13 @@ class SExpressionWasmBuilder { Module& wasm; MixedArena allocator; - SExpressionParser parser; public: // Assumes control of and modifies the input. - SExpressionWasmBuilder(Module& wasm, char* input) : wasm(wasm), parser(input) { - Element* root = parser.parseEverything(); - if (debug) std::cout << *root << '\n'; - assert(root); - Element* module = (*root)[0]; - assert((*module)[0]->str() == MODULE); - for (unsigned i = 1; i < module->size(); i++) { - parseModuleElement(*(*module)[i]); + SExpressionWasmBuilder(Module& wasm, Element& module) : wasm(wasm) { + assert(module[0]->str() == MODULE); + for (unsigned i = 1; i < module.size(); i++) { + parseModuleElement(*module[i]); } } |