summaryrefslogtreecommitdiff
path: root/src/wat-parser.h
Commit message (Collapse)AuthorAgeFilesLines
* [Parser][NFC] Refactor to use context callbacks (#4799)Thomas Lively2022-07-121-0/+2
| | | | | | | | | | | | | | | | | The parser functions previously both parsed the input and controlled what was done with the results using `constexpr` if-else chains. As the number of parsing contexts grew, these if-else chains became increasingly complex and distracting from the core parsing logic of the parsing functions. To simplify the code, refactor the parsing functions to replace the `constexpr` if-else chains with unconditional calls to methods on the context. To avoid duplicating most method definitions for multiple parsing contexts, introduce new utility contexts that implement common methods and (ab)use inheritance and multiple inheritance to reuse their methods from the main parsing contexts. This change will also make it easier to reuse the parser code for entirely different purposes in the future by providing new context implementations. For example, V8 could reuse the code and provide different parser contexts that construct V8-internal data structures rather than Binaryen data structures.
* [Parser][NFC] Small code cleanups (#4729)Thomas Lively2022-06-141-2/+1
| | | | Apply cleanups suggested by aheejin in post-merge code review of previous parser PRs.
* [Parser] Begin parsing modules (#4716)Thomas Lively2022-06-101-0/+73
Implement the basic infrastructure for the full WAT parser with just enough detail to parse basic modules that contain only imported globals. Parsing functions correspond to elements of the grammar in the text specification and are templatized over context types that correspond to each phase of parsing. Errors are explicitly propagated via `Result<T>` and `MaybeResult<T>` types. Follow-on PRs will implement additional phases of parsing and parsing for new elements in the grammar.