| 98 | } |
| 99 | |
| 100 | void ParseContext::parse_modulefield() { |
| 101 | // Each modulefield is '(' keyword ... ')'. |
| 102 | // Peek inside to see which section. |
| 103 | if (tok_.peek().type != TokenType::LParen) |
| 104 | throw Exception::Parse("expected '('", tok_.location()); |
| 105 | |
| 106 | const Token& kw = tok_.peek2(); |
| 107 | if (kw.type != TokenType::Keyword) |
| 108 | throw Exception::Parse("expected section keyword", {kw.line, kw.column}); |
| 109 | |
| 110 | const std::string& name = kw.text; |
| 111 | if (name == "type") parse_typesection(); |
| 112 | else if (name == "import") parse_importsection(); |
| 113 | else if (name == "func") parse_funcsection(); |
| 114 | else if (name == "table") parse_tablesection(); |
| 115 | else if (name == "memory") parse_memorysection(); |
| 116 | else if (name == "global") parse_globalsection(); |
| 117 | else if (name == "export") parse_exportsection(); |
| 118 | else if (name == "start") parse_startsection(); |
| 119 | else if (name == "elem") parse_elemsection(); |
| 120 | else if (name == "data") parse_datasection(); |
| 121 | else if (name == "tag") parse_tagsection(); |
| 122 | else throw Exception::Parse("unknown module section '" + name + "'", {kw.line, kw.column}); |
| 123 | } |
| 124 | |
| 125 | // ── Type section ────────────────────────────────────────────────────────────── |
| 126 | |