summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/circular-array.h9
-rw-r--r--src/common.h11
-rw-r--r--src/ir.cc183
-rw-r--r--src/ir.h62
-rw-r--r--src/prebuilt/wast-lexer-gen.cc1732
-rw-r--r--src/prebuilt/wast-parser-gen.cc4915
-rw-r--r--src/prebuilt/wast-parser-gen.hh164
-rw-r--r--src/prebuilt/wast-parser-gen.output6361
-rw-r--r--src/resolve-names.cc2
-rw-r--r--src/tools/wasm-interp.cc103
-rw-r--r--src/validator.cc1
-rw-r--r--src/wast-lexer.cc736
-rw-r--r--src/wast-lexer.h162
-rw-r--r--src/wast-parser-lexer-shared.cc21
-rw-r--r--src/wast-parser-lexer-shared.h114
-rw-r--r--src/wast-parser.cc2010
-rw-r--r--src/wast-parser.h175
-rw-r--r--src/wast-parser.y1848
18 files changed, 3923 insertions, 14686 deletions
diff --git a/src/circular-array.h b/src/circular-array.h
index 3787cbdd..265410e8 100644
--- a/src/circular-array.h
+++ b/src/circular-array.h
@@ -18,6 +18,9 @@
#define WABT_CIRCULAR_ARRAY_H_
#include <array>
+#include <cassert>
+#include <cstddef>
+#include <type_traits>
namespace wabt {
@@ -33,8 +36,10 @@ class CircularArray {
typedef const value_type& const_reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
+
CircularArray() : size_(0), front_(0), mask_(kCapacity - 1) {
- assert(kCapacity && ((kCapacity & (kCapacity - 1)) == 0));
+ static_assert(kCapacity && ((kCapacity & (kCapacity - 1)) == 0),
+ "Capacity must be a power of 2.");
}
reference at(size_type index) {
@@ -86,7 +91,7 @@ class CircularArray {
--size_;
}
- void push_back(value_type& value) {
+ void push_back(const value_type& value) {
assert(size_ < kCapacity);
contents_[position(size_++)] = value;
}
diff --git a/src/common.h b/src/common.h
index 58f7070e..d65306bc 100644
--- a/src/common.h
+++ b/src/common.h
@@ -25,6 +25,7 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
+#include <memory>
#include <string>
#include <type_traits>
#include <vector>
@@ -119,6 +120,11 @@ void Destruct(T& placement) {
placement.~T();
}
+template <typename T, typename... Args>
+std::unique_ptr<T> make_unique(Args&&... args) {
+ return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
+}
+
// Calls data() on vector, string, etc. but will return nullptr if the
// container is empty.
// TODO(binji): this should probably be removed when there is a more direct way
@@ -166,6 +172,11 @@ struct Location {
};
Location() : line(0), first_column(0), last_column(0) {}
+ Location(const char* filename, int line, int first_column, int last_column)
+ : filename(filename),
+ line(line),
+ first_column(first_column),
+ last_column(last_column) {}
explicit Location(size_t offset) : offset(offset) {}
const char* filename = nullptr;
diff --git a/src/ir.cc b/src/ir.cc
index be7848bf..df58768d 100644
--- a/src/ir.cc
+++ b/src/ir.cc
@@ -191,6 +191,187 @@ Index Module::GetFuncTypeIndex(const FuncDeclaration& decl) const {
}
}
+void Module::AppendField(DataSegmentModuleField* field) {
+ fields.push_back(field);
+ data_segments.push_back(field->data_segment);
+}
+
+void Module::AppendField(ElemSegmentModuleField* field) {
+ fields.push_back(field);
+ elem_segments.push_back(field->elem_segment);
+}
+
+void Module::AppendField(ExceptionModuleField* field) {
+ auto except = field->except;
+ if (!except->name.empty())
+ except_bindings.emplace(except->name, Binding(field->loc, excepts.size()));
+ excepts.push_back(except);
+ fields.push_back(field);
+}
+
+void Module::AppendField(ExportModuleField* field) {
+ // Exported names are allowed to be empty.
+ auto export_ = field->export_;
+ export_bindings.emplace(export_->name, Binding(field->loc, exports.size()));
+ exports.push_back(export_);
+ fields.push_back(field);
+}
+
+void Module::AppendField(FuncModuleField* field) {
+ auto func = field->func;
+ if (!func->name.empty())
+ func_bindings.emplace(func->name, Binding(field->loc, funcs.size()));
+ funcs.push_back(func);
+ fields.push_back(field);
+}
+
+void Module::AppendField(FuncTypeModuleField* field) {
+ auto func_type = field->func_type;
+ if (!func_type->name.empty()) {
+ func_type_bindings.emplace(func_type->name,
+ Binding(field->loc, func_types.size()));
+ }
+ func_types.push_back(func_type);
+ fields.push_back(field);
+}
+
+void Module::AppendField(GlobalModuleField* field) {
+ auto global = field->global;
+ if (!global->name.empty())
+ global_bindings.emplace(global->name, Binding(field->loc, globals.size()));
+ globals.push_back(global);
+ fields.push_back(field);
+}
+
+void Module::AppendField(ImportModuleField* field) {
+ auto import = field->import;
+ std::string* name = nullptr;
+ BindingHash* bindings = nullptr;
+ Index index = kInvalidIndex;
+
+ switch (import->kind) {
+ case ExternalKind::Func:
+ name = &import->func->name;
+ bindings = &func_bindings;
+ index = funcs.size();
+ funcs.push_back(import->func);
+ ++num_func_imports;
+ break;
+
+ case ExternalKind::Table:
+ name = &import->table->name;
+ bindings = &table_bindings;
+ index = tables.size();
+ tables.push_back(import->table);
+ ++num_table_imports;
+ break;
+
+ case ExternalKind::Memory:
+ name = &import->memory->name;
+ bindings = &memory_bindings;
+ index = memories.size();
+ memories.push_back(import->memory);
+ ++num_memory_imports;
+ break;
+
+ case ExternalKind::Global:
+ name = &import->global->name;
+ bindings = &global_bindings;
+ index = globals.size();
+ globals.push_back(import->global);
+ ++num_global_imports;
+ break;
+
+ case ExternalKind::Except:
+ name = &import->except->name;
+ bindings = &except_bindings;
+ index = excepts.size();
+ excepts.push_back(import->except);
+ ++num_except_imports;
+ break;
+ }
+
+ assert(name && bindings && index != kInvalidIndex);
+ if (!name->empty())
+ bindings->emplace(*name, Binding(field->loc, index));
+ imports.push_back(import);
+ fields.push_back(field);
+}
+
+void Module::AppendField(MemoryModuleField* field) {
+ auto memory = field->memory;
+ if (!memory->name.empty())
+ memory_bindings.emplace(memory->name, Binding(field->loc, memories.size()));
+ memories.push_back(memory);
+ fields.push_back(field);
+}
+
+void Module::AppendField(StartModuleField* field) {
+ fields.push_back(field);
+ start = &field->start;
+}
+
+void Module::AppendField(TableModuleField* field) {
+ auto table = field->table;
+ if (!table->name.empty())
+ table_bindings.emplace(table->name, Binding(field->loc, tables.size()));
+ tables.push_back(table);
+ fields.push_back(field);
+}
+
+void Module::AppendField(ModuleField* field) {
+ switch (field->type) {
+ case ModuleFieldType::Func:
+ AppendField(dyn_cast<FuncModuleField>(field));
+ break;
+
+ case ModuleFieldType::Global:
+ AppendField(dyn_cast<GlobalModuleField>(field));
+ break;
+
+ case ModuleFieldType::Import:
+ AppendField(dyn_cast<ImportModuleField>(field));
+ break;
+
+ case ModuleFieldType::Export:
+ AppendField(dyn_cast<ExportModuleField>(field));
+ break;
+
+ case ModuleFieldType::FuncType:
+ AppendField(dyn_cast<FuncTypeModuleField>(field));
+ break;
+
+ case ModuleFieldType::Table:
+ AppendField(dyn_cast<TableModuleField>(field));
+ break;
+
+ case ModuleFieldType::ElemSegment:
+ AppendField(dyn_cast<ElemSegmentModuleField>(field));
+ break;
+
+ case ModuleFieldType::Memory:
+ AppendField(dyn_cast<MemoryModuleField>(field));
+ break;
+
+ case ModuleFieldType::DataSegment:
+ AppendField(dyn_cast<DataSegmentModuleField>(field));
+ break;
+
+ case ModuleFieldType::Start:
+ AppendField(dyn_cast<StartModuleField>(field));
+ break;
+
+ case ModuleFieldType::Except:
+ AppendField(dyn_cast<ExceptionModuleField>(field));
+ break;
+ }
+}
+
+void Module::AppendFields(ModuleFieldList* fields) {
+ while (!fields->empty())
+ AppendField(fields->extract_front());
+}
+
const Module* Script::GetFirstModule() const {
return const_cast<Script*>(this)->GetFirstModule();
}
@@ -322,6 +503,8 @@ TryExpr::~TryExpr() {
Expr::Expr(ExprType type) : type(type) {}
+Expr::Expr(ExprType type, Location loc) : loc(loc), type(type) {}
+
Table::Table() {
ZeroMemory(elem_limits);
}
diff --git a/src/ir.h b/src/ir.h
index 467c8f17..9bd30ade 100644
--- a/src/ir.h
+++ b/src/ir.h
@@ -174,6 +174,7 @@ class Expr : public intrusive_list_base<Expr> {
protected:
explicit Expr(ExprType);
+ Expr(ExprType, Location);
};
const char* GetExprTypeName(const Expr& expr);
@@ -184,6 +185,7 @@ class ExprMixin : public Expr {
static bool classof(const Expr* expr) { return expr->type == TypeEnum; }
ExprMixin() : Expr(TypeEnum) {}
+ explicit ExprMixin(Location loc) : Expr(TypeEnum, loc) {}
};
typedef ExprMixin<ExprType::CurrentMemory> CurrentMemoryExpr;
@@ -197,7 +199,8 @@ typedef ExprMixin<ExprType::Unreachable> UnreachableExpr;
template <ExprType TypeEnum>
class OpcodeExpr : public ExprMixin<TypeEnum> {
public:
- OpcodeExpr(Opcode opcode) : opcode(opcode) {}
+ OpcodeExpr(Opcode opcode, const Location& loc = Location())
+ : ExprMixin<TypeEnum>(loc), opcode(opcode) {}
Opcode opcode;
};
@@ -210,7 +213,8 @@ typedef OpcodeExpr<ExprType::Unary> UnaryExpr;
template <ExprType TypeEnum>
class VarExpr : public ExprMixin<TypeEnum> {
public:
- VarExpr(const Var& var) : var(var) {}
+ VarExpr(const Var& var, const Location& loc = Location())
+ : ExprMixin<TypeEnum>(loc), var(var) {}
Var var;
};
@@ -230,7 +234,8 @@ typedef VarExpr<ExprType::Throw> ThrowExpr;
template <ExprType TypeEnum>
class BlockExprBase : public ExprMixin<TypeEnum> {
public:
- explicit BlockExprBase(Block* block) : block(block) {}
+ explicit BlockExprBase(Block* block, const Location& loc = Location())
+ : ExprMixin<TypeEnum>(loc), block(block) {}
~BlockExprBase() { delete block; }
Block* block;
@@ -241,8 +246,13 @@ typedef BlockExprBase<ExprType::Loop> LoopExpr;
class IfExpr : public ExprMixin<ExprType::If> {
public:
- explicit IfExpr(Block* true_block, ExprList false_expr = ExprList())
- : true_(true_block), false_(std::move(false_expr)) {}
+ explicit IfExpr(Block* true_block,
+ ExprList false_expr = ExprList(),
+ const Location& loc = Location())
+ : ExprMixin<ExprType::If>(loc),
+ true_(true_block),
+ false_(std::move(false_expr)) {}
+
~IfExpr();
Block* true_;
@@ -251,7 +261,8 @@ class IfExpr : public ExprMixin<ExprType::If> {
class TryExpr : public ExprMixin<ExprType::TryBlock> {
public:
- TryExpr() : block(nullptr) {}
+ explicit TryExpr(const Location& loc = Location())
+ : ExprMixin<ExprType::TryBlock>(loc), block(nullptr) {}
~TryExpr();
Block* block;
@@ -260,8 +271,12 @@ class TryExpr : public ExprMixin<ExprType::TryBlock> {
class BrTableExpr : public ExprMixin<ExprType::BrTable> {
public:
- BrTableExpr(VarVector* targets, Var default_target)
- : targets(targets), default_target(default_target) {}
+ BrTableExpr(VarVector* targets,
+ Var default_target,
+ const Location& loc = Location())
+ : ExprMixin<ExprType::BrTable>(loc),
+ targets(targets),
+ default_target(default_target) {}
~BrTableExpr() { delete targets; }
VarVector* targets;
@@ -270,7 +285,8 @@ class BrTableExpr : public ExprMixin<ExprType::BrTable> {
class ConstExpr : public ExprMixin<ExprType::Const> {
public:
- ConstExpr(const Const& c) : const_(c) {}
+ ConstExpr(const Const& c, const Location& loc = Location())
+ : ExprMixin<ExprType::Const>(loc), const_(c) {}
Const const_;
};
@@ -278,8 +294,14 @@ class ConstExpr : public ExprMixin<ExprType::Const> {
template <ExprType TypeEnum>
class LoadStoreExpr : public ExprMixin<TypeEnum> {
public:
- LoadStoreExpr(Opcode opcode, Address align, uint32_t offset)
- : opcode(opcode), align(align), offset(offset) {}
+ LoadStoreExpr(Opcode opcode,
+ Address align,
+ uint32_t offset,
+ const Location& loc = Location())
+ : ExprMixin<TypeEnum>(loc),
+ opcode(opcode),
+ align(align),
+ offset(offset) {}
Opcode opcode;
Address align;
@@ -580,6 +602,21 @@ struct Module {
Exception* GetExcept(const Var&) const;
Index GetExceptIndex(const Var&) const;
+ // TODO(binji): move this into a builder class?
+ void AppendField(DataSegmentModuleField*);
+ void AppendField(ElemSegmentModuleField*);
+ void AppendField(ExceptionModuleField*);
+ void AppendField(ExportModuleField*);
+ void AppendField(FuncModuleField*);
+ void AppendField(FuncTypeModuleField*);
+ void AppendField(GlobalModuleField*);
+ void AppendField(ImportModuleField*);
+ void AppendField(MemoryModuleField*);
+ void AppendField(StartModuleField*);
+ void AppendField(TableModuleField*);
+ void AppendField(ModuleField*);
+ void AppendFields(ModuleFieldList*);
+
Location loc;
std::string name;
ModuleFieldList fields;
@@ -793,7 +830,8 @@ typedef AssertModuleCommand<CommandType::AssertUnlinkable>
typedef AssertModuleCommand<CommandType::AssertUninstantiable>
AssertUninstantiableCommand;
-typedef std::vector<std::unique_ptr<Command>> CommandPtrVector;
+typedef std::unique_ptr<Command> CommandPtr;
+typedef std::vector<CommandPtr> CommandPtrVector;
struct Script {
WABT_DISALLOW_COPY_AND_ASSIGN(Script);
diff --git a/src/prebuilt/wast-lexer-gen.cc b/src/prebuilt/wast-lexer-gen.cc
index a766846c..f82728d3 100644
--- a/src/prebuilt/wast-lexer-gen.cc
+++ b/src/prebuilt/wast-lexer-gen.cc
@@ -24,48 +24,22 @@
#include "config.h"
#include "circular-array.h"
+#include "error-handler.h"
#include "lexer-source.h"
#include "wast-parser.h"
-#include "wast-parser-lexer-shared.h"
-
-/* must be included after so some typedefs will be defined */
-#include "wast-parser-gen.hh"
#define YYMAXFILL 29
#define INITIAL_LEXER_BUFFER_SIZE (64 * 1024)
-#define NAME_TO_VALUE(name) WABT_TOKEN_TYPE_##name
-
-#define LOOKAHEAD(name) \
- SetLookaheadToken(NAME_TO_VALUE(name)); \
- next_pos_ = cursor_; \
- continue
-
-#define RETURN(name) \
- SetToken(NAME_TO_VALUE(name)); \
- return PopLookaheadToken(lval, loc);
-
-#define RETURN_LPAR(name) \
- SetToken(NAME_TO_VALUE(name)); \
- if (IsLookaheadLpar()) { \
- SetLocation(loc); \
- return NAME_TO_VALUE(LPAR_##name); \
- } \
- return PopLookaheadToken(lval, loc);
-
-#define ERROR(...) \
- SetLocation(loc); \
- WastParserError(loc, this, parser, __VA_ARGS__)
+#define ERROR(...) parser->Error(GetLocation(), __VA_ARGS__)
#define BEGIN(c) cond = (c)
-#define FILL(n) \
- do { \
- if (Failed(Fill(loc, parser, (n)))) { \
- int value = NAME_TO_VALUE(EOF); \
- SetToken(value); \
- return PopLookaheadToken(lval, loc); \
- } \
+#define FILL(n) \
+ do { \
+ if (Failed(Fill((n)))) { \
+ RETURN(Eof); \
+ } \
} while (0)
#define MAYBE_MALFORMED_UTF8(desc) \
@@ -88,23 +62,163 @@
line_file_offset_ = FILE_OFFSET(cursor_); \
} while (0)
-#define TYPE(type_) SetType(Type::type_)
+#define RETURN(token) return Token(GetLocation(), TokenType::token);
+
+#define RETURN_LITERAL(token, literal) \
+ return Token(GetLocation(), TokenType::token, \
+ MakeLiteral(LiteralType::literal))
+
+#define RETURN_TYPE(token, type) \
+ return Token(GetLocation(), TokenType::token, Type::type)
-#define OPCODE(name) SetOpcode(Opcode::name);
+#define RETURN_OPCODE(token, opcode) \
+ return Token(GetLocation(), TokenType::token, Opcode::opcode)
-#define LITERAL(type_) SetLiteral(LiteralType::type_)
+#define RETURN_TEXT(token) \
+ return Token(GetLocation(), TokenType::token, GetText())
+
+#define RETURN_TEXT_AT(token, at) \
+ return Token(GetLocation(), TokenType::token, GetText(at))
namespace wabt {
-struct WastLexer::LexToken {
- Location loc_;
- int value_ = 0;
- Token lval_;
-};
+const char* GetTokenTypeName(TokenType token_type) {
+ const char* s_names[] = {
+ "Invalid",
+ "Reserved",
+ "EOF",
+ "(",
+ ")",
+ "NAT",
+ "INT",
+ "FLOAT",
+ "TEXT",
+ "VAR",
+ "VALUETYPE",
+ "anyfunc",
+ "mut",
+ "nop",
+ "drop",
+ "block",
+ "end",
+ "if",
+ "then",
+ "else",
+ "loop",
+ "br",
+ "br_if",
+ "br_table",
+ "try",
+ "catch",
+ "catch_all",
+ "throw",
+ "rethrow",
+ "call",
+ "call_indirect",
+ "return",
+ "get_local",
+ "set_local",
+ "tee_local",
+ "get_global",
+ "set_global",
+ "LOAD",
+ "STORE",
+ "offset=",
+ "align=",
+ "CONST",
+ "UNARY",
+ "BINARY",
+ "COMPARE",
+ "CONVERT",
+ "select",
+ "unreachable",
+ "current_memory",
+ "grow_memory",
+ "func",
+ "start",
+ "type",
+ "param",
+ "result",
+ "local",
+ "global",
+ "table",
+ "elem",
+ "memory",
+ "data",
+ "offset",
+ "import",
+ "export",
+ "except",
+ "module",
+ "bin",
+ "quote",
+ "register",
+ "invoke",
+ "get",
+ "assert_malformed",
+ "assert_invalid",
+ "assert_unlinkable",
+ "assert_return",
+ "assert_return_canonical_nan",
+ "assert_return_arithmetic_nan",
+ "assert_trap",
+ "assert_exhaustion",
+ };
-struct WastLexer::Lookahead {
- CircularArray<LexToken, 4> tokens_;
-};
+ static_assert(
+ WABT_ARRAY_SIZE(s_names) == WABT_ENUM_COUNT(TokenType),
+ "Expected TokenType names list length to match number of TokenTypes.");
+
+ int x = static_cast<int>(token_type);
+ if (x < WABT_ENUM_COUNT(TokenType))
+ return s_names[x];
+
+ return "Invalid";
+}
+
+Token::Token(Location loc, TokenType token_type)
+ : loc(loc), token_type(token_type) {}
+
+Token::Token(Location loc, TokenType token_type, Type type)
+ : loc(loc), token_type(token_type), type(type) {}
+
+Token::Token(Location loc, TokenType token_type, StringTerminal text)
+ : loc(loc), token_type(token_type), text(text) {}
+
+Token::Token(Location loc, TokenType token_type, Opcode opcode)
+ : loc(loc), token_type(token_type), opcode(opcode) {}
+
+Token::Token(Location loc, TokenType token_type, LiteralTerminal literal)
+ : loc(loc), token_type(token_type), literal(literal) {}
+
+std::string Token::to_string() const {
+ switch (token_type) {
+ case TokenType::Nat:
+ case TokenType::Int:
+ case TokenType::Float:
+ return literal.text.to_string();
+
+ case TokenType::Reserved:
+ case TokenType::Text:
+ case TokenType::Var:
+ return text.to_string();
+
+ case TokenType::ValueType:
+ return GetTypeName(type);
+
+ case TokenType::Load:
+ case TokenType::Store:
+ case TokenType::Const:
+ case TokenType::Unary:
+ case TokenType::Binary:
+ case TokenType::Compare:
+ case TokenType::Convert:
+ return opcode.GetName();
+
+ default:
+ return GetTokenTypeName(token_type);
+ }
+}
WastLexer::WastLexer(std::unique_ptr<LexerSource> source, const char* filename)
: source_(std::move(source)),
@@ -114,8 +228,6 @@ WastLexer::WastLexer(std::unique_ptr<LexerSource> source, const char* filename)
comment_nesting_(0),
buffer_file_offset_(0),
line_file_offset_(0),
- lookahead_(new WastLexer::Lookahead()),
- token_(nullptr),
eof_(false),
buffer_(nullptr),
buffer_size_(0),
@@ -126,7 +238,6 @@ WastLexer::WastLexer(std::unique_ptr<LexerSource> source, const char* filename)
WastLexer::~WastLexer() {
delete[] buffer_;
- delete lookahead_;
}
// static
@@ -143,70 +254,19 @@ std::unique_ptr<WastLexer> WastLexer::CreateBufferLexer(const char* filename,
return std::unique_ptr<WastLexer>(new WastLexer(std::move(source), filename));
}
-bool WastLexer::IsLookaheadLpar() {
- return lookahead_->tokens_.size() == 2 // ignore current token
- && lookahead_->tokens_[0].value_ == WABT_TOKEN_TYPE_LPAR;
-}
-
-int WastLexer::PopLookaheadToken(Token* lval, Location* loc) {
- WastLexer::LexToken* tok = &lookahead_->tokens_.front();
- *loc = tok->loc_;
- *lval = tok->lval_;
- int Result = tok->value_;
- lookahead_->tokens_.pop_front();
- if (lookahead_->tokens_.empty()) token_ = nullptr;
- return Result; \
-}
-
-void WastLexer::PushLookaheadToken() {
- WastLexer::LexToken tok;
- lookahead_->tokens_.push_back(tok);
- token_ = &lookahead_->tokens_.back();
-}
-
-void WastLexer::SetLiteral(LiteralType lit_typ) {
- token_->lval_.t_literal.type = lit_typ;
- token_->lval_.t_literal.text.data = yytext;
- token_->lval_.t_literal.text.size = yyleng;
-}
-
-void WastLexer::SetLocation(Location* loc) {
- loc->filename = filename_;
- loc->line = line_;
- loc->first_column = COLUMN(next_pos_);
- loc->last_column = COLUMN(cursor_);
-}
-
-void WastLexer::SetLookaheadToken(int value) {
- SetToken(value);
- PushLookaheadToken();
-}
-
-void WastLexer::SetOpcode(Opcode opc) {
- token_->lval_.t_opcode = opc;
-}
-
-void WastLexer::SetText() {
- token_->lval_.t_text.data = yytext;
- token_->lval_.t_text.size = yyleng;
-}
-
-void WastLexer::SetTextAt(size_t offset) {
- token_->lval_.t_text.data = yytext + offset;
- token_->lval_.t_text.size = yyleng - offset;
+Location WastLexer::GetLocation() {
+ return Location(filename_, line_, COLUMN(next_pos_), COLUMN(cursor_));
}
-void WastLexer::SetToken(int value) {
- SetLocation(&token_->loc_);
- token_->value_ = value;
- next_pos_ = cursor_;
+LiteralTerminal WastLexer::MakeLiteral(LiteralType type) {
+ return LiteralTerminal(type, GetText());
}
-void WastLexer::SetType(Type ty) {
- token_->lval_.t_type = ty;
+StringTerminal WastLexer::GetText(size_t offset) {
+ return StringTerminal(yytext + offset, yyleng - offset);
}
-Result WastLexer::Fill(Location* loc, WastParser* parser, size_t need) {
+Result WastLexer::Fill(size_t need) {
if (eof_)
return Result::Error;
size_t free = next_pos_ - buffer_;
@@ -260,8 +320,8 @@ Result WastLexer::Fill(Location* loc, WastParser* parser, size_t need) {
return Result::Ok;
}
-int WastLexer::GetToken(Token* lval, Location* loc, WastParser* parser) {
-#line 265 "src/prebuilt/wast-lexer-gen.cc"
+Token WastLexer::GetToken(WastParser* parser) {
+#line 325 "src/prebuilt/wast-lexer-gen.cc"
enum YYCONDTYPE {
YYCOND_i,
@@ -270,19 +330,13 @@ enum YYCONDTYPE {
YYCOND_BLOCK_COMMENT,
};
-#line 262 "src/wast-lexer.cc"
+#line 322 "src/wast-lexer.cc"
YYCONDTYPE cond = YYCOND_i; // i is the initial state.
- if (!lookahead_->tokens_.empty()) {
- return PopLookaheadToken(lval, loc);
- }
-
- PushLookaheadToken();
-
for (;;) {
next_pos_ = cursor_;
-#line 286 "src/prebuilt/wast-lexer-gen.cc"
+#line 340 "src/prebuilt/wast-lexer-gen.cc"
{
unsigned char yych;
unsigned int yyaccept = 0;
@@ -327,29 +381,29 @@ YYCOND_BAD_TEXT:
}
++cursor_;
yy4:
-#line 330 "src/wast-lexer.cc"
+#line 384 "src/wast-lexer.cc"
{ ERROR("illegal character in string");
continue; }
-#line 334 "src/prebuilt/wast-lexer-gen.cc"
+#line 388 "src/prebuilt/wast-lexer-gen.cc"
yy5:
++cursor_;
BEGIN(YYCOND_i);
-#line 323 "src/wast-lexer.cc"
+#line 377 "src/wast-lexer.cc"
{ ERROR("newline in string");
NEWLINE;
continue; }
-#line 342 "src/prebuilt/wast-lexer-gen.cc"
+#line 396 "src/prebuilt/wast-lexer-gen.cc"
yy7:
++cursor_;
-#line 322 "src/wast-lexer.cc"
+#line 376 "src/wast-lexer.cc"
{ continue; }
-#line 347 "src/prebuilt/wast-lexer-gen.cc"
+#line 401 "src/prebuilt/wast-lexer-gen.cc"
yy9:
++cursor_;
BEGIN(YYCOND_i);
-#line 329 "src/wast-lexer.cc"
- { SetText(); RETURN(TEXT); }
-#line 353 "src/prebuilt/wast-lexer-gen.cc"
+#line 383 "src/wast-lexer.cc"
+ { RETURN_TEXT(Text); }
+#line 407 "src/prebuilt/wast-lexer-gen.cc"
yy11:
yyaccept = 0;
yych = *(marker_ = ++cursor_);
@@ -401,9 +455,9 @@ yy11:
yy12:
++cursor_;
yy13:
-#line 332 "src/wast-lexer.cc"
+#line 386 "src/wast-lexer.cc"
{ MAYBE_MALFORMED_UTF8(" in string"); }
-#line 407 "src/prebuilt/wast-lexer-gen.cc"
+#line 461 "src/prebuilt/wast-lexer-gen.cc"
yy14:
yych = *++cursor_;
if (yych <= 0x7F) goto yy13;
@@ -442,11 +496,11 @@ yy19:
yy20:
++cursor_;
yy21:
-#line 326 "src/wast-lexer.cc"
+#line 380 "src/wast-lexer.cc"
{ ERROR("bad escape \"%.*s\"",
static_cast<int>(yyleng), yytext);
continue; }
-#line 450 "src/prebuilt/wast-lexer-gen.cc"
+#line 504 "src/prebuilt/wast-lexer-gen.cc"
yy22:
yych = *++cursor_;
if (yych <= '@') {
@@ -532,14 +586,14 @@ YYCOND_BLOCK_COMMENT:
yy34:
++cursor_;
yy35:
-#line 561 "src/wast-lexer.cc"
+#line 613 "src/wast-lexer.cc"
{ continue; }
-#line 538 "src/prebuilt/wast-lexer-gen.cc"
+#line 592 "src/prebuilt/wast-lexer-gen.cc"
yy36:
++cursor_;
-#line 560 "src/wast-lexer.cc"
+#line 612 "src/wast-lexer.cc"
{ NEWLINE; continue; }
-#line 543 "src/prebuilt/wast-lexer-gen.cc"
+#line 597 "src/prebuilt/wast-lexer-gen.cc"
yy38:
yych = *++cursor_;
if (yych == ';') goto yy48;
@@ -551,9 +605,9 @@ yy39:
yy40:
++cursor_;
yy41:
-#line 562 "src/wast-lexer.cc"
+#line 614 "src/wast-lexer.cc"
{ MAYBE_MALFORMED_UTF8(" in block comment"); }
-#line 557 "src/prebuilt/wast-lexer-gen.cc"
+#line 611 "src/prebuilt/wast-lexer-gen.cc"
yy42:
yych = *++cursor_;
if (yych <= 0x7F) goto yy41;
@@ -586,16 +640,16 @@ yy47:
goto yy41;
yy48:
++cursor_;
-#line 556 "src/wast-lexer.cc"
+#line 608 "src/wast-lexer.cc"
{ COMMENT_NESTING++; continue; }
-#line 592 "src/prebuilt/wast-lexer-gen.cc"
+#line 646 "src/prebuilt/wast-lexer-gen.cc"
yy50:
++cursor_;
-#line 557 "src/wast-lexer.cc"
+#line 609 "src/wast-lexer.cc"
{ if (--COMMENT_NESTING == 0)
BEGIN(YYCOND_i);
continue; }
-#line 599 "src/prebuilt/wast-lexer-gen.cc"
+#line 653 "src/prebuilt/wast-lexer-gen.cc"
yy52:
yych = *++cursor_;
if (yych <= 0x7F) goto yy53;
@@ -684,21 +738,21 @@ yy57:
if (yych <= 0xF4) goto yy76;
}
yy59:
-#line 554 "src/wast-lexer.cc"
+#line 606 "src/wast-lexer.cc"
{ continue; }
-#line 690 "src/prebuilt/wast-lexer-gen.cc"
+#line 744 "src/prebuilt/wast-lexer-gen.cc"
yy60:
++cursor_;
BEGIN(YYCOND_i);
-#line 553 "src/wast-lexer.cc"
+#line 605 "src/wast-lexer.cc"
{ NEWLINE; continue; }
-#line 696 "src/prebuilt/wast-lexer-gen.cc"
+#line 750 "src/prebuilt/wast-lexer-gen.cc"
yy62:
++cursor_;
yy63:
-#line 569 "src/wast-lexer.cc"
+#line 619 "src/wast-lexer.cc"
{ MAYBE_MALFORMED_UTF8(""); }
-#line 702 "src/prebuilt/wast-lexer-gen.cc"
+#line 756 "src/prebuilt/wast-lexer-gen.cc"
yy64:
yych = *++cursor_;
if (yych <= 0x7F) goto yy63;
@@ -919,9 +973,9 @@ YYCOND_i:
yy79:
++cursor_;
yy80:
-#line 568 "src/wast-lexer.cc"
+#line 618 "src/wast-lexer.cc"
{ ERROR("unexpected char"); continue; }
-#line 925 "src/prebuilt/wast-lexer-gen.cc"
+#line 979 "src/prebuilt/wast-lexer-gen.cc"
yy81:
++cursor_;
if (limit_ <= cursor_) FILL(1);
@@ -929,14 +983,14 @@ yy81:
if (yybm[0+yych] & 4) {
goto yy81;
}
-#line 564 "src/wast-lexer.cc"
+#line 616 "src/wast-lexer.cc"
{ continue; }
-#line 935 "src/prebuilt/wast-lexer-gen.cc"
+#line 989 "src/prebuilt/wast-lexer-gen.cc"
yy84:
++cursor_;
-#line 563 "src/wast-lexer.cc"
+#line 615 "src/wast-lexer.cc"
{ NEWLINE; continue; }
-#line 940 "src/prebuilt/wast-lexer-gen.cc"
+#line 994 "src/prebuilt/wast-lexer-gen.cc"
yy86:
++cursor_;
if (limit_ <= cursor_) FILL(1);
@@ -946,11 +1000,9 @@ yy87:
goto yy86;
}
yy88:
-#line 565 "src/wast-lexer.cc"
- { ERROR("unexpected token \"%.*s\"",
- static_cast<int>(yyleng), yytext);
- continue; }
-#line 954 "src/prebuilt/wast-lexer-gen.cc"
+#line 617 "src/wast-lexer.cc"
+ { RETURN_TEXT(Reserved); }
+#line 1006 "src/prebuilt/wast-lexer-gen.cc"
yy89:
yyaccept = 0;
yych = *(marker_ = ++cursor_);
@@ -960,9 +1012,9 @@ yy89:
if (yych <= 0xF4) goto yy129;
yy90:
BEGIN(YYCOND_BAD_TEXT);
-#line 321 "src/wast-lexer.cc"
+#line 375 "src/wast-lexer.cc"
{ continue; }
-#line 966 "src/prebuilt/wast-lexer-gen.cc"
+#line 1018 "src/prebuilt/wast-lexer-gen.cc"
yy91:
yych = *++cursor_;
if (yych <= '\'') {
@@ -982,14 +1034,14 @@ yy91:
yy92:
++cursor_;
if ((yych = *cursor_) == ';') goto yy143;
-#line 312 "src/wast-lexer.cc"
- { LOOKAHEAD(LPAR); }
-#line 988 "src/prebuilt/wast-lexer-gen.cc"
+#line 366 "src/wast-lexer.cc"
+ { RETURN(Lpar); }
+#line 1040 "src/prebuilt/wast-lexer-gen.cc"
yy94:
++cursor_;
-#line 313 "src/wast-lexer.cc"
- { RETURN(RPAR); }
-#line 993 "src/prebuilt/wast-lexer-gen.cc"
+#line 367 "src/wast-lexer.cc"
+ { RETURN(Rpar); }
+#line 1045 "src/prebuilt/wast-lexer-gen.cc"
yy96:
yych = *++cursor_;
if (yych <= 'h') {
@@ -1039,9 +1091,9 @@ yy97:
}
}
yy98:
-#line 314 "src/wast-lexer.cc"
- { LITERAL(Int); RETURN(NAT); }
-#line 1045 "src/prebuilt/wast-lexer-gen.cc"
+#line 368 "src/wast-lexer.cc"
+ { RETURN_LITERAL(Nat, Int); }
+#line 1097 "src/prebuilt/wast-lexer-gen.cc"
yy99:
++cursor_;
if ((limit_ - cursor_) < 3) FILL(3);
@@ -1216,9 +1268,9 @@ yy119:
yy120:
++cursor_;
yy121:
-#line 569 "src/wast-lexer.cc"
+#line 619 "src/wast-lexer.cc"
{ MAYBE_MALFORMED_UTF8(""); }
-#line 1222 "src/prebuilt/wast-lexer-gen.cc"
+#line 1274 "src/prebuilt/wast-lexer-gen.cc"
yy122:
yych = *++cursor_;
if (yych <= 0x7F) goto yy121;
@@ -1288,9 +1340,9 @@ yy130:
}
yy131:
++cursor_;
-#line 320 "src/wast-lexer.cc"
- { SetText(); RETURN(TEXT); }
-#line 1294 "src/prebuilt/wast-lexer-gen.cc"
+#line 374 "src/wast-lexer.cc"
+ { RETURN_TEXT(Text); }
+#line 1346 "src/prebuilt/wast-lexer-gen.cc"
yy133:
++cursor_;
if (limit_ <= cursor_) FILL(1);
@@ -1385,15 +1437,15 @@ yy141:
if (yych <= ';') goto yy142;
if (yych <= '}') goto yy86;
yy142:
-#line 550 "src/wast-lexer.cc"
- { SetText(); RETURN(VAR); }
-#line 1391 "src/prebuilt/wast-lexer-gen.cc"
+#line 602 "src/wast-lexer.cc"
+ { RETURN_TEXT(Var); }
+#line 1443 "src/prebuilt/wast-lexer-gen.cc"
yy143:
++cursor_;
BEGIN(YYCOND_BLOCK_COMMENT);
-#line 555 "src/wast-lexer.cc"
+#line 607 "src/wast-lexer.cc"
{ COMMENT_NESTING = 1; continue; }
-#line 1397 "src/prebuilt/wast-lexer-gen.cc"
+#line 1449 "src/prebuilt/wast-lexer-gen.cc"
yy145:
++cursor_;
if ((yych = *cursor_) <= ':') {
@@ -1434,9 +1486,9 @@ yy145:
}
}
yy146:
-#line 315 "src/wast-lexer.cc"
- { LITERAL(Int); RETURN(INT); }
-#line 1440 "src/prebuilt/wast-lexer-gen.cc"
+#line 369 "src/wast-lexer.cc"
+ { RETURN_LITERAL(Int, Int); }
+#line 1492 "src/prebuilt/wast-lexer-gen.cc"
yy147:
++cursor_;
if ((limit_ - cursor_) < 3) FILL(3);
@@ -1506,9 +1558,9 @@ yy151:
}
}
yy152:
-#line 316 "src/wast-lexer.cc"
- { LITERAL(Float); RETURN(FLOAT); }
-#line 1512 "src/prebuilt/wast-lexer-gen.cc"
+#line 370 "src/wast-lexer.cc"
+ { RETURN_LITERAL(Float, Float); }
+#line 1564 "src/prebuilt/wast-lexer-gen.cc"
yy153:
yych = *++cursor_;
if (yych <= ',') {
@@ -1565,9 +1617,9 @@ yy155:
yy156:
++cursor_;
BEGIN(YYCOND_LINE_COMMENT);
-#line 552 "src/wast-lexer.cc"
+#line 604 "src/wast-lexer.cc"
{ continue; }
-#line 1571 "src/prebuilt/wast-lexer-gen.cc"
+#line 1623 "src/prebuilt/wast-lexer-gen.cc"
yy158:
yych = *++cursor_;
if (yych == 'i') goto yy215;
@@ -1606,9 +1658,9 @@ yy163:
}
}
yy164:
-#line 345 "src/wast-lexer.cc"
- { RETURN(BR); }
-#line 1612 "src/prebuilt/wast-lexer-gen.cc"
+#line 399 "src/wast-lexer.cc"
+ { RETURN(Br); }
+#line 1664 "src/prebuilt/wast-lexer-gen.cc"
yy165:
yych = *++cursor_;
if (yych == 'l') goto yy221;
@@ -1677,9 +1729,9 @@ yy180:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 341 "src/wast-lexer.cc"
- { RETURN(IF); }
-#line 1683 "src/prebuilt/wast-lexer-gen.cc"
+#line 395 "src/wast-lexer.cc"
+ { RETURN(If); }
+#line 1735 "src/prebuilt/wast-lexer-gen.cc"
yy182:
yych = *++cursor_;
if (yych == 'p') goto yy245;
@@ -2017,9 +2069,9 @@ yy228:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 351 "src/wast-lexer.cc"
- { RETURN(END); }
-#line 2023 "src/prebuilt/wast-lexer-gen.cc"
+#line 405 "src/wast-lexer.cc"
+ { RETURN(End); }
+#line 2075 "src/prebuilt/wast-lexer-gen.cc"
yy230:
yych = *++cursor_;
if (yych == 'e') goto yy301;
@@ -2047,9 +2099,9 @@ yy232:
}
}
yy233:
-#line 335 "src/wast-lexer.cc"
- { TYPE(F32); RETURN(VALUE_TYPE); }
-#line 2053 "src/prebuilt/wast-lexer-gen.cc"
+#line 389 "src/wast-lexer.cc"
+ { RETURN_TYPE(ValueType, F32); }
+#line 2105 "src/prebuilt/wast-lexer-gen.cc"
yy234:
++cursor_;
if ((yych = *cursor_) <= ')') {
@@ -2069,9 +2121,9 @@ yy234:
}
}
yy235:
-#line 336 "src/wast-lexer.cc"
- { TYPE(F64); RETURN(VALUE_TYPE); }
-#line 2075 "src/prebuilt/wast-lexer-gen.cc"
+#line 390 "src/wast-lexer.cc"
+ { RETURN_TYPE(ValueType, F64); }
+#line 2127 "src/prebuilt/wast-lexer-gen.cc"
yy236:
yych = *++cursor_;
if (yych == 'c') goto yy305;
@@ -2094,9 +2146,9 @@ yy237:
}
}
yy238:
-#line 534 "src/wast-lexer.cc"
- { RETURN(GET); }
-#line 2100 "src/prebuilt/wast-lexer-gen.cc"
+#line 588 "src/wast-lexer.cc"
+ { RETURN(Get); }
+#line 2152 "src/prebuilt/wast-lexer-gen.cc"
yy239:
yych = *++cursor_;
if (yych == 'b') goto yy308;
@@ -2124,9 +2176,9 @@ yy241:
}
}
yy242:
-#line 333 "src/wast-lexer.cc"
- { TYPE(I32); RETURN(VALUE_TYPE); }
-#line 2130 "src/prebuilt/wast-lexer-gen.cc"
+#line 387 "src/wast-lexer.cc"
+ { RETURN_TYPE(ValueType, I32); }
+#line 2182 "src/prebuilt/wast-lexer-gen.cc"
yy243:
++cursor_;
if ((yych = *cursor_) <= ')') {
@@ -2146,9 +2198,9 @@ yy243:
}
}
yy244:
-#line 334 "src/wast-lexer.cc"
- { TYPE(I64); RETURN(VALUE_TYPE); }
-#line 2152 "src/prebuilt/wast-lexer-gen.cc"
+#line 388 "src/wast-lexer.cc"
+ { RETURN_TYPE(ValueType, I64); }
+#line 2204 "src/prebuilt/wast-lexer-gen.cc"
yy245:
yych = *++cursor_;
if (yych == 'o') goto yy312;
@@ -2158,9 +2210,9 @@ yy246:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 318 "src/wast-lexer.cc"
- { LITERAL(Infinity); RETURN(FLOAT); }
-#line 2164 "src/prebuilt/wast-lexer-gen.cc"
+#line 372 "src/wast-lexer.cc"
+ { RETURN_LITERAL(Float, Infinity); }
+#line 2216 "src/prebuilt/wast-lexer-gen.cc"
yy248:
yych = *++cursor_;
if (yych == 'o') goto yy313;
@@ -2186,9 +2238,9 @@ yy253:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 338 "src/wast-lexer.cc"
- { RETURN(MUT); }
-#line 2192 "src/prebuilt/wast-lexer-gen.cc"
+#line 392 "src/wast-lexer.cc"
+ { RETURN(Mut); }
+#line 2244 "src/prebuilt/wast-lexer-gen.cc"
yy255:
++cursor_;
if ((yych = *cursor_) <= ')') {
@@ -2208,17 +2260,17 @@ yy255:
}
}
yy256:
-#line 319 "src/wast-lexer.cc"
- { LITERAL(Nan); RETURN(FLOAT); }
-#line 2214 "src/prebuilt/wast-lexer-gen.cc"
+#line 373 "src/wast-lexer.cc"
+ { RETURN_LITERAL(Float, Nan); }
+#line 2266 "src/prebuilt/wast-lexer-gen.cc"
yy257:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 339 "src/wast-lexer.cc"
- { RETURN(NOP); }
-#line 2222 "src/prebuilt/wast-lexer-gen.cc"
+#line 393 "src/wast-lexer.cc"
+ { RETURN(Nop); }
+#line 2274 "src/prebuilt/wast-lexer-gen.cc"
yy259:
yych = *++cursor_;
if (yych == 's') goto yy320;
@@ -2277,9 +2329,9 @@ yy272:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 545 "src/wast-lexer.cc"
- { RETURN(TRY); }
-#line 2283 "src/prebuilt/wast-lexer-gen.cc"
+#line 597 "src/wast-lexer.cc"
+ { RETURN(Try); }
+#line 2335 "src/prebuilt/wast-lexer-gen.cc"
yy274:
yych = *++cursor_;
if (yych == 'e') goto yy335;
@@ -2393,9 +2445,9 @@ yy279:
}
}
yy280:
-#line 317 "src/wast-lexer.cc"
- { LITERAL(Hexfloat); RETURN(FLOAT); }
-#line 2399 "src/prebuilt/wast-lexer-gen.cc"
+#line 371 "src/wast-lexer.cc"
+ { RETURN_LITERAL(Float, Hexfloat); }
+#line 2451 "src/prebuilt/wast-lexer-gen.cc"
yy281:
yych = *++cursor_;
if (yych <= ',') {
@@ -2453,9 +2505,9 @@ yy289:
}
}
yy290:
-#line 348 "src/wast-lexer.cc"
- { RETURN(CALL); }
-#line 2459 "src/prebuilt/wast-lexer-gen.cc"
+#line 402 "src/wast-lexer.cc"
+ { RETURN(Call); }
+#line 2511 "src/prebuilt/wast-lexer-gen.cc"
yy291:
yych = *++cursor_;
if (yych == 'h') goto yy353;
@@ -2469,33 +2521,33 @@ yy293:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 527 "src/wast-lexer.cc"
- { RETURN(DATA); }
-#line 2475 "src/prebuilt/wast-lexer-gen.cc"
+#line 581 "src/wast-lexer.cc"
+ { RETURN(Data); }
+#line 2527 "src/prebuilt/wast-lexer-gen.cc"
yy295:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 350 "src/wast-lexer.cc"
- { RETURN(DROP); }
-#line 2483 "src/prebuilt/wast-lexer-gen.cc"
+#line 404 "src/wast-lexer.cc"
+ { RETURN(Drop); }
+#line 2535 "src/prebuilt/wast-lexer-gen.cc"
yy297:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 526 "src/wast-lexer.cc"
- { RETURN(ELEM); }
-#line 2491 "src/prebuilt/wast-lexer-gen.cc"
+#line 580 "src/wast-lexer.cc"
+ { RETURN(Elem); }
+#line 2543 "src/prebuilt/wast-lexer-gen.cc"
yy299:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 343 "src/wast-lexer.cc"
- { RETURN(ELSE); }
-#line 2499 "src/prebuilt/wast-lexer-gen.cc"
+#line 397 "src/wast-lexer.cc"
+ { RETURN(Else); }
+#line 2551 "src/prebuilt/wast-lexer-gen.cc"
yy301:
yych = *++cursor_;
if (yych == 'p') goto yy356;
@@ -2544,9 +2596,9 @@ yy305:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 515 "src/wast-lexer.cc"
- { RETURN(FUNC); }
-#line 2550 "src/prebuilt/wast-lexer-gen.cc"
+#line 569 "src/wast-lexer.cc"
+ { RETURN(Func); }
+#line 2602 "src/prebuilt/wast-lexer-gen.cc"
yy307:
yych = *++cursor_;
if (yych == 'g') goto yy383;
@@ -2616,9 +2668,9 @@ yy315:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 344 "src/wast-lexer.cc"
- { RETURN(LOOP); }
-#line 2622 "src/prebuilt/wast-lexer-gen.cc"
+#line 398 "src/wast-lexer.cc"
+ { RETURN(Loop); }
+#line 2674 "src/prebuilt/wast-lexer-gen.cc"
yy317:
yych = *++cursor_;
if (yych == 'r') goto yy420;
@@ -2685,9 +2737,9 @@ yy332:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 342 "src/wast-lexer.cc"
- { RETURN(THEN); }
-#line 2691 "src/prebuilt/wast-lexer-gen.cc"
+#line 396 "src/wast-lexer.cc"
+ { RETURN(Then); }
+#line 2743 "src/prebuilt/wast-lexer-gen.cc"
yy334:
yych = *++cursor_;
if (yych == 'w') goto yy440;
@@ -2697,9 +2749,9 @@ yy335:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 514 "src/wast-lexer.cc"
- { RETURN(TYPE); }
-#line 2703 "src/prebuilt/wast-lexer-gen.cc"
+#line 568 "src/wast-lexer.cc"
+ { RETURN(Type); }
+#line 2755 "src/prebuilt/wast-lexer-gen.cc"
yy337:
yych = *++cursor_;
if (yych == 'a') goto yy442;
@@ -2817,17 +2869,17 @@ yy347:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 340 "src/wast-lexer.cc"
- { RETURN(BLOCK); }
-#line 2823 "src/prebuilt/wast-lexer-gen.cc"
+#line 394 "src/wast-lexer.cc"
+ { RETURN(Block); }
+#line 2875 "src/prebuilt/wast-lexer-gen.cc"
yy349:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 346 "src/wast-lexer.cc"
- { RETURN(BR_IF); }
-#line 2831 "src/prebuilt/wast-lexer-gen.cc"
+#line 400 "src/wast-lexer.cc"
+ { RETURN(BrIf); }
+#line 2883 "src/prebuilt/wast-lexer-gen.cc"
yy351:
yych = *++cursor_;
if (yych == 'b') goto yy449;
@@ -2854,9 +2906,9 @@ yy353:
}
}
yy354:
-#line 546 "src/wast-lexer.cc"
- { RETURN_LPAR(CATCH); }
-#line 2860 "src/prebuilt/wast-lexer-gen.cc"
+#line 598 "src/wast-lexer.cc"
+ { RETURN(Catch); }
+#line 2912 "src/prebuilt/wast-lexer-gen.cc"
yy355:
yych = *++cursor_;
if (yych == 'n') goto yy452;
@@ -3200,9 +3252,9 @@ yy418:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 518 "src/wast-lexer.cc"
- { RETURN(LOCAL); }
-#line 3206 "src/prebuilt/wast-lexer-gen.cc"
+#line 572 "src/wast-lexer.cc"
+ { RETURN(Local); }
+#line 3258 "src/prebuilt/wast-lexer-gen.cc"
yy420:
yych = *++cursor_;
if (yych == 'y') goto yy576;
@@ -3224,17 +3276,17 @@ yy424:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 516 "src/wast-lexer.cc"
- { RETURN(PARAM); }
-#line 3230 "src/prebuilt/wast-lexer-gen.cc"
+#line 570 "src/wast-lexer.cc"
+ { RETURN(Param); }
+#line 3282 "src/prebuilt/wast-lexer-gen.cc"
yy426:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 522 "src/wast-lexer.cc"
- { RETURN(QUOTE); }
-#line 3238 "src/prebuilt/wast-lexer-gen.cc"
+#line 576 "src/wast-lexer.cc"
+ { RETURN(Quote); }
+#line 3290 "src/prebuilt/wast-lexer-gen.cc"
yy428:
yych = *++cursor_;
if (yych == 't') goto yy583;
@@ -3268,17 +3320,17 @@ yy435:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 525 "src/wast-lexer.cc"
- { RETURN(START); }
-#line 3274 "src/prebuilt/wast-lexer-gen.cc"
+#line 579 "src/wast-lexer.cc"
+ { RETURN(Start); }
+#line 3326 "src/prebuilt/wast-lexer-gen.cc"
yy437:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 523 "src/wast-lexer.cc"
- { RETURN(TABLE); }
-#line 3282 "src/prebuilt/wast-lexer-gen.cc"
+#line 577 "src/wast-lexer.cc"
+ { RETURN(Table); }
+#line 3334 "src/prebuilt/wast-lexer-gen.cc"
yy439:
yych = *++cursor_;
if (yych == 'o') goto yy593;
@@ -3288,9 +3340,9 @@ yy440:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 548 "src/wast-lexer.cc"
- { RETURN(THROW); }
-#line 3294 "src/prebuilt/wast-lexer-gen.cc"
+#line 600 "src/wast-lexer.cc"
+ { RETURN(Throw); }
+#line 3346 "src/prebuilt/wast-lexer-gen.cc"
yy442:
yych = *++cursor_;
if (yych == 'c') goto yy594;
@@ -3340,9 +3392,9 @@ yy447:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 521 "src/wast-lexer.cc"
- { RETURN(BIN); }
-#line 3346 "src/prebuilt/wast-lexer-gen.cc"
+#line 575 "src/wast-lexer.cc"
+ { RETURN(Bin); }
+#line 3398 "src/prebuilt/wast-lexer-gen.cc"
yy449:
yych = *++cursor_;
if (yych == 'l') goto yy602;
@@ -3364,17 +3416,17 @@ yy453:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 531 "src/wast-lexer.cc"
- { RETURN(EXCEPT); }
-#line 3370 "src/prebuilt/wast-lexer-gen.cc"
+#line 585 "src/wast-lexer.cc"
+ { RETURN(Except); }
+#line 3422 "src/prebuilt/wast-lexer-gen.cc"
yy455:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 530 "src/wast-lexer.cc"
- { RETURN(EXPORT); }
-#line 3378 "src/prebuilt/wast-lexer-gen.cc"
+#line 584 "src/wast-lexer.cc"
+ { RETURN(Export); }
+#line 3430 "src/prebuilt/wast-lexer-gen.cc"
yy457:
yych = *++cursor_;
if (yych == 's') goto yy606;
@@ -3405,9 +3457,9 @@ yy463:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 473 "src/wast-lexer.cc"
- { OPCODE(F32Eq); RETURN(COMPARE); }
-#line 3411 "src/prebuilt/wast-lexer-gen.cc"
+#line 527 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, F32Eq); }
+#line 3463 "src/prebuilt/wast-lexer-gen.cc"
yy465:
yych = *++cursor_;
if (yych == 'o') goto yy616;
@@ -3417,25 +3469,25 @@ yy466:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 483 "src/wast-lexer.cc"
- { OPCODE(F32Ge); RETURN(COMPARE); }
-#line 3423 "src/prebuilt/wast-lexer-gen.cc"
+#line 537 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, F32Ge); }
+#line 3475 "src/prebuilt/wast-lexer-gen.cc"
yy468:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 481 "src/wast-lexer.cc"
- { OPCODE(F32Gt); RETURN(COMPARE); }
-#line 3431 "src/prebuilt/wast-lexer-gen.cc"
+#line 535 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, F32Gt); }
+#line 3483 "src/prebuilt/wast-lexer-gen.cc"
yy470:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 479 "src/wast-lexer.cc"
- { OPCODE(F32Le); RETURN(COMPARE); }
-#line 3439 "src/prebuilt/wast-lexer-gen.cc"
+#line 533 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, F32Le); }
+#line 3491 "src/prebuilt/wast-lexer-gen.cc"
yy472:
yych = *++cursor_;
if (yych == 'a') goto yy617;
@@ -3445,9 +3497,9 @@ yy473:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 477 "src/wast-lexer.cc"
- { OPCODE(F32Lt); RETURN(COMPARE); }
-#line 3451 "src/prebuilt/wast-lexer-gen.cc"
+#line 531 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, F32Lt); }
+#line 3503 "src/prebuilt/wast-lexer-gen.cc"
yy475:
yych = *++cursor_;
if (yych == 'x') goto yy618;
@@ -3480,9 +3532,9 @@ yy478:
}
}
yy479:
-#line 475 "src/wast-lexer.cc"
- { OPCODE(F32Ne); RETURN(COMPARE); }
-#line 3486 "src/prebuilt/wast-lexer-gen.cc"
+#line 529 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, F32Ne); }
+#line 3538 "src/prebuilt/wast-lexer-gen.cc"
yy480:
yych = *++cursor_;
if (yych == 'i') goto yy627;
@@ -3529,9 +3581,9 @@ yy490:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 474 "src/wast-lexer.cc"
- { OPCODE(F64Eq); RETURN(COMPARE); }
-#line 3535 "src/prebuilt/wast-lexer-gen.cc"
+#line 528 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, F64Eq); }
+#line 3587 "src/prebuilt/wast-lexer-gen.cc"
yy492:
yych = *++cursor_;
if (yych == 'o') goto yy642;
@@ -3541,25 +3593,25 @@ yy493:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 484 "src/wast-lexer.cc"
- { OPCODE(F64Ge); RETURN(COMPARE); }
-#line 3547 "src/prebuilt/wast-lexer-gen.cc"
+#line 538 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, F64Ge); }
+#line 3599 "src/prebuilt/wast-lexer-gen.cc"
yy495:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 482 "src/wast-lexer.cc"
- { OPCODE(F64Gt); RETURN(COMPARE); }
-#line 3555 "src/prebuilt/wast-lexer-gen.cc"
+#line 536 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, F64Gt); }
+#line 3607 "src/prebuilt/wast-lexer-gen.cc"
yy497:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 480 "src/wast-lexer.cc"
- { OPCODE(F64Le); RETURN(COMPARE); }
-#line 3563 "src/prebuilt/wast-lexer-gen.cc"
+#line 534 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, F64Le); }
+#line 3615 "src/prebuilt/wast-lexer-gen.cc"
yy499:
yych = *++cursor_;
if (yych == 'a') goto yy643;
@@ -3569,9 +3621,9 @@ yy500:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 478 "src/wast-lexer.cc"
- { OPCODE(F64Lt); RETURN(COMPARE); }
-#line 3575 "src/prebuilt/wast-lexer-gen.cc"
+#line 532 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, F64Lt); }
+#line 3627 "src/prebuilt/wast-lexer-gen.cc"
yy502:
yych = *++cursor_;
if (yych == 'x') goto yy644;
@@ -3604,9 +3656,9 @@ yy505:
}
}
yy506:
-#line 476 "src/wast-lexer.cc"
- { OPCODE(F64Ne); RETURN(COMPARE); }
-#line 3610 "src/prebuilt/wast-lexer-gen.cc"
+#line 530 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, F64Ne); }
+#line 3662 "src/prebuilt/wast-lexer-gen.cc"
yy507:
yych = *++cursor_;
if (yych == 'o') goto yy653;
@@ -3644,9 +3696,9 @@ yy515:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 519 "src/wast-lexer.cc"
- { RETURN(GLOBAL); }
-#line 3650 "src/prebuilt/wast-lexer-gen.cc"
+#line 573 "src/wast-lexer.cc"
+ { RETURN(Global); }
+#line 3702 "src/prebuilt/wast-lexer-gen.cc"
yy517:
yych = *++cursor_;
if (yych == 'e') goto yy662;
@@ -3693,9 +3745,9 @@ yy524:
}
}
yy525:
-#line 453 "src/wast-lexer.cc"
- { OPCODE(I32Eq); RETURN(COMPARE); }
-#line 3699 "src/prebuilt/wast-lexer-gen.cc"
+#line 507 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, I32Eq); }
+#line 3751 "src/prebuilt/wast-lexer-gen.cc"
yy526:
yych = *++cursor_;
if (yych == '_') goto yy675;
@@ -3725,17 +3777,17 @@ yy532:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 455 "src/wast-lexer.cc"
- { OPCODE(I32Ne); RETURN(COMPARE); }
-#line 3731 "src/prebuilt/wast-lexer-gen.cc"
+#line 509 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, I32Ne); }
+#line 3783 "src/prebuilt/wast-lexer-gen.cc"
yy534:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 425 "src/wast-lexer.cc"
- { OPCODE(I32Or); RETURN(BINARY); }
-#line 3739 "src/prebuilt/wast-lexer-gen.cc"
+#line 479 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I32Or); }
+#line 3791 "src/prebuilt/wast-lexer-gen.cc"
yy536:
yych = *++cursor_;
if (yych == 'p') goto yy682;
@@ -3816,9 +3868,9 @@ yy551:
}
}
yy552:
-#line 454 "src/wast-lexer.cc"
- { OPCODE(I64Eq); RETURN(COMPARE); }
-#line 3822 "src/prebuilt/wast-lexer-gen.cc"
+#line 508 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, I64Eq); }
+#line 3874 "src/prebuilt/wast-lexer-gen.cc"
yy553:
yych = *++cursor_;
if (yych == 't') goto yy708;
@@ -3852,17 +3904,17 @@ yy560:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 456 "src/wast-lexer.cc"
- { OPCODE(I64Ne); RETURN(COMPARE); }
-#line 3858 "src/prebuilt/wast-lexer-gen.cc"
+#line 510 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, I64Ne); }
+#line 3910 "src/prebuilt/wast-lexer-gen.cc"
yy562:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 426 "src/wast-lexer.cc"
- { OPCODE(I64Or); RETURN(BINARY); }
-#line 3866 "src/prebuilt/wast-lexer-gen.cc"
+#line 480 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I64Or); }
+#line 3918 "src/prebuilt/wast-lexer-gen.cc"
yy564:
yych = *++cursor_;
if (yych == 'p') goto yy716;
@@ -3902,33 +3954,33 @@ yy572:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 529 "src/wast-lexer.cc"
- { RETURN(IMPORT); }
-#line 3908 "src/prebuilt/wast-lexer-gen.cc"
+#line 583 "src/wast-lexer.cc"
+ { RETURN(Import); }
+#line 3960 "src/prebuilt/wast-lexer-gen.cc"
yy574:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 533 "src/wast-lexer.cc"
- { RETURN(INVOKE); }
-#line 3916 "src/prebuilt/wast-lexer-gen.cc"
+#line 587 "src/wast-lexer.cc"
+ { RETURN(Invoke); }
+#line 3968 "src/prebuilt/wast-lexer-gen.cc"
yy576:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 524 "src/wast-lexer.cc"
- { RETURN(MEMORY); }
-#line 3924 "src/prebuilt/wast-lexer-gen.cc"
+#line 578 "src/wast-lexer.cc"
+ { RETURN(Memory); }
+#line 3976 "src/prebuilt/wast-lexer-gen.cc"
yy578:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 520 "src/wast-lexer.cc"
- { RETURN(MODULE); }
-#line 3932 "src/prebuilt/wast-lexer-gen.cc"
+#line 574 "src/wast-lexer.cc"
+ { RETURN(Module); }
+#line 3984 "src/prebuilt/wast-lexer-gen.cc"
yy580:
++cursor_;
if (limit_ <= cursor_) FILL(1);
@@ -3973,9 +4025,9 @@ yy581:
}
}
yy582:
-#line 528 "src/wast-lexer.cc"
- { RETURN(OFFSET); }
-#line 3979 "src/prebuilt/wast-lexer-gen.cc"
+#line 582 "src/wast-lexer.cc"
+ { RETURN(Offset); }
+#line 4031 "src/prebuilt/wast-lexer-gen.cc"
yy583:
yych = *++cursor_;
if (yych == 'e') goto yy732;
@@ -3985,9 +4037,9 @@ yy584:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 517 "src/wast-lexer.cc"
- { RETURN(RESULT); }
-#line 3991 "src/prebuilt/wast-lexer-gen.cc"
+#line 571 "src/wast-lexer.cc"
+ { RETURN(Result); }
+#line 4043 "src/prebuilt/wast-lexer-gen.cc"
yy586:
yych = *++cursor_;
if (yych == 'w') goto yy733;
@@ -3997,17 +4049,17 @@ yy587:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 352 "src/wast-lexer.cc"
- { RETURN(RETURN); }
-#line 4003 "src/prebuilt/wast-lexer-gen.cc"
+#line 406 "src/wast-lexer.cc"
+ { RETURN(Return); }
+#line 4055 "src/prebuilt/wast-lexer-gen.cc"
yy589:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 510 "src/wast-lexer.cc"
- { RETURN(SELECT); }
-#line 4011 "src/prebuilt/wast-lexer-gen.cc"
+#line 564 "src/wast-lexer.cc"
+ { RETURN(Select); }
+#line 4063 "src/prebuilt/wast-lexer-gen.cc"
yy591:
yych = *++cursor_;
if (yych == 'o') goto yy735;
@@ -4046,9 +4098,9 @@ yy595:
}
}
yy596:
-#line 382 "src/wast-lexer.cc"
- { SetTextAt(6); RETURN(ALIGN_EQ_NAT); }
-#line 4052 "src/prebuilt/wast-lexer-gen.cc"
+#line 436 "src/wast-lexer.cc"
+ { RETURN_TEXT_AT(AlignEqNat, 6); }
+#line 4104 "src/prebuilt/wast-lexer-gen.cc"
yy597:
++cursor_;
if (limit_ <= cursor_) FILL(1);
@@ -4078,9 +4130,9 @@ yy599:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 337 "src/wast-lexer.cc"
- { RETURN(ANYFUNC); }
-#line 4084 "src/prebuilt/wast-lexer-gen.cc"
+#line 391 "src/wast-lexer.cc"
+ { RETURN(Anyfunc); }
+#line 4136 "src/prebuilt/wast-lexer-gen.cc"
yy601:
yych = *++cursor_;
switch (yych) {
@@ -4113,17 +4165,17 @@ yy606:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 397 "src/wast-lexer.cc"
- { OPCODE(F32Abs); RETURN(UNARY); }
-#line 4119 "src/prebuilt/wast-lexer-gen.cc"
+#line 451 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Unary, F32Abs); }
+#line 4171 "src/prebuilt/wast-lexer-gen.cc"
yy608:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 439 "src/wast-lexer.cc"
- { OPCODE(F32Add); RETURN(BINARY); }
-#line 4127 "src/prebuilt/wast-lexer-gen.cc"
+#line 493 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, F32Add); }
+#line 4179 "src/prebuilt/wast-lexer-gen.cc"
yy610:
yych = *++cursor_;
if (yych == 'l') goto yy752;
@@ -4146,9 +4198,9 @@ yy614:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 445 "src/wast-lexer.cc"
- { OPCODE(F32Div); RETURN(BINARY); }
-#line 4152 "src/prebuilt/wast-lexer-gen.cc"
+#line 499 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, F32Div); }
+#line 4204 "src/prebuilt/wast-lexer-gen.cc"
yy616:
yych = *++cursor_;
if (yych == 'o') goto yy758;
@@ -4162,25 +4214,25 @@ yy618:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 449 "src/wast-lexer.cc"
- { OPCODE(F32Max); RETURN(BINARY); }
-#line 4168 "src/prebuilt/wast-lexer-gen.cc"
+#line 503 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, F32Max); }
+#line 4220 "src/prebuilt/wast-lexer-gen.cc"
yy620:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 447 "src/wast-lexer.cc"
- { OPCODE(F32Min); RETURN(BINARY); }
-#line 4176 "src/prebuilt/wast-lexer-gen.cc"
+#line 501 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, F32Min); }
+#line 4228 "src/prebuilt/wast-lexer-gen.cc"
yy622:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 443 "src/wast-lexer.cc"
- { OPCODE(F32Mul); RETURN(BINARY); }
-#line 4184 "src/prebuilt/wast-lexer-gen.cc"
+#line 497 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, F32Mul); }
+#line 4236 "src/prebuilt/wast-lexer-gen.cc"
yy624:
yych = *++cursor_;
if (yych == 'r') goto yy761;
@@ -4190,9 +4242,9 @@ yy625:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 395 "src/wast-lexer.cc"
- { OPCODE(F32Neg); RETURN(UNARY); }
-#line 4196 "src/prebuilt/wast-lexer-gen.cc"
+#line 449 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Unary, F32Neg); }
+#line 4248 "src/prebuilt/wast-lexer-gen.cc"
yy627:
yych = *++cursor_;
if (yych == 'n') goto yy762;
@@ -4210,9 +4262,9 @@ yy630:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 441 "src/wast-lexer.cc"
- { OPCODE(F32Sub); RETURN(BINARY); }
-#line 4216 "src/prebuilt/wast-lexer-gen.cc"
+#line 495 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, F32Sub); }
+#line 4268 "src/prebuilt/wast-lexer-gen.cc"
yy632:
yych = *++cursor_;
if (yych == 'n') goto yy766;
@@ -4222,17 +4274,17 @@ yy633:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 398 "src/wast-lexer.cc"
- { OPCODE(F64Abs); RETURN(UNARY); }
-#line 4228 "src/prebuilt/wast-lexer-gen.cc"
+#line 452 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Unary, F64Abs); }
+#line 4280 "src/prebuilt/wast-lexer-gen.cc"
yy635:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 440 "src/wast-lexer.cc"
- { OPCODE(F64Add); RETURN(BINARY); }
-#line 4236 "src/prebuilt/wast-lexer-gen.cc"
+#line 494 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, F64Add); }
+#line 4288 "src/prebuilt/wast-lexer-gen.cc"
yy637:
yych = *++cursor_;
if (yych == 'l') goto yy767;
@@ -4251,9 +4303,9 @@ yy640:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 446 "src/wast-lexer.cc"
- { OPCODE(F64Div); RETURN(BINARY); }
-#line 4257 "src/prebuilt/wast-lexer-gen.cc"
+#line 500 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, F64Div); }
+#line 4309 "src/prebuilt/wast-lexer-gen.cc"
yy642:
yych = *++cursor_;
if (yych == 'o') goto yy772;
@@ -4267,25 +4319,25 @@ yy644:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 450 "src/wast-lexer.cc"
- { OPCODE(F64Max); RETURN(BINARY); }
-#line 4273 "src/prebuilt/wast-lexer-gen.cc"
+#line 504 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, F64Max); }
+#line 4325 "src/prebuilt/wast-lexer-gen.cc"
yy646:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 448 "src/wast-lexer.cc"
- { OPCODE(F64Min); RETURN(BINARY); }
-#line 4281 "src/prebuilt/wast-lexer-gen.cc"
+#line 502 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, F64Min); }
+#line 4333 "src/prebuilt/wast-lexer-gen.cc"
yy648:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 444 "src/wast-lexer.cc"
- { OPCODE(F64Mul); RETURN(BINARY); }
-#line 4289 "src/prebuilt/wast-lexer-gen.cc"
+#line 498 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, F64Mul); }
+#line 4341 "src/prebuilt/wast-lexer-gen.cc"
yy650:
yych = *++cursor_;
if (yych == 'r') goto yy775;
@@ -4295,9 +4347,9 @@ yy651:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 396 "src/wast-lexer.cc"
- { OPCODE(F64Neg); RETURN(UNARY); }
-#line 4301 "src/prebuilt/wast-lexer-gen.cc"
+#line 450 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Unary, F64Neg); }
+#line 4353 "src/prebuilt/wast-lexer-gen.cc"
yy653:
yych = *++cursor_;
if (yych == 'm') goto yy776;
@@ -4319,9 +4371,9 @@ yy657:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 442 "src/wast-lexer.cc"
- { OPCODE(F64Sub); RETURN(BINARY); }
-#line 4325 "src/prebuilt/wast-lexer-gen.cc"
+#line 496 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, F64Sub); }
+#line 4377 "src/prebuilt/wast-lexer-gen.cc"
yy659:
yych = *++cursor_;
if (yych == 'n') goto yy781;
@@ -4343,25 +4395,25 @@ yy663:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 409 "src/wast-lexer.cc"
- { OPCODE(I32Add); RETURN(BINARY); }
-#line 4349 "src/prebuilt/wast-lexer-gen.cc"
+#line 463 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I32Add); }
+#line 4401 "src/prebuilt/wast-lexer-gen.cc"
yy665:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 423 "src/wast-lexer.cc"
- { OPCODE(I32And); RETURN(BINARY); }
-#line 4357 "src/prebuilt/wast-lexer-gen.cc"
+#line 477 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I32And); }
+#line 4409 "src/prebuilt/wast-lexer-gen.cc"
yy667:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 389 "src/wast-lexer.cc"
- { OPCODE(I32Clz); RETURN(UNARY); }
-#line 4365 "src/prebuilt/wast-lexer-gen.cc"
+#line 443 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Unary, I32Clz); }
+#line 4417 "src/prebuilt/wast-lexer-gen.cc"
yy669:
yych = *++cursor_;
if (yych == 's') goto yy785;
@@ -4371,9 +4423,9 @@ yy670:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 391 "src/wast-lexer.cc"
- { OPCODE(I32Ctz); RETURN(UNARY); }
-#line 4377 "src/prebuilt/wast-lexer-gen.cc"
+#line 445 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Unary, I32Ctz); }
+#line 4429 "src/prebuilt/wast-lexer-gen.cc"
yy672:
yych = *++cursor_;
if (yych == '_') goto yy786;
@@ -4383,9 +4435,9 @@ yy673:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 387 "src/wast-lexer.cc"
- { OPCODE(I32Eqz); RETURN(CONVERT); }
-#line 4389 "src/prebuilt/wast-lexer-gen.cc"
+#line 441 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, I32Eqz); }
+#line 4441 "src/prebuilt/wast-lexer-gen.cc"
yy675:
yych = *++cursor_;
if (yych == 's') goto yy787;
@@ -4415,9 +4467,9 @@ yy680:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 413 "src/wast-lexer.cc"
- { OPCODE(I32Mul); RETURN(BINARY); }
-#line 4421 "src/prebuilt/wast-lexer-gen.cc"
+#line 467 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I32Mul); }
+#line 4473 "src/prebuilt/wast-lexer-gen.cc"
yy682:
yych = *++cursor_;
if (yych == 'c') goto yy805;
@@ -4440,9 +4492,9 @@ yy686:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 429 "src/wast-lexer.cc"
- { OPCODE(I32Shl); RETURN(BINARY); }
-#line 4446 "src/prebuilt/wast-lexer-gen.cc"
+#line 483 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I32Shl); }
+#line 4498 "src/prebuilt/wast-lexer-gen.cc"
yy688:
yych = *++cursor_;
if (yych == '_') goto yy812;
@@ -4456,9 +4508,9 @@ yy690:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 411 "src/wast-lexer.cc"
- { OPCODE(I32Sub); RETURN(BINARY); }
-#line 4462 "src/prebuilt/wast-lexer-gen.cc"
+#line 465 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I32Sub); }
+#line 4514 "src/prebuilt/wast-lexer-gen.cc"
yy692:
yych = *++cursor_;
if (yych == 'n') goto yy814;
@@ -4472,33 +4524,33 @@ yy694:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 427 "src/wast-lexer.cc"
- { OPCODE(I32Xor); RETURN(BINARY); }
-#line 4478 "src/prebuilt/wast-lexer-gen.cc"
+#line 481 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I32Xor); }
+#line 4530 "src/prebuilt/wast-lexer-gen.cc"
yy696:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 410 "src/wast-lexer.cc"
- { OPCODE(I64Add); RETURN(BINARY); }
-#line 4486 "src/prebuilt/wast-lexer-gen.cc"
+#line 464 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I64Add); }
+#line 4538 "src/prebuilt/wast-lexer-gen.cc"
yy698:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 424 "src/wast-lexer.cc"
- { OPCODE(I64And); RETURN(BINARY); }
-#line 4494 "src/prebuilt/wast-lexer-gen.cc"
+#line 478 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I64And); }
+#line 4546 "src/prebuilt/wast-lexer-gen.cc"
yy700:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 390 "src/wast-lexer.cc"
- { OPCODE(I64Clz); RETURN(UNARY); }
-#line 4502 "src/prebuilt/wast-lexer-gen.cc"
+#line 444 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Unary, I64Clz); }
+#line 4554 "src/prebuilt/wast-lexer-gen.cc"
yy702:
yych = *++cursor_;
if (yych == 's') goto yy816;
@@ -4508,9 +4560,9 @@ yy703:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 392 "src/wast-lexer.cc"
- { OPCODE(I64Ctz); RETURN(UNARY); }
-#line 4514 "src/prebuilt/wast-lexer-gen.cc"
+#line 446 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Unary, I64Ctz); }
+#line 4566 "src/prebuilt/wast-lexer-gen.cc"
yy705:
yych = *++cursor_;
if (yych == '_') goto yy817;
@@ -4520,9 +4572,9 @@ yy706:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 388 "src/wast-lexer.cc"
- { OPCODE(I64Eqz); RETURN(CONVERT); }
-#line 4526 "src/prebuilt/wast-lexer-gen.cc"
+#line 442 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, I64Eqz); }
+#line 4578 "src/prebuilt/wast-lexer-gen.cc"
yy708:
yych = *++cursor_;
if (yych == 'e') goto yy818;
@@ -4556,9 +4608,9 @@ yy714:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 414 "src/wast-lexer.cc"
- { OPCODE(I64Mul); RETURN(BINARY); }
-#line 4562 "src/prebuilt/wast-lexer-gen.cc"
+#line 468 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I64Mul); }
+#line 4614 "src/prebuilt/wast-lexer-gen.cc"
yy716:
yych = *++cursor_;
if (yych == 'c') goto yy837;
@@ -4581,9 +4633,9 @@ yy720:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 430 "src/wast-lexer.cc"
- { OPCODE(I64Shl); RETURN(BINARY); }
-#line 4587 "src/prebuilt/wast-lexer-gen.cc"
+#line 484 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I64Shl); }
+#line 4639 "src/prebuilt/wast-lexer-gen.cc"
yy722:
yych = *++cursor_;
if (yych == '_') goto yy844;
@@ -4597,9 +4649,9 @@ yy724:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 412 "src/wast-lexer.cc"
- { OPCODE(I64Sub); RETURN(BINARY); }
-#line 4603 "src/prebuilt/wast-lexer-gen.cc"
+#line 466 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I64Sub); }
+#line 4655 "src/prebuilt/wast-lexer-gen.cc"
yy726:
yych = *++cursor_;
if (yych == 'n') goto yy846;
@@ -4609,9 +4661,9 @@ yy727:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 428 "src/wast-lexer.cc"
- { OPCODE(I64Xor); RETURN(BINARY); }
-#line 4615 "src/prebuilt/wast-lexer-gen.cc"
+#line 482 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I64Xor); }
+#line 4667 "src/prebuilt/wast-lexer-gen.cc"
yy729:
++cursor_;
if (limit_ <= cursor_) FILL(1);
@@ -4659,9 +4711,9 @@ yy733:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 549 "src/wast-lexer.cc"
- { RETURN(RETHROW); }
-#line 4665 "src/prebuilt/wast-lexer-gen.cc"
+#line 601 "src/wast-lexer.cc"
+ { RETURN(Rethrow); }
+#line 4717 "src/prebuilt/wast-lexer-gen.cc"
yy735:
yych = *++cursor_;
if (yych == 'b') goto yy853;
@@ -4757,9 +4809,9 @@ yy747:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 347 "src/wast-lexer.cc"
- { RETURN(BR_TABLE); }
-#line 4763 "src/prebuilt/wast-lexer-gen.cc"
+#line 401 "src/wast-lexer.cc"
+ { RETURN(BrTable); }
+#line 4815 "src/prebuilt/wast-lexer-gen.cc"
yy749:
yych = *++cursor_;
if (yych == 'i') goto yy865;
@@ -4777,9 +4829,9 @@ yy752:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 401 "src/wast-lexer.cc"
- { OPCODE(F32Ceil); RETURN(UNARY); }
-#line 4783 "src/prebuilt/wast-lexer-gen.cc"
+#line 455 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Unary, F32Ceil); }
+#line 4835 "src/prebuilt/wast-lexer-gen.cc"
yy754:
yych = *++cursor_;
if (yych == 't') goto yy869;
@@ -4805,9 +4857,9 @@ yy759:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 360 "src/wast-lexer.cc"
- { OPCODE(F32Load); RETURN(LOAD); }
-#line 4811 "src/prebuilt/wast-lexer-gen.cc"
+#line 414 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Load, F32Load); }
+#line 4863 "src/prebuilt/wast-lexer-gen.cc"
yy761:
yych = *++cursor_;
if (yych == 'e') goto yy876;
@@ -4821,9 +4873,9 @@ yy763:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 399 "src/wast-lexer.cc"
- { OPCODE(F32Sqrt); RETURN(UNARY); }
-#line 4827 "src/prebuilt/wast-lexer-gen.cc"
+#line 453 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Unary, F32Sqrt); }
+#line 4879 "src/prebuilt/wast-lexer-gen.cc"
yy765:
yych = *++cursor_;
if (yych == 'e') goto yy878;
@@ -4837,9 +4889,9 @@ yy767:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 402 "src/wast-lexer.cc"
- { OPCODE(F64Ceil); RETURN(UNARY); }
-#line 4843 "src/prebuilt/wast-lexer-gen.cc"
+#line 456 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Unary, F64Ceil); }
+#line 4895 "src/prebuilt/wast-lexer-gen.cc"
yy769:
yych = *++cursor_;
if (yych == 't') goto yy882;
@@ -4861,9 +4913,9 @@ yy773:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 361 "src/wast-lexer.cc"
- { OPCODE(F64Load); RETURN(LOAD); }
-#line 4867 "src/prebuilt/wast-lexer-gen.cc"
+#line 415 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Load, F64Load); }
+#line 4919 "src/prebuilt/wast-lexer-gen.cc"
yy775:
yych = *++cursor_;
if (yych == 'e') goto yy888;
@@ -4881,9 +4933,9 @@ yy778:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 400 "src/wast-lexer.cc"
- { OPCODE(F64Sqrt); RETURN(UNARY); }
-#line 4887 "src/prebuilt/wast-lexer-gen.cc"
+#line 454 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Unary, F64Sqrt); }
+#line 4939 "src/prebuilt/wast-lexer-gen.cc"
yy780:
yych = *++cursor_;
if (yych == 'e') goto yy891;
@@ -4918,49 +4970,49 @@ yy787:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 469 "src/wast-lexer.cc"
- { OPCODE(I32GeS); RETURN(COMPARE); }
-#line 4924 "src/prebuilt/wast-lexer-gen.cc"
+#line 523 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, I32GeS); }
+#line 4976 "src/prebuilt/wast-lexer-gen.cc"
yy789:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 471 "src/wast-lexer.cc"
- { OPCODE(I32GeU); RETURN(COMPARE); }
-#line 4932 "src/prebuilt/wast-lexer-gen.cc"
+#line 525 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, I32GeU); }
+#line 4984 "src/prebuilt/wast-lexer-gen.cc"
yy791:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 465 "src/wast-lexer.cc"
- { OPCODE(I32GtS); RETURN(COMPARE); }
-#line 4940 "src/prebuilt/wast-lexer-gen.cc"
+#line 519 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, I32GtS); }
+#line 4992 "src/prebuilt/wast-lexer-gen.cc"
yy793:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 467 "src/wast-lexer.cc"
- { OPCODE(I32GtU); RETURN(COMPARE); }
-#line 4948 "src/prebuilt/wast-lexer-gen.cc"
+#line 521 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, I32GtU); }
+#line 5000 "src/prebuilt/wast-lexer-gen.cc"
yy795:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 461 "src/wast-lexer.cc"
- { OPCODE(I32LeS); RETURN(COMPARE); }
-#line 4956 "src/prebuilt/wast-lexer-gen.cc"
+#line 515 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, I32LeS); }
+#line 5008 "src/prebuilt/wast-lexer-gen.cc"
yy797:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 463 "src/wast-lexer.cc"
- { OPCODE(I32LeU); RETURN(COMPARE); }
-#line 4964 "src/prebuilt/wast-lexer-gen.cc"
+#line 517 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, I32LeU); }
+#line 5016 "src/prebuilt/wast-lexer-gen.cc"
yy799:
++cursor_;
if ((yych = *cursor_) <= '0') {
@@ -4981,25 +5033,25 @@ yy799:
}
}
yy800:
-#line 358 "src/wast-lexer.cc"
- { OPCODE(I32Load); RETURN(LOAD); }
-#line 4987 "src/prebuilt/wast-lexer-gen.cc"
+#line 412 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Load, I32Load); }
+#line 5039 "src/prebuilt/wast-lexer-gen.cc"
yy801:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 457 "src/wast-lexer.cc"
- { OPCODE(I32LtS); RETURN(COMPARE); }
-#line 4995 "src/prebuilt/wast-lexer-gen.cc"
+#line 511 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, I32LtS); }
+#line 5047 "src/prebuilt/wast-lexer-gen.cc"
yy803:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 459 "src/wast-lexer.cc"
- { OPCODE(I32LtU); RETURN(COMPARE); }
-#line 5003 "src/prebuilt/wast-lexer-gen.cc"
+#line 513 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, I32LtU); }
+#line 5055 "src/prebuilt/wast-lexer-gen.cc"
yy805:
yych = *++cursor_;
if (yych == 'n') goto yy907;
@@ -5018,17 +5070,17 @@ yy808:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 435 "src/wast-lexer.cc"
- { OPCODE(I32Rotl); RETURN(BINARY); }
-#line 5024 "src/prebuilt/wast-lexer-gen.cc"
+#line 489 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I32Rotl); }
+#line 5076 "src/prebuilt/wast-lexer-gen.cc"
yy810:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 437 "src/wast-lexer.cc"
- { OPCODE(I32Rotr); RETURN(BINARY); }
-#line 5032 "src/prebuilt/wast-lexer-gen.cc"
+#line 491 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I32Rotr); }
+#line 5084 "src/prebuilt/wast-lexer-gen.cc"
yy812:
yych = *++cursor_;
if (yych == 's') goto yy913;
@@ -5064,49 +5116,49 @@ yy819:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 470 "src/wast-lexer.cc"
- { OPCODE(I64GeS); RETURN(COMPARE); }
-#line 5070 "src/prebuilt/wast-lexer-gen.cc"
+#line 524 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, I64GeS); }
+#line 5122 "src/prebuilt/wast-lexer-gen.cc"
yy821:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 472 "src/wast-lexer.cc"
- { OPCODE(I64GeU); RETURN(COMPARE); }
-#line 5078 "src/prebuilt/wast-lexer-gen.cc"
+#line 526 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, I64GeU); }
+#line 5130 "src/prebuilt/wast-lexer-gen.cc"
yy823:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 466 "src/wast-lexer.cc"
- { OPCODE(I64GtS); RETURN(COMPARE); }
-#line 5086 "src/prebuilt/wast-lexer-gen.cc"
+#line 520 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, I64GtS); }
+#line 5138 "src/prebuilt/wast-lexer-gen.cc"
yy825:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 468 "src/wast-lexer.cc"
- { OPCODE(I64GtU); RETURN(COMPARE); }
-#line 5094 "src/prebuilt/wast-lexer-gen.cc"
+#line 522 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, I64GtU); }
+#line 5146 "src/prebuilt/wast-lexer-gen.cc"
yy827:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 462 "src/wast-lexer.cc"
- { OPCODE(I64LeS); RETURN(COMPARE); }
-#line 5102 "src/prebuilt/wast-lexer-gen.cc"
+#line 516 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, I64LeS); }
+#line 5154 "src/prebuilt/wast-lexer-gen.cc"
yy829:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 464 "src/wast-lexer.cc"
- { OPCODE(I64LeU); RETURN(COMPARE); }
-#line 5110 "src/prebuilt/wast-lexer-gen.cc"
+#line 518 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, I64LeU); }
+#line 5162 "src/prebuilt/wast-lexer-gen.cc"
yy831:
++cursor_;
if ((yych = *cursor_) <= '1') {
@@ -5129,25 +5181,25 @@ yy831:
}
}
yy832:
-#line 359 "src/wast-lexer.cc"
- { OPCODE(I64Load); RETURN(LOAD); }
-#line 5135 "src/prebuilt/wast-lexer-gen.cc"
+#line 413 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Load, I64Load); }
+#line 5187 "src/prebuilt/wast-lexer-gen.cc"
yy833:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 458 "src/wast-lexer.cc"
- { OPCODE(I64LtS); RETURN(COMPARE); }
-#line 5143 "src/prebuilt/wast-lexer-gen.cc"
+#line 512 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, I64LtS); }
+#line 5195 "src/prebuilt/wast-lexer-gen.cc"
yy835:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 460 "src/wast-lexer.cc"
- { OPCODE(I64LtU); RETURN(COMPARE); }
-#line 5151 "src/prebuilt/wast-lexer-gen.cc"
+#line 514 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Compare, I64LtU); }
+#line 5203 "src/prebuilt/wast-lexer-gen.cc"
yy837:
yych = *++cursor_;
if (yych == 'n') goto yy931;
@@ -5166,17 +5218,17 @@ yy840:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 436 "src/wast-lexer.cc"
- { OPCODE(I64Rotl); RETURN(BINARY); }
-#line 5172 "src/prebuilt/wast-lexer-gen.cc"
+#line 490 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I64Rotl); }
+#line 5224 "src/prebuilt/wast-lexer-gen.cc"
yy842:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 438 "src/wast-lexer.cc"
- { OPCODE(I64Rotr); RETURN(BINARY); }
-#line 5180 "src/prebuilt/wast-lexer-gen.cc"
+#line 492 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I64Rotr); }
+#line 5232 "src/prebuilt/wast-lexer-gen.cc"
yy844:
yych = *++cursor_;
if (yych == 's') goto yy937;
@@ -5212,9 +5264,9 @@ yy847:
}
}
yy848:
-#line 381 "src/wast-lexer.cc"
- { SetTextAt(7); RETURN(OFFSET_EQ_NAT); }
-#line 5218 "src/prebuilt/wast-lexer-gen.cc"
+#line 435 "src/wast-lexer.cc"
+ { RETURN_TEXT_AT(OffsetEqNat, 7); }
+#line 5270 "src/prebuilt/wast-lexer-gen.cc"
yy849:
++cursor_;
if (limit_ <= cursor_) FILL(1);
@@ -5244,9 +5296,9 @@ yy851:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 532 "src/wast-lexer.cc"
- { RETURN(REGISTER); }
-#line 5250 "src/prebuilt/wast-lexer-gen.cc"
+#line 586 "src/wast-lexer.cc"
+ { RETURN(Register); }
+#line 5302 "src/prebuilt/wast-lexer-gen.cc"
yy853:
yych = *++cursor_;
if (yych == 'a') goto yy946;
@@ -5328,9 +5380,9 @@ yy866:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 547 "src/wast-lexer.cc"
- { RETURN_LPAR(CATCH_ALL); }
-#line 5334 "src/prebuilt/wast-lexer-gen.cc"
+#line 599 "src/wast-lexer.cc"
+ { RETURN(CatchAll); }
+#line 5386 "src/prebuilt/wast-lexer-gen.cc"
yy868:
yych = *++cursor_;
if (yych == 'e') goto yy959;
@@ -5340,9 +5392,9 @@ yy869:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 385 "src/wast-lexer.cc"
- { TYPE(F32); RETURN(CONST); }
-#line 5346 "src/prebuilt/wast-lexer-gen.cc"
+#line 439 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Const, F32Const); }
+#line 5398 "src/prebuilt/wast-lexer-gen.cc"
yy871:
yych = *++cursor_;
if (yych == 'r') goto yy960;
@@ -5360,9 +5412,9 @@ yy874:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 403 "src/wast-lexer.cc"
- { OPCODE(F32Floor); RETURN(UNARY); }
-#line 5366 "src/prebuilt/wast-lexer-gen.cc"
+#line 457 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Unary, F32Floor); }
+#line 5418 "src/prebuilt/wast-lexer-gen.cc"
yy876:
yych = *++cursor_;
if (yych == 's') goto yy963;
@@ -5376,25 +5428,25 @@ yy878:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 364 "src/wast-lexer.cc"
- { OPCODE(F32Store); RETURN(STORE); }
-#line 5382 "src/prebuilt/wast-lexer-gen.cc"
+#line 418 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Store, F32Store); }
+#line 5434 "src/prebuilt/wast-lexer-gen.cc"
yy880:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 405 "src/wast-lexer.cc"
- { OPCODE(F32Trunc); RETURN(UNARY); }
-#line 5390 "src/prebuilt/wast-lexer-gen.cc"
+#line 459 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Unary, F32Trunc); }
+#line 5442 "src/prebuilt/wast-lexer-gen.cc"
yy882:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 386 "src/wast-lexer.cc"
- { TYPE(F64); RETURN(CONST); }
-#line 5398 "src/prebuilt/wast-lexer-gen.cc"
+#line 440 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Const, F64Const); }
+#line 5450 "src/prebuilt/wast-lexer-gen.cc"
yy884:
yych = *++cursor_;
if (yych == 'r') goto yy965;
@@ -5408,9 +5460,9 @@ yy886:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 404 "src/wast-lexer.cc"
- { OPCODE(F64Floor); RETURN(UNARY); }
-#line 5414 "src/prebuilt/wast-lexer-gen.cc"
+#line 458 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Unary, F64Floor); }
+#line 5466 "src/prebuilt/wast-lexer-gen.cc"
yy888:
yych = *++cursor_;
if (yych == 's') goto yy967;
@@ -5428,17 +5480,17 @@ yy891:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 365 "src/wast-lexer.cc"
- { OPCODE(F64Store); RETURN(STORE); }
-#line 5434 "src/prebuilt/wast-lexer-gen.cc"
+#line 419 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Store, F64Store); }
+#line 5486 "src/prebuilt/wast-lexer-gen.cc"
yy893:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 406 "src/wast-lexer.cc"
- { OPCODE(F64Trunc); RETURN(UNARY); }
-#line 5442 "src/prebuilt/wast-lexer-gen.cc"
+#line 460 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Unary, F64Trunc); }
+#line 5494 "src/prebuilt/wast-lexer-gen.cc"
yy895:
yych = *++cursor_;
if (yych == 'l') goto yy970;
@@ -5448,9 +5500,9 @@ yy896:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 353 "src/wast-lexer.cc"
- { RETURN(GET_LOCAL); }
-#line 5454 "src/prebuilt/wast-lexer-gen.cc"
+#line 407 "src/wast-lexer.cc"
+ { RETURN(GetLocal); }
+#line 5506 "src/prebuilt/wast-lexer-gen.cc"
yy898:
yych = *++cursor_;
if (yych == 'r') goto yy972;
@@ -5460,25 +5512,25 @@ yy899:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 383 "src/wast-lexer.cc"
- { TYPE(I32); RETURN(CONST); }
-#line 5466 "src/prebuilt/wast-lexer-gen.cc"
+#line 437 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Const, I32Const); }
+#line 5518 "src/prebuilt/wast-lexer-gen.cc"
yy901:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 415 "src/wast-lexer.cc"
- { OPCODE(I32DivS); RETURN(BINARY); }
-#line 5474 "src/prebuilt/wast-lexer-gen.cc"
+#line 469 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I32DivS); }
+#line 5526 "src/prebuilt/wast-lexer-gen.cc"
yy903:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 417 "src/wast-lexer.cc"
- { OPCODE(I32DivU); RETURN(BINARY); }
-#line 5482 "src/prebuilt/wast-lexer-gen.cc"
+#line 471 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I32DivU); }
+#line 5534 "src/prebuilt/wast-lexer-gen.cc"
yy905:
yych = *++cursor_;
if (yych == '6') goto yy973;
@@ -5500,33 +5552,33 @@ yy909:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 419 "src/wast-lexer.cc"
- { OPCODE(I32RemS); RETURN(BINARY); }
-#line 5506 "src/prebuilt/wast-lexer-gen.cc"
+#line 473 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I32RemS); }
+#line 5558 "src/prebuilt/wast-lexer-gen.cc"
yy911:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 421 "src/wast-lexer.cc"
- { OPCODE(I32RemU); RETURN(BINARY); }
-#line 5514 "src/prebuilt/wast-lexer-gen.cc"
+#line 475 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I32RemU); }
+#line 5566 "src/prebuilt/wast-lexer-gen.cc"
yy913:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 431 "src/wast-lexer.cc"
- { OPCODE(I32ShrS); RETURN(BINARY); }
-#line 5522 "src/prebuilt/wast-lexer-gen.cc"
+#line 485 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I32ShrS); }
+#line 5574 "src/prebuilt/wast-lexer-gen.cc"
yy915:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 433 "src/wast-lexer.cc"
- { OPCODE(I32ShrU); RETURN(BINARY); }
-#line 5530 "src/prebuilt/wast-lexer-gen.cc"
+#line 487 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I32ShrU); }
+#line 5582 "src/prebuilt/wast-lexer-gen.cc"
yy917:
++cursor_;
if ((yych = *cursor_) <= '0') {
@@ -5547,9 +5599,9 @@ yy917:
}
}
yy918:
-#line 362 "src/wast-lexer.cc"
- { OPCODE(I32Store); RETURN(STORE); }
-#line 5553 "src/prebuilt/wast-lexer-gen.cc"
+#line 416 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Store, I32Store); }
+#line 5605 "src/prebuilt/wast-lexer-gen.cc"
yy919:
yych = *++cursor_;
if (yych == '_') goto yy981;
@@ -5563,25 +5615,25 @@ yy921:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 384 "src/wast-lexer.cc"
- { TYPE(I64); RETURN(CONST); }
-#line 5569 "src/prebuilt/wast-lexer-gen.cc"
+#line 438 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Const, I64Const); }
+#line 5621 "src/prebuilt/wast-lexer-gen.cc"
yy923:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 416 "src/wast-lexer.cc"
- { OPCODE(I64DivS); RETURN(BINARY); }
-#line 5577 "src/prebuilt/wast-lexer-gen.cc"
+#line 470 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I64DivS); }
+#line 5629 "src/prebuilt/wast-lexer-gen.cc"
yy925:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 418 "src/wast-lexer.cc"
- { OPCODE(I64DivU); RETURN(BINARY); }
-#line 5585 "src/prebuilt/wast-lexer-gen.cc"
+#line 472 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I64DivU); }
+#line 5637 "src/prebuilt/wast-lexer-gen.cc"
yy927:
yych = *++cursor_;
if (yych == 'd') goto yy983;
@@ -5611,33 +5663,33 @@ yy933:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 420 "src/wast-lexer.cc"
- { OPCODE(I64RemS); RETURN(BINARY); }
-#line 5617 "src/prebuilt/wast-lexer-gen.cc"
+#line 474 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I64RemS); }
+#line 5669 "src/prebuilt/wast-lexer-gen.cc"
yy935:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 422 "src/wast-lexer.cc"
- { OPCODE(I64RemU); RETURN(BINARY); }
-#line 5625 "src/prebuilt/wast-lexer-gen.cc"
+#line 476 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I64RemU); }
+#line 5677 "src/prebuilt/wast-lexer-gen.cc"
yy937:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 432 "src/wast-lexer.cc"
- { OPCODE(I64ShrS); RETURN(BINARY); }
-#line 5633 "src/prebuilt/wast-lexer-gen.cc"
+#line 486 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I64ShrS); }
+#line 5685 "src/prebuilt/wast-lexer-gen.cc"
yy939:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 434 "src/wast-lexer.cc"
- { OPCODE(I64ShrU); RETURN(BINARY); }
-#line 5641 "src/prebuilt/wast-lexer-gen.cc"
+#line 488 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, I64ShrU); }
+#line 5693 "src/prebuilt/wast-lexer-gen.cc"
yy941:
++cursor_;
if ((yych = *cursor_) <= '1') {
@@ -5660,9 +5712,9 @@ yy941:
}
}
yy942:
-#line 363 "src/wast-lexer.cc"
- { OPCODE(I64Store); RETURN(STORE); }
-#line 5666 "src/prebuilt/wast-lexer-gen.cc"
+#line 417 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Store, I64Store); }
+#line 5718 "src/prebuilt/wast-lexer-gen.cc"
yy943:
yych = *++cursor_;
if (yych == '_') goto yy994;
@@ -5726,17 +5778,17 @@ yy947:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 354 "src/wast-lexer.cc"
- { RETURN(SET_LOCAL); }
-#line 5732 "src/prebuilt/wast-lexer-gen.cc"
+#line 408 "src/wast-lexer.cc"
+ { RETURN(SetLocal); }
+#line 5784 "src/prebuilt/wast-lexer-gen.cc"
yy949:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 355 "src/wast-lexer.cc"
- { RETURN(TEE_LOCAL); }
-#line 5740 "src/prebuilt/wast-lexer-gen.cc"
+#line 409 "src/wast-lexer.cc"
+ { RETURN(TeeLocal); }
+#line 5792 "src/prebuilt/wast-lexer-gen.cc"
yy951:
yych = *++cursor_;
if (yych == 'l') goto yy999;
@@ -5818,9 +5870,9 @@ yy970:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 356 "src/wast-lexer.cc"
- { RETURN(GET_GLOBAL); }
-#line 5824 "src/prebuilt/wast-lexer-gen.cc"
+#line 410 "src/wast-lexer.cc"
+ { RETURN(GetGlobal); }
+#line 5876 "src/prebuilt/wast-lexer-gen.cc"
yy972:
yych = *++cursor_;
if (yych == 'y') goto yy1021;
@@ -5839,9 +5891,9 @@ yy975:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 393 "src/wast-lexer.cc"
- { OPCODE(I32Popcnt); RETURN(UNARY); }
-#line 5845 "src/prebuilt/wast-lexer-gen.cc"
+#line 447 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Unary, I32Popcnt); }
+#line 5897 "src/prebuilt/wast-lexer-gen.cc"
yy977:
yych = *++cursor_;
if (yych == 'r') goto yy1028;
@@ -5855,9 +5907,9 @@ yy979:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 376 "src/wast-lexer.cc"
- { OPCODE(I32Store8); RETURN(STORE); }
-#line 5861 "src/prebuilt/wast-lexer-gen.cc"
+#line 430 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Store, I32Store8); }
+#line 5913 "src/prebuilt/wast-lexer-gen.cc"
yy981:
yych = *++cursor_;
if (yych == 's') goto yy1031;
@@ -5889,9 +5941,9 @@ yy987:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 394 "src/wast-lexer.cc"
- { OPCODE(I64Popcnt); RETURN(UNARY); }
-#line 5895 "src/prebuilt/wast-lexer-gen.cc"
+#line 448 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Unary, I64Popcnt); }
+#line 5947 "src/prebuilt/wast-lexer-gen.cc"
yy989:
yych = *++cursor_;
if (yych == 'r') goto yy1041;
@@ -5909,9 +5961,9 @@ yy992:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 377 "src/wast-lexer.cc"
- { OPCODE(I64Store8); RETURN(STORE); }
-#line 5915 "src/prebuilt/wast-lexer-gen.cc"
+#line 431 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Store, I64Store8); }
+#line 5967 "src/prebuilt/wast-lexer-gen.cc"
yy994:
yych = *++cursor_;
if (yych == 's') goto yy1046;
@@ -5954,9 +6006,9 @@ yy997:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 357 "src/wast-lexer.cc"
- { RETURN(SET_GLOBAL); }
-#line 5960 "src/prebuilt/wast-lexer-gen.cc"
+#line 411 "src/wast-lexer.cc"
+ { RETURN(SetGlobal); }
+#line 6012 "src/prebuilt/wast-lexer-gen.cc"
yy999:
yych = *++cursor_;
if (yych == 'e') goto yy1048;
@@ -5982,9 +6034,9 @@ yy1004:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 543 "src/wast-lexer.cc"
- { RETURN(ASSERT_TRAP); }
-#line 5988 "src/prebuilt/wast-lexer-gen.cc"
+#line 595 "src/wast-lexer.cc"
+ { RETURN(AssertTrap); }
+#line 6040 "src/prebuilt/wast-lexer-gen.cc"
yy1006:
yych = *++cursor_;
if (yych == 'n') goto yy1054;
@@ -6014,9 +6066,9 @@ yy1012:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 407 "src/wast-lexer.cc"
- { OPCODE(F32Nearest); RETURN(UNARY); }
-#line 6020 "src/prebuilt/wast-lexer-gen.cc"
+#line 461 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Unary, F32Nearest); }
+#line 6072 "src/prebuilt/wast-lexer-gen.cc"
yy1014:
yych = *++cursor_;
if (yych == 'p') goto yy1061;
@@ -6034,9 +6086,9 @@ yy1017:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 408 "src/wast-lexer.cc"
- { OPCODE(F64Nearest); RETURN(UNARY); }
-#line 6040 "src/prebuilt/wast-lexer-gen.cc"
+#line 462 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Unary, F64Nearest); }
+#line 6092 "src/prebuilt/wast-lexer-gen.cc"
yy1019:
yych = *++cursor_;
if (yych == '/') goto yy1065;
@@ -6050,9 +6102,9 @@ yy1021:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 513 "src/wast-lexer.cc"
- { RETURN(GROW_MEMORY); }
-#line 6056 "src/prebuilt/wast-lexer-gen.cc"
+#line 567 "src/wast-lexer.cc"
+ { RETURN(GrowMemory); }
+#line 6108 "src/prebuilt/wast-lexer-gen.cc"
yy1023:
yych = *++cursor_;
if (yych == 's') goto yy1067;
@@ -6063,17 +6115,17 @@ yy1024:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 366 "src/wast-lexer.cc"
- { OPCODE(I32Load8S); RETURN(LOAD); }
-#line 6069 "src/prebuilt/wast-lexer-gen.cc"
+#line 420 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Load, I32Load8S); }
+#line 6121 "src/prebuilt/wast-lexer-gen.cc"
yy1026:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 368 "src/wast-lexer.cc"
- { OPCODE(I32Load8U); RETURN(LOAD); }
-#line 6077 "src/prebuilt/wast-lexer-gen.cc"
+#line 422 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Load, I32Load8U); }
+#line 6129 "src/prebuilt/wast-lexer-gen.cc"
yy1028:
yych = *++cursor_;
if (yych == 'p') goto yy1071;
@@ -6083,9 +6135,9 @@ yy1029:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 378 "src/wast-lexer.cc"
- { OPCODE(I32Store16); RETURN(STORE); }
-#line 6089 "src/prebuilt/wast-lexer-gen.cc"
+#line 432 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Store, I32Store16); }
+#line 6141 "src/prebuilt/wast-lexer-gen.cc"
yy1031:
yych = *++cursor_;
if (yych == '/') goto yy1072;
@@ -6118,17 +6170,17 @@ yy1037:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 367 "src/wast-lexer.cc"
- { OPCODE(I64Load8S); RETURN(LOAD); }
-#line 6124 "src/prebuilt/wast-lexer-gen.cc"
+#line 421 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Load, I64Load8S); }
+#line 6176 "src/prebuilt/wast-lexer-gen.cc"
yy1039:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 369 "src/wast-lexer.cc"
- { OPCODE(I64Load8U); RETURN(LOAD); }
-#line 6132 "src/prebuilt/wast-lexer-gen.cc"
+#line 423 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Load, I64Load8U); }
+#line 6184 "src/prebuilt/wast-lexer-gen.cc"
yy1041:
yych = *++cursor_;
if (yych == 'p') goto yy1086;
@@ -6138,17 +6190,17 @@ yy1042:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 379 "src/wast-lexer.cc"
- { OPCODE(I64Store16); RETURN(STORE); }
-#line 6144 "src/prebuilt/wast-lexer-gen.cc"
+#line 433 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Store, I64Store16); }
+#line 6196 "src/prebuilt/wast-lexer-gen.cc"
yy1044:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 380 "src/wast-lexer.cc"
- { OPCODE(I64Store32); RETURN(STORE); }
-#line 6152 "src/prebuilt/wast-lexer-gen.cc"
+#line 434 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Store, I64Store32); }
+#line 6204 "src/prebuilt/wast-lexer-gen.cc"
yy1046:
yych = *++cursor_;
if (yych == '/') goto yy1087;
@@ -6162,9 +6214,9 @@ yy1048:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 511 "src/wast-lexer.cc"
- { RETURN(UNREACHABLE); }
-#line 6168 "src/prebuilt/wast-lexer-gen.cc"
+#line 565 "src/wast-lexer.cc"
+ { RETURN(Unreachable); }
+#line 6220 "src/prebuilt/wast-lexer-gen.cc"
yy1050:
yych = *++cursor_;
if (yych == 's') goto yy1089;
@@ -6203,9 +6255,9 @@ yy1058:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 451 "src/wast-lexer.cc"
- { OPCODE(F32Copysign); RETURN(BINARY); }
-#line 6209 "src/prebuilt/wast-lexer-gen.cc"
+#line 505 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, F32Copysign); }
+#line 6261 "src/prebuilt/wast-lexer-gen.cc"
yy1060:
yych = *++cursor_;
if (yych == '6') goto yy1100;
@@ -6224,9 +6276,9 @@ yy1063:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 452 "src/wast-lexer.cc"
- { OPCODE(F64Copysign); RETURN(BINARY); }
-#line 6230 "src/prebuilt/wast-lexer-gen.cc"
+#line 506 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Binary, F64Copysign); }
+#line 6282 "src/prebuilt/wast-lexer-gen.cc"
yy1065:
yych = *++cursor_;
if (yych == 'f') goto yy1104;
@@ -6240,17 +6292,17 @@ yy1067:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 370 "src/wast-lexer.cc"
- { OPCODE(I32Load16S); RETURN(LOAD); }
-#line 6246 "src/prebuilt/wast-lexer-gen.cc"
+#line 424 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Load, I32Load16S); }
+#line 6298 "src/prebuilt/wast-lexer-gen.cc"
yy1069:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 372 "src/wast-lexer.cc"
- { OPCODE(I32Load16U); RETURN(LOAD); }
-#line 6254 "src/prebuilt/wast-lexer-gen.cc"
+#line 426 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Load, I32Load16U); }
+#line 6306 "src/prebuilt/wast-lexer-gen.cc"
yy1071:
yych = *++cursor_;
if (yych == 'r') goto yy1106;
@@ -6268,9 +6320,9 @@ yy1074:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 487 "src/wast-lexer.cc"
- { OPCODE(I32WrapI64); RETURN(CONVERT); }
-#line 6274 "src/prebuilt/wast-lexer-gen.cc"
+#line 541 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, I32WrapI64); }
+#line 6326 "src/prebuilt/wast-lexer-gen.cc"
yy1076:
yych = *++cursor_;
if (yych == '/') goto yy1109;
@@ -6284,33 +6336,33 @@ yy1078:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 371 "src/wast-lexer.cc"
- { OPCODE(I64Load16S); RETURN(LOAD); }
-#line 6290 "src/prebuilt/wast-lexer-gen.cc"
+#line 425 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Load, I64Load16S); }
+#line 6342 "src/prebuilt/wast-lexer-gen.cc"
yy1080:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 373 "src/wast-lexer.cc"
- { OPCODE(I64Load16U); RETURN(LOAD); }
-#line 6298 "src/prebuilt/wast-lexer-gen.cc"
+#line 427 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Load, I64Load16U); }
+#line 6350 "src/prebuilt/wast-lexer-gen.cc"
yy1082:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 374 "src/wast-lexer.cc"
- { OPCODE(I64Load32S); RETURN(LOAD); }
-#line 6306 "src/prebuilt/wast-lexer-gen.cc"
+#line 428 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Load, I64Load32S); }
+#line 6358 "src/prebuilt/wast-lexer-gen.cc"
yy1084:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 375 "src/wast-lexer.cc"
- { OPCODE(I64Load32U); RETURN(LOAD); }
-#line 6314 "src/prebuilt/wast-lexer-gen.cc"
+#line 429 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Load, I64Load32U); }
+#line 6366 "src/prebuilt/wast-lexer-gen.cc"
yy1086:
yych = *++cursor_;
if (yych == 'r') goto yy1111;
@@ -6353,9 +6405,9 @@ yy1092:
}
}
yy1093:
-#line 538 "src/wast-lexer.cc"
- { RETURN(ASSERT_RETURN); }
-#line 6359 "src/prebuilt/wast-lexer-gen.cc"
+#line 592 "src/wast-lexer.cc"
+ { RETURN(AssertReturn); }
+#line 6411 "src/prebuilt/wast-lexer-gen.cc"
yy1094:
yych = *++cursor_;
if (yych == 'a') goto yy1119;
@@ -6365,9 +6417,9 @@ yy1095:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 349 "src/wast-lexer.cc"
- { RETURN(CALL_INDIRECT); }
-#line 6371 "src/prebuilt/wast-lexer-gen.cc"
+#line 403 "src/wast-lexer.cc"
+ { RETURN(CallIndirect); }
+#line 6423 "src/prebuilt/wast-lexer-gen.cc"
yy1097:
yych = *++cursor_;
if (yych == 'y') goto yy1120;
@@ -6449,9 +6501,9 @@ yy1115:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 536 "src/wast-lexer.cc"
- { RETURN(ASSERT_INVALID); }
-#line 6455 "src/prebuilt/wast-lexer-gen.cc"
+#line 590 "src/wast-lexer.cc"
+ { RETURN(AssertInvalid); }
+#line 6507 "src/prebuilt/wast-lexer-gen.cc"
yy1117:
yych = *++cursor_;
if (yych == 'e') goto yy1144;
@@ -6470,9 +6522,9 @@ yy1120:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 512 "src/wast-lexer.cc"
- { RETURN(CURRENT_MEMORY); }
-#line 6476 "src/prebuilt/wast-lexer-gen.cc"
+#line 566 "src/wast-lexer.cc"
+ { RETURN(CurrentMemory); }
+#line 6528 "src/prebuilt/wast-lexer-gen.cc"
yy1122:
yych = *++cursor_;
if (yych == 'i') goto yy1148;
@@ -6486,9 +6538,9 @@ yy1124:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 505 "src/wast-lexer.cc"
- { OPCODE(F32DemoteF64); RETURN(CONVERT); }
-#line 6492 "src/prebuilt/wast-lexer-gen.cc"
+#line 559 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, F32DemoteF64); }
+#line 6544 "src/prebuilt/wast-lexer-gen.cc"
yy1126:
yych = *++cursor_;
if (yych == 't') goto yy1150;
@@ -6606,9 +6658,9 @@ yy1153:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 504 "src/wast-lexer.cc"
- { OPCODE(F64PromoteF32); RETURN(CONVERT); }
-#line 6612 "src/prebuilt/wast-lexer-gen.cc"
+#line 558 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, F64PromoteF32); }
+#line 6664 "src/prebuilt/wast-lexer-gen.cc"
yy1155:
yych = *++cursor_;
if (yych == '/') goto yy1191;
@@ -6622,33 +6674,33 @@ yy1157:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 488 "src/wast-lexer.cc"
- { OPCODE(I32TruncSF32); RETURN(CONVERT); }
-#line 6628 "src/prebuilt/wast-lexer-gen.cc"
+#line 542 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, I32TruncSF32); }
+#line 6680 "src/prebuilt/wast-lexer-gen.cc"
yy1159:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 490 "src/wast-lexer.cc"
- { OPCODE(I32TruncSF64); RETURN(CONVERT); }
-#line 6636 "src/prebuilt/wast-lexer-gen.cc"
+#line 544 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, I32TruncSF64); }
+#line 6688 "src/prebuilt/wast-lexer-gen.cc"
yy1161:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 492 "src/wast-lexer.cc"
- { OPCODE(I32TruncUF32); RETURN(CONVERT); }
-#line 6644 "src/prebuilt/wast-lexer-gen.cc"
+#line 546 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, I32TruncUF32); }
+#line 6696 "src/prebuilt/wast-lexer-gen.cc"
yy1163:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 494 "src/wast-lexer.cc"
- { OPCODE(I32TruncUF64); RETURN(CONVERT); }
-#line 6652 "src/prebuilt/wast-lexer-gen.cc"
+#line 548 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, I32TruncUF64); }
+#line 6704 "src/prebuilt/wast-lexer-gen.cc"
yy1165:
yych = *++cursor_;
if (yych == '2') goto yy1193;
@@ -6666,33 +6718,33 @@ yy1168:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 489 "src/wast-lexer.cc"
- { OPCODE(I64TruncSF32); RETURN(CONVERT); }
-#line 6672 "src/prebuilt/wast-lexer-gen.cc"
+#line 543 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, I64TruncSF32); }
+#line 6724 "src/prebuilt/wast-lexer-gen.cc"
yy1170:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 491 "src/wast-lexer.cc"
- { OPCODE(I64TruncSF64); RETURN(CONVERT); }
-#line 6680 "src/prebuilt/wast-lexer-gen.cc"
+#line 545 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, I64TruncSF64); }
+#line 6732 "src/prebuilt/wast-lexer-gen.cc"
yy1172:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 493 "src/wast-lexer.cc"
- { OPCODE(I64TruncUF32); RETURN(CONVERT); }
-#line 6688 "src/prebuilt/wast-lexer-gen.cc"
+#line 547 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, I64TruncUF32); }
+#line 6740 "src/prebuilt/wast-lexer-gen.cc"
yy1174:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 495 "src/wast-lexer.cc"
- { OPCODE(I64TruncUF64); RETURN(CONVERT); }
-#line 6696 "src/prebuilt/wast-lexer-gen.cc"
+#line 549 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, I64TruncUF64); }
+#line 6748 "src/prebuilt/wast-lexer-gen.cc"
yy1176:
yych = *++cursor_;
if (yych == 'n') goto yy1198;
@@ -6702,9 +6754,9 @@ yy1177:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 535 "src/wast-lexer.cc"
- { RETURN(ASSERT_MALFORMED); }
-#line 6708 "src/prebuilt/wast-lexer-gen.cc"
+#line 589 "src/wast-lexer.cc"
+ { RETURN(AssertMalformed); }
+#line 6760 "src/prebuilt/wast-lexer-gen.cc"
yy1179:
yych = *++cursor_;
if (yych == 'i') goto yy1200;
@@ -6766,17 +6818,17 @@ yy1193:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 485 "src/wast-lexer.cc"
- { OPCODE(I64ExtendSI32); RETURN(CONVERT); }
-#line 6772 "src/prebuilt/wast-lexer-gen.cc"
+#line 539 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, I64ExtendSI32); }
+#line 6824 "src/prebuilt/wast-lexer-gen.cc"
yy1195:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 486 "src/wast-lexer.cc"
- { OPCODE(I64ExtendUI32); RETURN(CONVERT); }
-#line 6780 "src/prebuilt/wast-lexer-gen.cc"
+#line 540 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, I64ExtendUI32); }
+#line 6832 "src/prebuilt/wast-lexer-gen.cc"
yy1197:
yych = *++cursor_;
if (yych == 'f') goto yy1223;
@@ -6786,9 +6838,9 @@ yy1198:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 544 "src/wast-lexer.cc"
- { RETURN(ASSERT_EXHAUSTION); }
-#line 6792 "src/prebuilt/wast-lexer-gen.cc"
+#line 596 "src/wast-lexer.cc"
+ { RETURN(AssertExhaustion); }
+#line 6844 "src/prebuilt/wast-lexer-gen.cc"
yy1200:
yych = *++cursor_;
if (yych == 't') goto yy1224;
@@ -6802,41 +6854,41 @@ yy1202:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 537 "src/wast-lexer.cc"
- { RETURN(ASSERT_UNLINKABLE); }
-#line 6808 "src/prebuilt/wast-lexer-gen.cc"
+#line 591 "src/wast-lexer.cc"
+ { RETURN(AssertUnlinkable); }
+#line 6860 "src/prebuilt/wast-lexer-gen.cc"
yy1204:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 496 "src/wast-lexer.cc"
- { OPCODE(F32ConvertSI32); RETURN(CONVERT); }
-#line 6816 "src/prebuilt/wast-lexer-gen.cc"
+#line 550 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, F32ConvertSI32); }
+#line 6868 "src/prebuilt/wast-lexer-gen.cc"
yy1206:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 498 "src/wast-lexer.cc"
- { OPCODE(F32ConvertSI64); RETURN(CONVERT); }
-#line 6824 "src/prebuilt/wast-lexer-gen.cc"
+#line 552 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, F32ConvertSI64); }
+#line 6876 "src/prebuilt/wast-lexer-gen.cc"
yy1208:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 500 "src/wast-lexer.cc"
- { OPCODE(F32ConvertUI32); RETURN(CONVERT); }
-#line 6832 "src/prebuilt/wast-lexer-gen.cc"
+#line 554 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, F32ConvertUI32); }
+#line 6884 "src/prebuilt/wast-lexer-gen.cc"
yy1210:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 502 "src/wast-lexer.cc"
- { OPCODE(F32ConvertUI64); RETURN(CONVERT); }
-#line 6840 "src/prebuilt/wast-lexer-gen.cc"
+#line 556 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, F32ConvertUI64); }
+#line 6892 "src/prebuilt/wast-lexer-gen.cc"
yy1212:
yych = *++cursor_;
if (yych == '3') goto yy1226;
@@ -6846,33 +6898,33 @@ yy1213:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 497 "src/wast-lexer.cc"
- { OPCODE(F64ConvertSI32); RETURN(CONVERT); }
-#line 6852 "src/prebuilt/wast-lexer-gen.cc"
+#line 551 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, F64ConvertSI32); }
+#line 6904 "src/prebuilt/wast-lexer-gen.cc"
yy1215:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 499 "src/wast-lexer.cc"
- { OPCODE(F64ConvertSI64); RETURN(CONVERT); }
-#line 6860 "src/prebuilt/wast-lexer-gen.cc"
+#line 553 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, F64ConvertSI64); }
+#line 6912 "src/prebuilt/wast-lexer-gen.cc"
yy1217:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 501 "src/wast-lexer.cc"
- { OPCODE(F64ConvertUI32); RETURN(CONVERT); }
-#line 6868 "src/prebuilt/wast-lexer-gen.cc"
+#line 555 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, F64ConvertUI32); }
+#line 6920 "src/prebuilt/wast-lexer-gen.cc"
yy1219:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 503 "src/wast-lexer.cc"
- { OPCODE(F64ConvertUI64); RETURN(CONVERT); }
-#line 6876 "src/prebuilt/wast-lexer-gen.cc"
+#line 557 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, F64ConvertUI64); }
+#line 6928 "src/prebuilt/wast-lexer-gen.cc"
yy1221:
yych = *++cursor_;
if (yych == '6') goto yy1227;
@@ -6922,33 +6974,33 @@ yy1232:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 506 "src/wast-lexer.cc"
- { OPCODE(F32ReinterpretI32); RETURN(CONVERT); }
-#line 6928 "src/prebuilt/wast-lexer-gen.cc"
+#line 560 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, F32ReinterpretI32); }
+#line 6980 "src/prebuilt/wast-lexer-gen.cc"
yy1234:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 508 "src/wast-lexer.cc"
- { OPCODE(F64ReinterpretI64); RETURN(CONVERT); }
-#line 6936 "src/prebuilt/wast-lexer-gen.cc"
+#line 562 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, F64ReinterpretI64); }
+#line 6988 "src/prebuilt/wast-lexer-gen.cc"
yy1236:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 507 "src/wast-lexer.cc"
- { OPCODE(I32ReinterpretF32); RETURN(CONVERT); }
-#line 6944 "src/prebuilt/wast-lexer-gen.cc"
+#line 561 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, I32ReinterpretF32); }
+#line 6996 "src/prebuilt/wast-lexer-gen.cc"
yy1238:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 509 "src/wast-lexer.cc"
- { OPCODE(I64ReinterpretF64); RETURN(CONVERT); }
-#line 6952 "src/prebuilt/wast-lexer-gen.cc"
+#line 563 "src/wast-lexer.cc"
+ { RETURN_OPCODE(Convert, I64ReinterpretF64); }
+#line 7004 "src/prebuilt/wast-lexer-gen.cc"
yy1240:
yych = *++cursor_;
if (yych == 'e') goto yy1242;
@@ -7014,22 +7066,20 @@ yy1255:
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 539 "src/wast-lexer.cc"
- {
- RETURN(ASSERT_RETURN_CANONICAL_NAN); }
-#line 7021 "src/prebuilt/wast-lexer-gen.cc"
+#line 593 "src/wast-lexer.cc"
+ { RETURN(AssertReturnCanonicalNan); }
+#line 7072 "src/prebuilt/wast-lexer-gen.cc"
yy1257:
++cursor_;
if (yybm[0+(yych = *cursor_)] & 8) {
goto yy86;
}
-#line 541 "src/wast-lexer.cc"
- {
- RETURN(ASSERT_RETURN_ARITHMETIC_NAN); }
-#line 7030 "src/prebuilt/wast-lexer-gen.cc"
+#line 594 "src/wast-lexer.cc"
+ { RETURN(AssertReturnArithmeticNan); }
+#line 7080 "src/prebuilt/wast-lexer-gen.cc"
}
}
-#line 570 "src/wast-lexer.cc"
+#line 620 "src/wast-lexer.cc"
}
}
diff --git a/src/prebuilt/wast-parser-gen.cc b/src/prebuilt/wast-parser-gen.cc
deleted file mode 100644
index f6ee16b5..00000000
--- a/src/prebuilt/wast-parser-gen.cc
+++ /dev/null
@@ -1,4915 +0,0 @@
-/* A Bison parser, made by GNU Bison 3.0.2. */
-
-/* Bison implementation for Yacc-like parsers in C
-
- Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-/* As a special exception, you may create a larger work that contains
- part or all of the Bison parser skeleton and distribute that work
- under terms of your choice, so long as that work isn't itself a
- parser generator using the skeleton or a modified version thereof
- as a parser skeleton. Alternatively, if you modify or redistribute
- the parser skeleton itself, you may (at your option) remove this
- special exception, which will cause the skeleton and the resulting
- Bison output files to be licensed under the GNU General Public
- License without this special exception.
-
- This special exception was added by the Free Software Foundation in
- version 2.2 of Bison. */
-
-/* C LALR(1) parser skeleton written by Richard Stallman, by
- simplifying the original so-called "semantic" parser. */
-
-/* All symbols defined below should begin with yy or YY, to avoid
- infringing on user name space. This should be done even for local
- variables, as they might otherwise be expanded by user macros.
- There are some unavoidable exceptions within include files to
- define necessary library symbols; they are noted "INFRINGES ON
- USER NAME SPACE" below. */
-
-/* Identify Bison output. */
-#define YYBISON 1
-
-/* Bison version. */
-#define YYBISON_VERSION "3.0.2"
-
-/* Skeleton name. */
-#define YYSKELETON_NAME "yacc.c"
-
-/* Pure parsers. */
-#define YYPURE 1
-
-/* Push parsers. */
-#define YYPUSH 0
-
-/* Pull parsers. */
-#define YYPULL 1
-
-/* Substitute the type names. */
-#define YYSTYPE WABT_WAST_PARSER_STYPE
-#define YYLTYPE WABT_WAST_PARSER_LTYPE
-/* Substitute the variable and function names. */
-#define yyparse wabt_wast_parser_parse
-#define yylex wabt_wast_parser_lex
-#define yyerror wabt_wast_parser_error
-#define yydebug wabt_wast_parser_debug
-#define yynerrs wabt_wast_parser_nerrs
-
-
-/* Copy the first part of user declarations. */
-#line 17 "src/wast-parser.y" /* yacc.c:339 */
-
-#include <algorithm>
-#include <cassert>
-#include <cstdarg>
-#include <cstdio>
-#include <cstdlib>
-#include <iterator>
-#include <utility>
-
-#include "binary-reader.h"
-#include "binary-reader-ir.h"
-#include "cast.h"
-#include "error-handler.h"
-#include "literal.h"
-#include "string-view.h"
-#include "wast-parser.h"
-#include "wast-parser-lexer-shared.h"
-
-#define YYDEBUG 1
-
-#define RELOCATE_STACK(type, array, stack_base, old_size, new_size) \
- do { \
- type* new_stack = new type[new_size](); \
- std::move((stack_base), (stack_base) + (old_size), (new_stack)); \
- if ((stack_base) != (array)) { \
- delete[](stack_base); \
- } else { \
- for (size_t i = 0; i < (old_size); ++i) { \
- (stack_base)[i].~type(); \
- } \
- } \
- /* Cache the pointer in the parser struct to be deleted later. */ \
- parser->array = (stack_base) = new_stack; \
- } while (0)
-
-#define yyoverflow(message, ss, ss_size, vs, vs_size, ls, ls_size, new_size) \
- do { \
- size_t old_size = *(new_size); \
- *(new_size) *= 2; \
- RELOCATE_STACK(yytype_int16, yyssa, *(ss), old_size, *(new_size)); \
- RELOCATE_STACK(YYSTYPE, yyvsa, *(vs), old_size, *(new_size)); \
- RELOCATE_STACK(YYLTYPE, yylsa, *(ls), old_size, *(new_size)); \
- } while (0)
-
-#define YYLLOC_DEFAULT(Current, Rhs, N) \
- do \
- if (N) { \
- (Current).filename = YYRHSLOC(Rhs, 1).filename; \
- (Current).line = YYRHSLOC(Rhs, 1).line; \
- (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \
- if (YYRHSLOC(Rhs, N).line == (Current).line) \
- (Current).last_column = YYRHSLOC(Rhs, N).last_column; \
- else \
- (Current).last_column = YYRHSLOC(Rhs, 1).last_column; \
- } else { \
- (Current).filename = nullptr; \
- (Current).line = YYRHSLOC(Rhs, 0).line; \
- (Current).first_column = (Current).last_column = \
- YYRHSLOC(Rhs, 0).last_column; \
- } \
- while (0)
-
-#define CHECK_END_LABEL(loc, begin_label, end_label) \
- do { \
- if (!end_label->empty()) { \
- if (begin_label.empty()) { \
- WastParserError(&loc, lexer, parser, "unexpected label \"%s\"", \
- end_label->c_str()); \
- } else if (begin_label != *end_label) { \
- WastParserError(&loc, lexer, parser, \
- "mismatching label \"%s\" != \"%s\"", \
- begin_label.c_str(), end_label->c_str()); \
- } \
- } \
- delete (end_label); \
- } while (0)
-
-#define CHECK_ALLOW_EXCEPTIONS(loc, opcode_name) \
- do { \
- if (!parser->options->allow_future_exceptions) { \
- WastParserError(loc, lexer, parser, "opcode not allowed: %s", \
- opcode_name); \
- } \
- } while (0)
-
-#define YYMALLOC(size) new char [size]
-#define YYFREE(p) delete [] (p)
-
-#define USE_NATURAL_ALIGNMENT (~0)
-
-namespace wabt {
-
-static bool IsPowerOfTwo(uint32_t x) {
- return x && ((x & (x - 1)) == 0);
-}
-
-Result ParseConst(Type type, const Literal& literal, Const* out);
-
-static void ReverseBindings(TypeVector*, BindingHash*);
-
-static bool IsEmptySignature(const FuncSignature* sig);
-
-static void CheckImportOrdering(Location* loc,
- WastLexer* lexer,
- WastParser* parser,
- Module* module,
- const ModuleFieldList&);
-static void AppendModuleFields(Module*, ModuleFieldList&&);
-static void ResolveFuncTypes(Module*);
-
-class BinaryErrorHandlerModule : public ErrorHandler {
- public:
- BinaryErrorHandlerModule(Location* loc, WastLexer* lexer, WastParser* parser);
- bool OnError(const Location&,
- const std::string& error,
- const std::string& source_line,
- size_t source_line_column_offset) override;
-
- // Unused.
- size_t source_line_max_length() const override { return 0; }
-
- private:
- Location* loc_;
- WastLexer* lexer_;
- WastParser* parser_;
-};
-
-template <typename OutputIter>
-void RemoveEscapes(string_view text, OutputIter dest) {
- // Remove surrounding quotes; if any. This may be empty if the string was
- // invalid (e.g. if it contained a bad escape sequence).
- if (text.size() <= 2)
- return;
-
- text = text.substr(1, text.size() - 2);
-
- const char* src = text.data();
- const char* end = text.data() + text.size();
-
- while (src < end) {
- if (*src == '\\') {
- src++;
- switch (*src) {
- case 'n':
- *dest++ = '\n';
- break;
- case 'r':
- *dest++ = '\r';
- break;
- case 't':
- *dest++ = '\t';
- break;
- case '\\':
- *dest++ = '\\';
- break;
- case '\'':
- *dest++ = '\'';
- break;
- case '\"':
- *dest++ = '\"';
- break;
- default: {
- // The string should be validated already, so we know this is a hex
- // sequence.
- uint32_t hi;
- uint32_t lo;
- if (Succeeded(ParseHexdigit(src[0], &hi)) &&
- Succeeded(ParseHexdigit(src[1], &lo))) {
- *dest++ = (hi << 4) | lo;
- } else {
- assert(0);
- }
- src++;
- break;
- }
- }
- src++;
- } else {
- *dest++ = *src++;
- }
- }
-}
-
-template <typename OutputIter>
-void RemoveEscapes(const TextVector& texts, OutputIter out) {
- for (const std::string& text: texts)
- RemoveEscapes(text, out);
-}
-
-template <typename T>
-T MoveAndDelete(T* ptr) {
- T result = std::move(*ptr);
- delete ptr;
- return result;
-}
-
-template <typename T, typename U>
-void PrependAndDelete(T& dest, U* source) {
- dest.insert(dest.begin(), std::begin(*source), std::end(*source));
- delete source;
-}
-
-template <typename T, typename U>
-void AppendAndDelete(T& dest, U* source) {
- dest.insert(dest.end(), std::begin(*source), std::end(*source));
- delete source;
-}
-
-#define wabt_wast_parser_lex(...) lexer->GetToken(__VA_ARGS__, parser)
-#define wabt_wast_parser_error WastParserError
-
-
-#line 287 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:339 */
-
-# ifndef YY_NULLPTR
-# if defined __cplusplus && 201103L <= __cplusplus
-# define YY_NULLPTR nullptr
-# else
-# define YY_NULLPTR 0
-# endif
-# endif
-
-/* Enabling verbose error messages. */
-#ifdef YYERROR_VERBOSE
-# undef YYERROR_VERBOSE
-# define YYERROR_VERBOSE 1
-#else
-# define YYERROR_VERBOSE 1
-#endif
-
-/* In a future release of Bison, this section will be replaced
- by #include "wast-parser-gen.hh". */
-#ifndef YY_WABT_WAST_PARSER_SRC_PREBUILT_WAST_PARSER_GEN_HH_INCLUDED
-# define YY_WABT_WAST_PARSER_SRC_PREBUILT_WAST_PARSER_GEN_HH_INCLUDED
-/* Debug traces. */
-#ifndef WABT_WAST_PARSER_DEBUG
-# if defined YYDEBUG
-#if YYDEBUG
-# define WABT_WAST_PARSER_DEBUG 1
-# else
-# define WABT_WAST_PARSER_DEBUG 0
-# endif
-# else /* ! defined YYDEBUG */
-# define WABT_WAST_PARSER_DEBUG 0
-# endif /* ! defined YYDEBUG */
-#endif /* ! defined WABT_WAST_PARSER_DEBUG */
-#if WABT_WAST_PARSER_DEBUG
-extern int wabt_wast_parser_debug;
-#endif
-
-/* Token type. */
-#ifndef WABT_WAST_PARSER_TOKENTYPE
-# define WABT_WAST_PARSER_TOKENTYPE
- enum wabt_wast_parser_tokentype
- {
- WABT_TOKEN_TYPE_EOF = 0,
- WABT_TOKEN_TYPE_LPAR = 258,
- WABT_TOKEN_TYPE_RPAR = 259,
- WABT_TOKEN_TYPE_NAT = 260,
- WABT_TOKEN_TYPE_INT = 261,
- WABT_TOKEN_TYPE_FLOAT = 262,
- WABT_TOKEN_TYPE_TEXT = 263,
- WABT_TOKEN_TYPE_VAR = 264,
- WABT_TOKEN_TYPE_VALUE_TYPE = 265,
- WABT_TOKEN_TYPE_ANYFUNC = 266,
- WABT_TOKEN_TYPE_MUT = 267,
- WABT_TOKEN_TYPE_NOP = 268,
- WABT_TOKEN_TYPE_DROP = 269,
- WABT_TOKEN_TYPE_BLOCK = 270,
- WABT_TOKEN_TYPE_END = 271,
- WABT_TOKEN_TYPE_IF = 272,
- WABT_TOKEN_TYPE_THEN = 273,
- WABT_TOKEN_TYPE_ELSE = 274,
- WABT_TOKEN_TYPE_LOOP = 275,
- WABT_TOKEN_TYPE_BR = 276,
- WABT_TOKEN_TYPE_BR_IF = 277,
- WABT_TOKEN_TYPE_BR_TABLE = 278,
- WABT_TOKEN_TYPE_TRY = 279,
- WABT_TOKEN_TYPE_CATCH = 280,
- WABT_TOKEN_TYPE_CATCH_ALL = 281,
- WABT_TOKEN_TYPE_THROW = 282,
- WABT_TOKEN_TYPE_RETHROW = 283,
- WABT_TOKEN_TYPE_LPAR_CATCH = 284,
- WABT_TOKEN_TYPE_LPAR_CATCH_ALL = 285,
- WABT_TOKEN_TYPE_CALL = 286,
- WABT_TOKEN_TYPE_CALL_INDIRECT = 287,
- WABT_TOKEN_TYPE_RETURN = 288,
- WABT_TOKEN_TYPE_GET_LOCAL = 289,
- WABT_TOKEN_TYPE_SET_LOCAL = 290,
- WABT_TOKEN_TYPE_TEE_LOCAL = 291,
- WABT_TOKEN_TYPE_GET_GLOBAL = 292,
- WABT_TOKEN_TYPE_SET_GLOBAL = 293,
- WABT_TOKEN_TYPE_LOAD = 294,
- WABT_TOKEN_TYPE_STORE = 295,
- WABT_TOKEN_TYPE_OFFSET_EQ_NAT = 296,
- WABT_TOKEN_TYPE_ALIGN_EQ_NAT = 297,
- WABT_TOKEN_TYPE_CONST = 298,
- WABT_TOKEN_TYPE_UNARY = 299,
- WABT_TOKEN_TYPE_BINARY = 300,
- WABT_TOKEN_TYPE_COMPARE = 301,
- WABT_TOKEN_TYPE_CONVERT = 302,
- WABT_TOKEN_TYPE_SELECT = 303,
- WABT_TOKEN_TYPE_UNREACHABLE = 304,
- WABT_TOKEN_TYPE_CURRENT_MEMORY = 305,
- WABT_TOKEN_TYPE_GROW_MEMORY = 306,
- WABT_TOKEN_TYPE_FUNC = 307,
- WABT_TOKEN_TYPE_START = 308,
- WABT_TOKEN_TYPE_TYPE = 309,
- WABT_TOKEN_TYPE_PARAM = 310,
- WABT_TOKEN_TYPE_RESULT = 311,
- WABT_TOKEN_TYPE_LOCAL = 312,
- WABT_TOKEN_TYPE_GLOBAL = 313,
- WABT_TOKEN_TYPE_TABLE = 314,
- WABT_TOKEN_TYPE_ELEM = 315,
- WABT_TOKEN_TYPE_MEMORY = 316,
- WABT_TOKEN_TYPE_DATA = 317,
- WABT_TOKEN_TYPE_OFFSET = 318,
- WABT_TOKEN_TYPE_IMPORT = 319,
- WABT_TOKEN_TYPE_EXPORT = 320,
- WABT_TOKEN_TYPE_EXCEPT = 321,
- WABT_TOKEN_TYPE_MODULE = 322,
- WABT_TOKEN_TYPE_BIN = 323,
- WABT_TOKEN_TYPE_QUOTE = 324,
- WABT_TOKEN_TYPE_REGISTER = 325,
- WABT_TOKEN_TYPE_INVOKE = 326,
- WABT_TOKEN_TYPE_GET = 327,
- WABT_TOKEN_TYPE_ASSERT_MALFORMED = 328,
- WABT_TOKEN_TYPE_ASSERT_INVALID = 329,
- WABT_TOKEN_TYPE_ASSERT_UNLINKABLE = 330,
- WABT_TOKEN_TYPE_ASSERT_RETURN = 331,
- WABT_TOKEN_TYPE_ASSERT_RETURN_CANONICAL_NAN = 332,
- WABT_TOKEN_TYPE_ASSERT_RETURN_ARITHMETIC_NAN = 333,
- WABT_TOKEN_TYPE_ASSERT_TRAP = 334,
- WABT_TOKEN_TYPE_ASSERT_EXHAUSTION = 335,
- WABT_TOKEN_TYPE_LOW = 336
- };
-#endif
-
-/* Value type. */
-#if ! defined WABT_WAST_PARSER_STYPE && ! defined WABT_WAST_PARSER_STYPE_IS_DECLARED
-typedef ::wabt::Token WABT_WAST_PARSER_STYPE;
-# define WABT_WAST_PARSER_STYPE_IS_TRIVIAL 1
-# define WABT_WAST_PARSER_STYPE_IS_DECLARED 1
-#endif
-
-/* Location type. */
-#if ! defined WABT_WAST_PARSER_LTYPE && ! defined WABT_WAST_PARSER_LTYPE_IS_DECLARED
-typedef struct WABT_WAST_PARSER_LTYPE WABT_WAST_PARSER_LTYPE;
-struct WABT_WAST_PARSER_LTYPE
-{
- int first_line;
- int first_column;
- int last_line;
- int last_column;
-};
-# define WABT_WAST_PARSER_LTYPE_IS_DECLARED 1
-# define WABT_WAST_PARSER_LTYPE_IS_TRIVIAL 1
-#endif
-
-
-
-int wabt_wast_parser_parse (::wabt::WastLexer* lexer, ::wabt::WastParser* parser);
-
-#endif /* !YY_WABT_WAST_PARSER_SRC_PREBUILT_WAST_PARSER_GEN_HH_INCLUDED */
-
-/* Copy the second part of user declarations. */
-
-#line 442 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:358 */
-
-#ifdef short
-# undef short
-#endif
-
-#ifdef YYTYPE_UINT8
-typedef YYTYPE_UINT8 yytype_uint8;
-#else
-typedef unsigned char yytype_uint8;
-#endif
-
-#ifdef YYTYPE_INT8
-typedef YYTYPE_INT8 yytype_int8;
-#else
-typedef signed char yytype_int8;
-#endif
-
-#ifdef YYTYPE_UINT16
-typedef YYTYPE_UINT16 yytype_uint16;
-#else
-typedef unsigned short int yytype_uint16;
-#endif
-
-#ifdef YYTYPE_INT16
-typedef YYTYPE_INT16 yytype_int16;
-#else
-typedef short int yytype_int16;
-#endif
-
-#ifndef YYSIZE_T
-# ifdef __SIZE_TYPE__
-# define YYSIZE_T __SIZE_TYPE__
-# elif defined size_t
-# define YYSIZE_T size_t
-# elif ! defined YYSIZE_T
-# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
-# define YYSIZE_T size_t
-# else
-# define YYSIZE_T unsigned int
-# endif
-#endif
-
-#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
-
-#ifndef YY_
-# if defined YYENABLE_NLS && YYENABLE_NLS
-# if ENABLE_NLS
-# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
-# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
-# endif
-# endif
-# ifndef YY_
-# define YY_(Msgid) Msgid
-# endif
-#endif
-
-#ifndef YY_ATTRIBUTE
-# if (defined __GNUC__ \
- && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
- || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
-# define YY_ATTRIBUTE(Spec) __attribute__(Spec)
-# else
-# define YY_ATTRIBUTE(Spec) /* empty */
-# endif
-#endif
-
-#ifndef YY_ATTRIBUTE_PURE
-# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
-#endif
-
-#ifndef YY_ATTRIBUTE_UNUSED
-# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
-#endif
-
-#if !defined _Noreturn \
- && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
-# if defined _MSC_VER && 1200 <= _MSC_VER
-# define _Noreturn __declspec (noreturn)
-# else
-# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
-# endif
-#endif
-
-/* Suppress unused-variable warnings by "using" E. */
-#if ! defined lint || defined __GNUC__
-# define YYUSE(E) ((void) (E))
-#else
-# define YYUSE(E) /* empty */
-#endif
-
-#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
-/* Suppress an incorrect diagnostic about yylval being uninitialized. */
-# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
- _Pragma ("GCC diagnostic push") \
- _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
- _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
-# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
- _Pragma ("GCC diagnostic pop")
-#else
-# define YY_INITIAL_VALUE(Value) Value
-#endif
-#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
-# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
-# define YY_IGNORE_MAYBE_UNINITIALIZED_END
-#endif
-#ifndef YY_INITIAL_VALUE
-# define YY_INITIAL_VALUE(Value) /* Nothing. */
-#endif
-
-
-#if ! defined yyoverflow || YYERROR_VERBOSE
-
-/* The parser invokes alloca or malloc; define the necessary symbols. */
-
-# ifdef YYSTACK_USE_ALLOCA
-# if YYSTACK_USE_ALLOCA
-# ifdef __GNUC__
-# define YYSTACK_ALLOC __builtin_alloca
-# elif defined __BUILTIN_VA_ARG_INCR
-# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
-# elif defined _AIX
-# define YYSTACK_ALLOC __alloca
-# elif defined _MSC_VER
-# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
-# define alloca _alloca
-# else
-# define YYSTACK_ALLOC alloca
-# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
- /* Use EXIT_SUCCESS as a witness for stdlib.h. */
-# ifndef EXIT_SUCCESS
-# define EXIT_SUCCESS 0
-# endif
-# endif
-# endif
-# endif
-# endif
-
-# ifdef YYSTACK_ALLOC
- /* Pacify GCC's 'empty if-body' warning. */
-# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
-# ifndef YYSTACK_ALLOC_MAXIMUM
- /* The OS might guarantee only one guard page at the bottom of the stack,
- and a page size can be as small as 4096 bytes. So we cannot safely
- invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
- to allow for a few compiler-allocated temporary stack slots. */
-# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
-# endif
-# else
-# define YYSTACK_ALLOC YYMALLOC
-# define YYSTACK_FREE YYFREE
-# ifndef YYSTACK_ALLOC_MAXIMUM
-# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
-# endif
-# if (defined __cplusplus && ! defined EXIT_SUCCESS \
- && ! ((defined YYMALLOC || defined malloc) \
- && (defined YYFREE || defined free)))
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-# ifndef EXIT_SUCCESS
-# define EXIT_SUCCESS 0
-# endif
-# endif
-# ifndef YYMALLOC
-# define YYMALLOC malloc
-# if ! defined malloc && ! defined EXIT_SUCCESS
-void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
-# endif
-# endif
-# ifndef YYFREE
-# define YYFREE free
-# if ! defined free && ! defined EXIT_SUCCESS
-void free (void *); /* INFRINGES ON USER NAME SPACE */
-# endif
-# endif
-# endif
-#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
-
-
-#if (! defined yyoverflow \
- && (! defined __cplusplus \
- || (defined WABT_WAST_PARSER_LTYPE_IS_TRIVIAL && WABT_WAST_PARSER_LTYPE_IS_TRIVIAL \
- && defined WABT_WAST_PARSER_STYPE_IS_TRIVIAL && WABT_WAST_PARSER_STYPE_IS_TRIVIAL)))
-
-/* A type that is properly aligned for any stack member. */
-union yyalloc
-{
- yytype_int16 yyss_alloc;
- YYSTYPE yyvs_alloc;
- YYLTYPE yyls_alloc;
-};
-
-/* The size of the maximum gap between one aligned stack and the next. */
-# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
-
-/* The size of an array large to enough to hold all stacks, each with
- N elements. */
-# define YYSTACK_BYTES(N) \
- ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
- + 2 * YYSTACK_GAP_MAXIMUM)
-
-# define YYCOPY_NEEDED 1
-
-/* Relocate STACK from its old location to the new one. The
- local variables YYSIZE and YYSTACKSIZE give the old and new number of
- elements in the stack, and YYPTR gives the new location of the
- stack. Advance YYPTR to a properly aligned location for the next
- stack. */
-# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
- do \
- { \
- YYSIZE_T yynewbytes; \
- YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
- Stack = &yyptr->Stack_alloc; \
- yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
- yyptr += yynewbytes / sizeof (*yyptr); \
- } \
- while (0)
-
-#endif
-
-#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
-/* Copy COUNT objects from SRC to DST. The source and destination do
- not overlap. */
-# ifndef YYCOPY
-# if defined __GNUC__ && 1 < __GNUC__
-# define YYCOPY(Dst, Src, Count) \
- __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
-# else
-# define YYCOPY(Dst, Src, Count) \
- do \
- { \
- YYSIZE_T yyi; \
- for (yyi = 0; yyi < (Count); yyi++) \
- (Dst)[yyi] = (Src)[yyi]; \
- } \
- while (0)
-# endif
-# endif
-#endif /* !YYCOPY_NEEDED */
-
-/* YYFINAL -- State number of the termination state. */
-#define YYFINAL 52
-/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 1028
-
-/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS 82
-/* YYNNTS -- Number of nonterminals. */
-#define YYNNTS 89
-/* YYNRULES -- Number of rules. */
-#define YYNRULES 218
-/* YYNSTATES -- Number of states. */
-#define YYNSTATES 481
-
-/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
- by yylex, with out-of-bounds checking. */
-#define YYUNDEFTOK 2
-#define YYMAXUTOK 336
-
-#define YYTRANSLATE(YYX) \
- ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
-
-/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
- as returned by yylex, without out-of-bounds checking. */
-static const yytype_uint8 yytranslate[] =
-{
- 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
- 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
- 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
- 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
- 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
- 75, 76, 77, 78, 79, 80, 81
-};
-
-#if WABT_WAST_PARSER_DEBUG
- /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
-static const yytype_uint16 yyrline[] =
-{
- 0, 332, 332, 336, 342, 343, 347, 356, 357, 363,
- 366, 371, 379, 383, 384, 388, 397, 398, 405, 411,
- 417, 422, 429, 435, 445, 448, 451, 457, 460, 465,
- 466, 472, 473, 476, 480, 481, 485, 486, 503, 504,
- 520, 524, 528, 532, 535, 538, 541, 544, 547, 550,
- 553, 556, 559, 562, 565, 568, 571, 574, 577, 580,
- 583, 593, 596, 599, 602, 605, 608, 611, 614, 620,
- 626, 632, 638, 645, 654, 657, 661, 667, 673, 680,
- 681, 685, 690, 697, 701, 706, 712, 718, 723, 732,
- 737, 746, 749, 755, 760, 768, 774, 777, 782, 787,
- 793, 799, 805, 814, 819, 825, 831, 832, 838, 839,
- 845, 850, 855, 862, 876, 882, 885, 893, 899, 908,
- 915, 916, 920, 929, 930, 937, 944, 945, 949, 958,
- 959, 966, 973, 977, 981, 992, 995, 999, 1006, 1016,
- 1030, 1033, 1039, 1045, 1064, 1071, 1081, 1095, 1098, 1104,
- 1110, 1132, 1146, 1151, 1157, 1168, 1176, 1183, 1189, 1195,
- 1201, 1209, 1218, 1226, 1231, 1236, 1241, 1246, 1253, 1261,
- 1271, 1276, 1285, 1291, 1292, 1293, 1294, 1295, 1296, 1297,
- 1298, 1299, 1300, 1301, 1305, 1306, 1310, 1315, 1323, 1343,
- 1353, 1356, 1362, 1370, 1376, 1385, 1394, 1404, 1407, 1410,
- 1413, 1416, 1419, 1422, 1425, 1428, 1434, 1437, 1438, 1441,
- 1448, 1452, 1459, 1469, 1470, 1477, 1480, 1542, 1551
-};
-#endif
-
-#if WABT_WAST_PARSER_DEBUG || YYERROR_VERBOSE || 1
-/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
- First, the terminals, then, starting at YYNTOKENS, nonterminals. */
-static const char *const yytname[] =
-{
- "\"EOF\"", "error", "$undefined", "\"(\"", "\")\"", "NAT", "INT",
- "FLOAT", "TEXT", "VAR", "VALUE_TYPE", "ANYFUNC", "MUT", "NOP", "DROP",
- "BLOCK", "END", "IF", "THEN", "ELSE", "LOOP", "BR", "BR_IF", "BR_TABLE",
- "TRY", "CATCH", "CATCH_ALL", "THROW", "RETHROW", "LPAR_CATCH",
- "LPAR_CATCH_ALL", "CALL", "CALL_INDIRECT", "RETURN", "GET_LOCAL",
- "SET_LOCAL", "TEE_LOCAL", "GET_GLOBAL", "SET_GLOBAL", "LOAD", "STORE",
- "OFFSET_EQ_NAT", "ALIGN_EQ_NAT", "CONST", "UNARY", "BINARY", "COMPARE",
- "CONVERT", "SELECT", "UNREACHABLE", "CURRENT_MEMORY", "GROW_MEMORY",
- "FUNC", "START", "TYPE", "PARAM", "RESULT", "LOCAL", "GLOBAL", "TABLE",
- "ELEM", "MEMORY", "DATA", "OFFSET", "IMPORT", "EXPORT", "EXCEPT",
- "MODULE", "BIN", "QUOTE", "REGISTER", "INVOKE", "GET",
- "ASSERT_MALFORMED", "ASSERT_INVALID", "ASSERT_UNLINKABLE",
- "ASSERT_RETURN", "ASSERT_RETURN_CANONICAL_NAN",
- "ASSERT_RETURN_ARITHMETIC_NAN", "ASSERT_TRAP", "ASSERT_EXHAUSTION",
- "LOW", "$accept", "text_list", "text_list_opt", "quoted_text",
- "value_type_list", "elem_type", "global_type", "func_type", "func_sig",
- "func_sig_result", "table_sig", "memory_sig", "limits", "type_use",
- "nat", "literal", "var", "var_list", "bind_var_opt", "bind_var",
- "labeling_opt", "offset_opt", "align_opt", "instr", "plain_instr",
- "block_instr", "block_sig", "block", "plain_catch", "plain_catch_all",
- "catch_instr", "catch_instr_list", "expr", "expr1", "try_", "catch_sexp",
- "catch_sexp_list", "if_block", "if_", "rethrow_check", "throw_check",
- "try_check", "instr_list", "expr_list", "const_expr", "exception",
- "exception_field", "func", "func_fields", "func_fields_import",
- "func_fields_import1", "func_fields_import_result", "func_fields_body",
- "func_fields_body1", "func_result_body", "func_body", "func_body1",
- "offset", "elem", "table", "table_fields", "data", "memory",
- "memory_fields", "global", "global_fields", "import_desc", "import",
- "inline_import", "export_desc", "export", "inline_export", "type_def",
- "start", "module_field", "module_fields_opt", "module_fields", "module",
- "inline_module", "script_var_opt", "script_module", "action",
- "assertion", "cmd", "cmd_list", "const", "const_list", "script",
- "script_start", YY_NULLPTR
-};
-#endif
-
-# ifdef YYPRINT
-/* YYTOKNUM[NUM] -- (External) token number corresponding to the
- (internal) symbol number NUM (which must be that of a token). */
-static const yytype_uint16 yytoknum[] =
-{
- 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
- 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
- 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
- 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
- 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
- 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
- 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
- 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
- 335, 336
-};
-# endif
-
-#define YYPACT_NINF -400
-
-#define yypact_value_is_default(Yystate) \
- (!!((Yystate) == (-400)))
-
-#define YYTABLE_NINF -31
-
-#define yytable_value_is_error(Yytable_value) \
- 0
-
- /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
- STATE-NUM. */
-static const yytype_int16 yypact[] =
-{
- 20, 948, -400, -400, -400, -400, -400, -400, -400, -400,
- -400, -400, -400, -400, -400, 55, -400, -400, -400, -400,
- -400, -400, 77, -400, 105, 106, 238, 129, 106, 106,
- 168, 106, 168, 141, 141, 106, 106, 141, 147, 147,
- 167, 167, 167, 193, 193, 193, 205, 193, 100, -400,
- 240, -400, -400, -400, 463, -400, -400, -400, -400, 211,
- 165, 220, 226, 34, 152, 412, 241, -400, -400, 50,
- 241, 253, -400, 141, 246, -400, 51, 147, -400, 141,
- 141, 198, 141, 141, 141, -40, -400, 271, 278, 160,
- 141, 141, 141, 366, -400, -400, 106, 106, 106, 238,
- 238, -400, -400, -400, -400, 238, 238, -400, 238, 238,
- 238, 238, 238, 249, 249, 282, -400, -400, -400, -400,
- -400, -400, -400, -400, 502, 541, -400, -400, -400, 238,
- 238, 106, -400, 290, -400, -400, -400, -400, -400, 293,
- 463, -400, 302, -400, 304, 49, -400, 541, 319, 121,
- 34, 103, -400, 324, -400, 320, 325, 328, 325, 152,
- 106, 106, 106, 541, 330, 331, 106, -400, 233, 221,
- -400, -400, 332, 325, 50, 253, -400, 335, 334, 336,
- 117, 340, 135, 253, 253, 344, 55, 345, -400, 346,
- 347, 349, 353, 190, -400, -400, 354, 355, 359, 238,
- 106, -400, 106, 141, 141, -400, 580, 580, 580, -400,
- -400, 238, -400, -400, -400, -400, -400, -400, -400, -400,
- 298, 298, -400, -400, -400, -400, 697, -400, 947, -400,
- -400, -400, 580, -400, 237, 367, -400, -400, -400, -400,
- 179, 368, -400, -400, 361, -400, -400, -400, 362, -400,
- -400, 313, -400, -400, -400, -400, -400, 580, 379, 580,
- 380, 330, -400, -400, 580, 236, -400, -400, 253, -400,
- -400, -400, 381, -400, -400, 148, -400, 387, 238, 238,
- 238, 238, 238, -400, -400, -400, 119, 242, -400, -400,
- 255, -400, -400, -400, -400, 352, -400, -400, -400, -400,
- -400, 388, 187, 386, 191, 200, 397, 141, 404, 868,
- 580, 402, -400, 24, 403, 251, -400, -400, -400, 276,
- 106, -400, 266, -400, 106, -400, -400, 420, -400, -400,
- 828, 379, 425, -400, -400, -400, -400, -400, 580, -400,
- 296, -400, 433, -400, 106, 106, 106, 106, -400, 434,
- 437, 438, 449, 450, -400, -400, -400, 282, -400, 502,
- 460, 619, 658, 461, 464, -400, -400, -400, 106, 106,
- 106, 106, 238, 541, -400, -400, -400, 118, 201, 457,
- 208, 215, 459, 216, -400, 248, 541, -400, 908, 330,
- -400, 467, 468, -400, 296, -400, 469, 121, 325, 325,
- -400, -400, -400, -400, -400, 470, -400, 502, 742, -400,
- 787, -400, 658, -400, 218, -400, -400, 541, -400, 541,
- -400, 106, -400, 367, 475, 478, 302, 484, 479, -400,
- 485, 541, -400, 448, 466, -400, 244, 489, 500, 514,
- 516, 517, -400, -400, -400, -400, 511, -400, -400, -400,
- 367, 472, -400, -400, 302, 476, -400, 528, 539, 553,
- 555, -400, -400, -400, -400, -400, 106, -400, -400, 547,
- 557, -400, -400, -400, 541, 548, 566, 541, -400, 567,
- -400
-};
-
- /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
- Performed when YYTABLE does not specify something else to do. Zero
- means the default is an error. */
-static const yytype_uint8 yydefact[] =
-{
- 215, 0, 112, 183, 177, 178, 175, 179, 176, 174,
- 181, 182, 173, 180, 186, 189, 208, 217, 188, 206,
- 207, 210, 216, 218, 0, 31, 0, 0, 31, 31,
- 0, 31, 0, 0, 0, 31, 31, 0, 190, 190,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 187,
- 0, 211, 1, 33, 106, 32, 23, 28, 27, 0,
- 0, 0, 0, 0, 0, 0, 0, 136, 29, 0,
- 0, 4, 6, 0, 0, 7, 184, 190, 191, 0,
- 0, 0, 0, 0, 0, 0, 213, 0, 0, 0,
- 0, 0, 0, 0, 44, 45, 34, 34, 34, 0,
- 0, 29, 105, 104, 103, 0, 0, 50, 0, 0,
- 0, 0, 0, 36, 36, 0, 61, 62, 63, 64,
- 46, 43, 65, 66, 106, 106, 40, 41, 42, 0,
- 0, 34, 132, 0, 115, 125, 126, 129, 131, 123,
- 106, 172, 16, 170, 0, 0, 10, 106, 0, 0,
- 0, 0, 9, 0, 140, 0, 20, 0, 0, 0,
- 34, 34, 34, 106, 108, 0, 34, 29, 0, 0,
- 147, 19, 0, 0, 0, 4, 2, 5, 0, 0,
- 0, 0, 0, 0, 0, 0, 185, 0, 213, 0,
- 0, 0, 0, 0, 202, 203, 0, 0, 0, 0,
- 7, 7, 7, 0, 0, 35, 106, 106, 106, 47,
- 48, 0, 51, 52, 53, 54, 55, 56, 57, 37,
- 38, 38, 24, 25, 26, 60, 0, 114, 0, 107,
- 68, 67, 106, 113, 0, 123, 117, 119, 120, 118,
- 0, 0, 13, 171, 0, 110, 152, 151, 0, 153,
- 154, 0, 18, 21, 139, 141, 142, 106, 0, 106,
- 0, 108, 84, 83, 106, 0, 138, 30, 4, 146,
- 148, 149, 0, 3, 145, 0, 160, 0, 0, 0,
- 0, 0, 0, 168, 111, 8, 0, 0, 192, 209,
- 0, 196, 197, 198, 199, 0, 201, 214, 200, 204,
- 205, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 106, 0, 76, 0, 0, 49, 39, 58, 59, 0,
- 7, 7, 0, 116, 7, 7, 12, 0, 29, 85,
- 0, 0, 0, 87, 96, 86, 135, 109, 106, 88,
- 0, 137, 0, 144, 31, 31, 31, 31, 161, 0,
- 0, 0, 0, 0, 193, 194, 195, 0, 22, 106,
- 0, 106, 106, 0, 0, 169, 7, 75, 34, 34,
- 34, 34, 0, 106, 79, 80, 81, 0, 0, 0,
- 0, 0, 0, 0, 11, 0, 106, 95, 0, 102,
- 89, 0, 0, 93, 90, 150, 16, 0, 0, 0,
- 163, 166, 164, 165, 167, 0, 127, 106, 0, 130,
- 0, 133, 106, 162, 0, 69, 71, 106, 70, 106,
- 78, 34, 82, 123, 0, 123, 16, 0, 16, 143,
- 0, 106, 101, 0, 0, 94, 0, 0, 0, 0,
- 0, 0, 212, 128, 134, 74, 0, 77, 73, 121,
- 123, 0, 124, 14, 16, 0, 17, 98, 0, 0,
- 0, 156, 155, 159, 157, 158, 34, 122, 15, 0,
- 100, 91, 92, 72, 106, 0, 0, 106, 97, 0,
- 99
-};
-
- /* YYPGOTO[NTERM-NUM]. */
-static const yytype_int16 yypgoto[] =
-{
- -400, 145, -159, -1, -174, 427, -143, 534, -381, 170,
- -150, -160, -62, -134, -52, 252, -12, -92, 31, 21,
- -97, 491, 378, -400, -54, -400, -190, -131, 173, 176,
- 258, -400, -28, -400, 283, 243, -400, 307, -400, -400,
- -400, -46, -122, 383, 482, 481, -400, -400, 508, 414,
- -399, 259, 550, -337, 315, -400, -341, 63, -400, -400,
- 518, -400, -400, 509, -400, 537, -400, -400, -34, -400,
- -400, 39, -400, -400, -5, -400, 612, -400, -400, 53,
- 144, 234, -400, 677, -400, -400, 512, -400, -400
-};
-
- /* YYDEFGOTO[NTERM-NUM]. */
-static const yytype_int16 yydefgoto[] =
-{
- -1, 177, 178, 73, 182, 153, 147, 61, 241, 242,
- 154, 170, 155, 124, 58, 225, 267, 168, 54, 205,
- 206, 220, 317, 125, 126, 127, 310, 311, 374, 375,
- 376, 377, 128, 165, 339, 393, 394, 333, 334, 129,
- 130, 131, 132, 262, 246, 2, 3, 4, 133, 236,
- 237, 238, 134, 135, 136, 137, 138, 68, 5, 6,
- 157, 7, 8, 172, 9, 148, 277, 10, 139, 181,
- 11, 140, 12, 13, 14, 185, 15, 16, 17, 79,
- 18, 19, 20, 21, 22, 297, 193, 23, 24
-};
-
- /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
- positive, shift that token. If negative, reduce the rule whose
- number is the opposite. If YYTABLE_NINF, syntax error. */
-static const yytype_int16 yytable[] =
-{
- 207, 208, 67, 229, 67, 235, 249, 171, 255, 211,
- 49, 164, 156, 270, 59, 437, 272, 156, 66, 166,
- 70, 411, 406, 1, 449, 245, 302, 304, 305, 149,
- 158, 38, 39, 74, 232, 173, 77, 145, 67, 164,
- 369, 245, 67, 370, 146, 453, 55, 166, 62, 55,
- 55, 467, 55, 169, 48, 56, 55, 55, 48, 63,
- 64, 244, 69, 257, 258, 259, 75, 76, 331, 264,
- 443, 444, 179, 468, 338, 265, 313, 314, 188, 189,
- 50, 190, 191, 192, 312, 312, 312, 209, 210, 196,
- 197, 198, 80, 212, 213, 71, 214, 215, 216, 217,
- 218, 319, 150, 159, 253, 52, 156, 156, 174, 342,
- 312, 171, 171, 203, 204, 53, 149, 230, 231, 183,
- 184, 156, 156, 354, 248, 158, 329, 273, 335, 167,
- 187, 146, 60, 175, 421, 312, 261, 312, 53, 284,
- 173, 331, 340, 372, 373, 285, 378, 380, 338, 72,
- 381, 383, 25, 26, 27, 151, 78, 56, 28, 29,
- 30, 31, 32, 152, 33, 34, 35, 203, 204, 278,
- 81, 65, 164, 56, 164, 279, 280, 57, 281, 367,
- 166, 49, 166, 282, 82, 83, 84, 301, 312, 150,
- 90, 359, 414, 295, 296, 361, 85, 285, 159, 315,
- 344, 285, 307, 308, 362, 423, 345, 346, 89, 347,
- 285, 285, 425, 174, 35, 141, 340, 142, 285, 426,
- 428, 303, 445, 306, 143, 285, 285, 36, 285, 60,
- 332, 38, 39, 261, 324, 325, 385, 266, 56, 441,
- 341, 56, 57, 56, 65, 57, 355, 57, 440, 180,
- 273, 420, 429, 56, 439, 164, -30, 57, 295, 356,
- -30, 176, 438, 166, 430, 36, 349, 350, 351, 352,
- 353, 415, 416, 417, 418, 194, 164, 86, 87, 88,
- 91, 92, 195, 268, 166, 203, 204, 222, 223, 224,
- 219, 199, 320, 321, 233, 446, 234, 447, 199, 324,
- 325, 372, 373, 332, 389, 240, 364, 36, 243, 458,
- 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
- 47, 320, 321, 247, 448, 391, 392, 251, 286, 287,
- 56, 152, 254, 228, 164, 263, 269, 171, 274, 275,
- 316, 379, 166, 273, 283, 382, 156, 156, 288, 289,
- 291, 292, 476, 293, 164, 479, 164, 294, 298, 299,
- 419, 432, 166, 300, 166, 55, 55, 55, 55, 473,
- 322, 327, 326, 328, 244, 396, 397, 398, 399, 94,
- 95, 160, 330, 161, 336, 343, 162, 99, 100, 101,
- 102, 348, 358, 103, 104, 357, 360, 105, 106, 107,
- 108, 109, 110, 111, 112, 113, 114, 363, 365, 115,
- 116, 117, 118, 119, 120, 121, 122, 123, 368, 371,
- 199, 200, 201, 202, 384, 94, 95, 160, 388, 161,
- 203, 204, 162, 99, 100, 101, 102, 395, 400, 103,
- 104, 401, 402, 105, 106, 107, 108, 109, 110, 111,
- 112, 113, 114, 403, 404, 115, 116, 117, 118, 119,
- 120, 121, 122, 123, 407, 412, 93, 424, 413, 427,
- 433, 434, 436, 372, 442, 163, 94, 95, 96, 450,
- 97, 451, 455, 98, 99, 100, 101, 102, 454, 457,
- 103, 104, 373, 461, 105, 106, 107, 108, 109, 110,
- 111, 112, 113, 114, 462, 226, 115, 116, 117, 118,
- 119, 120, 121, 122, 123, 94, 95, 96, 463, 97,
- 464, 465, 98, 99, 100, 101, 102, 466, 321, 103,
- 104, 469, 325, 105, 106, 107, 108, 109, 110, 111,
- 112, 113, 114, 470, 228, 115, 116, 117, 118, 119,
- 120, 121, 122, 123, 94, 95, 96, 471, 97, 472,
- 475, 98, 99, 100, 101, 102, 474, 477, 103, 104,
- 478, 480, 105, 106, 107, 108, 109, 110, 111, 112,
- 113, 114, 252, 309, 115, 116, 117, 118, 119, 120,
- 121, 122, 123, 94, 95, 96, 144, 97, 456, 318,
- 98, 99, 100, 101, 102, 221, 459, 103, 104, 405,
- 460, 105, 106, 107, 108, 109, 110, 111, 112, 113,
- 114, 390, 408, 115, 116, 117, 118, 119, 120, 121,
- 122, 123, 94, 95, 96, 422, 97, 435, 387, 98,
- 99, 100, 101, 102, 337, 260, 103, 104, 239, 323,
- 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
- 276, 410, 115, 116, 117, 118, 119, 120, 121, 122,
- 123, 94, 95, 96, 227, 97, 409, 256, 98, 99,
- 100, 101, 102, 271, 452, 103, 104, 250, 186, 105,
- 106, 107, 108, 109, 110, 111, 112, 113, 114, 51,
- 290, 115, 116, 117, 118, 119, 120, 121, 122, 123,
- 94, 95, 160, 0, 161, 0, 0, 162, 99, 100,
- 101, 102, 0, 0, 103, 104, 0, 0, 105, 106,
- 107, 108, 109, 110, 111, 112, 113, 114, 0, 0,
- 115, 116, 117, 118, 119, 120, 121, 122, 123, 0,
- 0, 0, 200, 201, 202, 94, 95, 160, 0, 161,
- 0, 0, 162, 99, 100, 101, 102, 0, 0, 103,
- 104, 0, 0, 105, 106, 107, 108, 109, 110, 111,
- 112, 113, 114, 0, 0, 115, 116, 117, 118, 119,
- 120, 121, 122, 123, 0, 0, 0, 0, 201, 202,
- 94, 95, 160, 0, 161, 0, 0, 162, 99, 100,
- 101, 102, 0, 0, 103, 104, 0, 0, 105, 106,
- 107, 108, 109, 110, 111, 112, 113, 114, 0, 0,
- 115, 116, 117, 118, 119, 120, 121, 122, 123, 0,
- 0, 94, 95, 160, 202, 161, 386, 0, 162, 99,
- 100, 101, 102, 0, 0, 103, 104, 0, 0, 105,
- 106, 107, 108, 109, 110, 111, 112, 113, 114, 0,
- 0, 115, 116, 117, 118, 119, 120, 121, 122, 123,
- 0, 94, 95, 160, 366, 161, 0, 0, 162, 99,
- 100, 101, 102, 0, 0, 103, 104, 0, 0, 105,
- 106, 107, 108, 109, 110, 111, 112, 113, 114, 0,
- 0, 115, 116, 117, 118, 119, 120, 121, 122, 123,
- 0, 94, 95, 160, 366, 161, 431, 0, 162, 99,
- 100, 101, 102, 0, 0, 103, 104, 0, 0, 105,
- 106, 107, 108, 109, 110, 111, 112, 113, 114, 0,
- 0, 115, 116, 117, 118, 119, 120, 121, 122, 123,
- 94, 95, 160, 0, 161, 0, 0, 162, 99, 100,
- 101, 102, 0, 0, 103, 104, 0, 0, 105, 106,
- 107, 108, 109, 110, 111, 112, 113, 114, 0, 0,
- 115, 116, 117, 118, 119, 120, 121, 122, 123, 0,
- 25, 26, 27, 0, 0, 0, 28, 29, 30, 31,
- 32, 0, 33, 34, 35, 36, 0, 0, 37, 38,
- 39, 40, 41, 42, 43, 44, 45, 46, 47
-};
-
-static const yytype_int16 yycheck[] =
-{
- 97, 98, 30, 125, 32, 139, 149, 69, 158, 101,
- 15, 65, 64, 173, 26, 396, 175, 69, 30, 65,
- 32, 362, 359, 3, 423, 147, 200, 201, 202, 63,
- 64, 71, 72, 34, 131, 69, 37, 3, 66, 93,
- 16, 163, 70, 19, 10, 426, 25, 93, 27, 28,
- 29, 450, 31, 3, 3, 5, 35, 36, 3, 28,
- 29, 12, 31, 160, 161, 162, 35, 36, 258, 166,
- 407, 412, 73, 454, 264, 167, 207, 208, 79, 80,
- 3, 82, 83, 84, 206, 207, 208, 99, 100, 90,
- 91, 92, 39, 105, 106, 32, 108, 109, 110, 111,
- 112, 232, 63, 64, 156, 0, 158, 159, 69, 268,
- 232, 173, 174, 64, 65, 9, 150, 129, 130, 68,
- 69, 173, 174, 4, 3, 159, 257, 8, 259, 66,
- 77, 10, 3, 70, 16, 257, 164, 259, 9, 4,
- 174, 331, 264, 25, 26, 10, 320, 321, 338, 8,
- 324, 325, 52, 53, 54, 3, 9, 5, 58, 59,
- 60, 61, 62, 11, 64, 65, 66, 64, 65, 52,
- 3, 3, 226, 5, 228, 58, 59, 9, 61, 310,
- 226, 186, 228, 66, 40, 41, 42, 199, 310, 150,
- 46, 4, 366, 3, 4, 4, 3, 10, 159, 211,
- 52, 10, 203, 204, 4, 4, 58, 59, 3, 61,
- 10, 10, 4, 174, 66, 4, 338, 52, 10, 4,
- 4, 200, 4, 202, 4, 10, 10, 67, 10, 3,
- 258, 71, 72, 261, 55, 56, 328, 4, 5, 399,
- 4, 5, 9, 5, 3, 9, 4, 9, 398, 3,
- 8, 373, 4, 5, 397, 309, 5, 9, 3, 4,
- 9, 8, 396, 309, 386, 67, 278, 279, 280, 281,
- 282, 368, 369, 370, 371, 4, 330, 43, 44, 45,
- 46, 47, 4, 62, 330, 64, 65, 5, 6, 7,
- 41, 54, 55, 56, 4, 417, 3, 419, 54, 55,
- 56, 25, 26, 331, 332, 3, 307, 67, 4, 431,
- 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
- 80, 55, 56, 4, 421, 29, 30, 3, 183, 184,
- 5, 11, 4, 3, 388, 4, 4, 399, 4, 3,
- 42, 320, 388, 8, 4, 324, 398, 399, 4, 4,
- 4, 4, 474, 4, 408, 477, 410, 4, 4, 4,
- 372, 389, 408, 4, 410, 344, 345, 346, 347, 466,
- 3, 10, 4, 60, 12, 344, 345, 346, 347, 13,
- 14, 15, 3, 17, 4, 4, 20, 21, 22, 23,
- 24, 4, 4, 27, 28, 43, 10, 31, 32, 33,
- 34, 35, 36, 37, 38, 39, 40, 10, 4, 43,
- 44, 45, 46, 47, 48, 49, 50, 51, 16, 16,
- 54, 55, 56, 57, 4, 13, 14, 15, 3, 17,
- 64, 65, 20, 21, 22, 23, 24, 4, 4, 27,
- 28, 4, 4, 31, 32, 33, 34, 35, 36, 37,
- 38, 39, 40, 4, 4, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 4, 4, 3, 10, 4, 10,
- 3, 3, 3, 25, 4, 63, 13, 14, 15, 4,
- 17, 3, 3, 20, 21, 22, 23, 24, 4, 4,
- 27, 28, 26, 4, 31, 32, 33, 34, 35, 36,
- 37, 38, 39, 40, 4, 3, 43, 44, 45, 46,
- 47, 48, 49, 50, 51, 13, 14, 15, 4, 17,
- 4, 4, 20, 21, 22, 23, 24, 16, 56, 27,
- 28, 3, 56, 31, 32, 33, 34, 35, 36, 37,
- 38, 39, 40, 4, 3, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 13, 14, 15, 4, 17, 4,
- 3, 20, 21, 22, 23, 24, 19, 19, 27, 28,
- 4, 4, 31, 32, 33, 34, 35, 36, 37, 38,
- 39, 40, 155, 3, 43, 44, 45, 46, 47, 48,
- 49, 50, 51, 13, 14, 15, 62, 17, 428, 221,
- 20, 21, 22, 23, 24, 114, 433, 27, 28, 357,
- 434, 31, 32, 33, 34, 35, 36, 37, 38, 39,
- 40, 338, 3, 43, 44, 45, 46, 47, 48, 49,
- 50, 51, 13, 14, 15, 377, 17, 394, 331, 20,
- 21, 22, 23, 24, 261, 163, 27, 28, 140, 235,
- 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
- 179, 3, 43, 44, 45, 46, 47, 48, 49, 50,
- 51, 13, 14, 15, 124, 17, 361, 159, 20, 21,
- 22, 23, 24, 174, 425, 27, 28, 150, 76, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 22,
- 188, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- 13, 14, 15, -1, 17, -1, -1, 20, 21, 22,
- 23, 24, -1, -1, 27, 28, -1, -1, 31, 32,
- 33, 34, 35, 36, 37, 38, 39, 40, -1, -1,
- 43, 44, 45, 46, 47, 48, 49, 50, 51, -1,
- -1, -1, 55, 56, 57, 13, 14, 15, -1, 17,
- -1, -1, 20, 21, 22, 23, 24, -1, -1, 27,
- 28, -1, -1, 31, 32, 33, 34, 35, 36, 37,
- 38, 39, 40, -1, -1, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, -1, -1, -1, -1, 56, 57,
- 13, 14, 15, -1, 17, -1, -1, 20, 21, 22,
- 23, 24, -1, -1, 27, 28, -1, -1, 31, 32,
- 33, 34, 35, 36, 37, 38, 39, 40, -1, -1,
- 43, 44, 45, 46, 47, 48, 49, 50, 51, -1,
- -1, 13, 14, 15, 57, 17, 18, -1, 20, 21,
- 22, 23, 24, -1, -1, 27, 28, -1, -1, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, -1,
- -1, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- -1, 13, 14, 15, 56, 17, -1, -1, 20, 21,
- 22, 23, 24, -1, -1, 27, 28, -1, -1, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, -1,
- -1, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- -1, 13, 14, 15, 56, 17, 18, -1, 20, 21,
- 22, 23, 24, -1, -1, 27, 28, -1, -1, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, -1,
- -1, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- 13, 14, 15, -1, 17, -1, -1, 20, 21, 22,
- 23, 24, -1, -1, 27, 28, -1, -1, 31, 32,
- 33, 34, 35, 36, 37, 38, 39, 40, -1, -1,
- 43, 44, 45, 46, 47, 48, 49, 50, 51, -1,
- 52, 53, 54, -1, -1, -1, 58, 59, 60, 61,
- 62, -1, 64, 65, 66, 67, -1, -1, 70, 71,
- 72, 73, 74, 75, 76, 77, 78, 79, 80
-};
-
- /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
- symbol of state STATE-NUM. */
-static const yytype_uint8 yystos[] =
-{
- 0, 3, 127, 128, 129, 140, 141, 143, 144, 146,
- 149, 152, 154, 155, 156, 158, 159, 160, 162, 163,
- 164, 165, 166, 169, 170, 52, 53, 54, 58, 59,
- 60, 61, 62, 64, 65, 66, 67, 70, 71, 72,
- 73, 74, 75, 76, 77, 78, 79, 80, 3, 156,
- 3, 165, 0, 9, 100, 101, 5, 9, 96, 98,
- 3, 89, 101, 100, 100, 3, 98, 114, 139, 100,
- 98, 139, 8, 85, 85, 100, 100, 85, 9, 161,
- 161, 3, 162, 162, 162, 3, 163, 163, 163, 3,
- 162, 163, 163, 3, 13, 14, 15, 17, 20, 21,
- 22, 23, 24, 27, 28, 31, 32, 33, 34, 35,
- 36, 37, 38, 39, 40, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 95, 105, 106, 107, 114, 121,
- 122, 123, 124, 130, 134, 135, 136, 137, 138, 150,
- 153, 4, 52, 4, 89, 3, 10, 88, 147, 150,
- 153, 3, 11, 87, 92, 94, 96, 142, 150, 153,
- 15, 17, 20, 63, 106, 115, 123, 139, 99, 3,
- 93, 94, 145, 150, 153, 139, 8, 83, 84, 85,
- 3, 151, 86, 68, 69, 157, 158, 161, 85, 85,
- 85, 85, 85, 168, 4, 4, 85, 85, 85, 54,
- 55, 56, 57, 64, 65, 101, 102, 102, 102, 98,
- 98, 99, 98, 98, 98, 98, 98, 98, 98, 41,
- 103, 103, 5, 6, 7, 97, 3, 134, 3, 124,
- 98, 98, 102, 4, 3, 95, 131, 132, 133, 130,
- 3, 90, 91, 4, 12, 124, 126, 4, 3, 88,
- 147, 3, 87, 96, 4, 92, 142, 102, 102, 102,
- 126, 114, 125, 4, 102, 99, 4, 98, 62, 4,
- 93, 145, 84, 8, 4, 3, 127, 148, 52, 58,
- 59, 61, 66, 4, 4, 10, 83, 83, 4, 4,
- 168, 4, 4, 4, 4, 3, 4, 167, 4, 4,
- 4, 98, 86, 101, 86, 86, 101, 85, 85, 3,
- 108, 109, 124, 109, 109, 98, 42, 104, 104, 109,
- 55, 56, 3, 131, 55, 56, 4, 10, 60, 109,
- 3, 108, 114, 119, 120, 109, 4, 125, 108, 116,
- 124, 4, 84, 4, 52, 58, 59, 61, 4, 98,
- 98, 98, 98, 98, 4, 4, 4, 43, 4, 4,
- 10, 4, 4, 10, 85, 4, 56, 109, 16, 16,
- 19, 16, 25, 26, 110, 111, 112, 113, 86, 101,
- 86, 86, 101, 86, 4, 99, 18, 119, 3, 114,
- 116, 29, 30, 117, 118, 4, 100, 100, 100, 100,
- 4, 4, 4, 4, 4, 97, 135, 4, 3, 136,
- 3, 138, 4, 4, 86, 102, 102, 102, 102, 98,
- 124, 16, 112, 4, 10, 4, 4, 10, 4, 4,
- 124, 18, 114, 3, 3, 117, 3, 90, 95, 88,
- 92, 93, 4, 135, 138, 4, 124, 124, 102, 132,
- 4, 3, 133, 90, 4, 3, 91, 4, 124, 110,
- 111, 4, 4, 4, 4, 4, 16, 132, 90, 3,
- 4, 4, 4, 102, 19, 3, 124, 19, 4, 124,
- 4
-};
-
- /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
-static const yytype_uint8 yyr1[] =
-{
- 0, 82, 83, 83, 84, 84, 85, 86, 86, 87,
- 88, 88, 89, 90, 90, 90, 91, 91, 92, 93,
- 94, 94, 95, 96, 97, 97, 97, 98, 98, 99,
- 99, 100, 100, 101, 102, 102, 103, 103, 104, 104,
- 105, 105, 105, 106, 106, 106, 106, 106, 106, 106,
- 106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
- 106, 106, 106, 106, 106, 106, 106, 106, 106, 107,
- 107, 107, 107, 107, 108, 109, 109, 110, 111, 112,
- 112, 113, 113, 114, 115, 115, 115, 115, 115, 116,
- 116, 117, 117, 118, 118, 119, 119, 120, 120, 120,
- 120, 120, 120, 121, 122, 123, 124, 124, 125, 125,
- 126, 127, 128, 129, 130, 130, 130, 130, 130, 131,
- 132, 132, 132, 133, 133, 134, 135, 135, 135, 136,
- 136, 137, 138, 138, 138, 139, 139, 140, 140, 141,
- 142, 142, 142, 142, 143, 143, 144, 145, 145, 145,
- 145, 146, 147, 147, 147, 148, 148, 148, 148, 148,
- 148, 149, 150, 151, 151, 151, 151, 151, 152, 153,
- 154, 154, 155, 156, 156, 156, 156, 156, 156, 156,
- 156, 156, 156, 156, 157, 157, 158, 158, 159, 160,
- 161, 161, 162, 162, 162, 163, 163, 164, 164, 164,
- 164, 164, 164, 164, 164, 164, 165, 165, 165, 165,
- 166, 166, 167, 168, 168, 169, 169, 169, 170
-};
-
- /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
-static const yytype_uint8 yyr2[] =
-{
- 0, 2, 1, 2, 0, 1, 1, 0, 2, 1,
- 1, 4, 4, 1, 5, 6, 0, 5, 2, 1,
- 1, 2, 4, 1, 1, 1, 1, 1, 1, 0,
- 2, 0, 1, 1, 0, 1, 0, 1, 0, 1,
- 1, 1, 1, 1, 1, 1, 1, 2, 2, 3,
- 1, 2, 2, 2, 2, 2, 2, 2, 3, 3,
- 2, 1, 1, 1, 1, 1, 1, 2, 2, 5,
- 5, 5, 8, 6, 4, 2, 1, 3, 2, 1,
- 1, 1, 2, 3, 2, 3, 3, 3, 3, 2,
- 2, 4, 4, 1, 2, 2, 1, 8, 4, 9,
- 5, 3, 2, 1, 1, 1, 0, 2, 0, 2,
- 1, 5, 1, 5, 2, 1, 3, 2, 2, 1,
- 1, 5, 6, 0, 5, 1, 1, 5, 6, 1,
- 5, 1, 1, 5, 6, 4, 1, 6, 5, 5,
- 1, 2, 2, 5, 6, 5, 5, 1, 2, 2,
- 4, 5, 2, 2, 2, 5, 5, 5, 5, 5,
- 1, 6, 5, 4, 4, 4, 4, 4, 5, 4,
- 4, 5, 4, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 0, 1, 1, 2, 1, 1,
- 0, 1, 5, 6, 6, 6, 5, 5, 5, 5,
- 5, 5, 4, 4, 5, 5, 1, 1, 1, 5,
- 1, 2, 4, 0, 2, 0, 1, 1, 1
-};
-
-
-#define yyerrok (yyerrstatus = 0)
-#define yyclearin (yychar = YYEMPTY)
-#define YYEMPTY (-2)
-#define YYEOF 0
-
-#define YYACCEPT goto yyacceptlab
-#define YYABORT goto yyabortlab
-#define YYERROR goto yyerrorlab
-
-
-#define YYRECOVERING() (!!yyerrstatus)
-
-#define YYBACKUP(Token, Value) \
-do \
- if (yychar == YYEMPTY) \
- { \
- yychar = (Token); \
- yylval = (Value); \
- YYPOPSTACK (yylen); \
- yystate = *yyssp; \
- goto yybackup; \
- } \
- else \
- { \
- yyerror (&yylloc, lexer, parser, YY_("syntax error: cannot back up")); \
- YYERROR; \
- } \
-while (0)
-
-/* Error token number */
-#define YYTERROR 1
-#define YYERRCODE 256
-
-
-/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
- If N is 0, then set CURRENT to the empty location which ends
- the previous symbol: RHS[0] (always defined). */
-
-#ifndef YYLLOC_DEFAULT
-# define YYLLOC_DEFAULT(Current, Rhs, N) \
- do \
- if (N) \
- { \
- (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
- (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
- (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
- (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
- } \
- else \
- { \
- (Current).first_line = (Current).last_line = \
- YYRHSLOC (Rhs, 0).last_line; \
- (Current).first_column = (Current).last_column = \
- YYRHSLOC (Rhs, 0).last_column; \
- } \
- while (0)
-#endif
-
-#define YYRHSLOC(Rhs, K) ((Rhs)[K])
-
-
-/* Enable debugging if requested. */
-#if WABT_WAST_PARSER_DEBUG
-
-# ifndef YYFPRINTF
-# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
-# define YYFPRINTF fprintf
-# endif
-
-# define YYDPRINTF(Args) \
-do { \
- if (yydebug) \
- YYFPRINTF Args; \
-} while (0)
-
-
-/* YY_LOCATION_PRINT -- Print the location on the stream.
- This macro was not mandated originally: define only if we know
- we won't break user code: when these are the locations we know. */
-
-#ifndef YY_LOCATION_PRINT
-# if defined WABT_WAST_PARSER_LTYPE_IS_TRIVIAL && WABT_WAST_PARSER_LTYPE_IS_TRIVIAL
-
-/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
-
-YY_ATTRIBUTE_UNUSED
-static unsigned
-yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
-{
- unsigned res = 0;
- int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
- if (0 <= yylocp->first_line)
- {
- res += YYFPRINTF (yyo, "%d", yylocp->first_line);
- if (0 <= yylocp->first_column)
- res += YYFPRINTF (yyo, ".%d", yylocp->first_column);
- }
- if (0 <= yylocp->last_line)
- {
- if (yylocp->first_line < yylocp->last_line)
- {
- res += YYFPRINTF (yyo, "-%d", yylocp->last_line);
- if (0 <= end_col)
- res += YYFPRINTF (yyo, ".%d", end_col);
- }
- else if (0 <= end_col && yylocp->first_column < end_col)
- res += YYFPRINTF (yyo, "-%d", end_col);
- }
- return res;
- }
-
-# define YY_LOCATION_PRINT(File, Loc) \
- yy_location_print_ (File, &(Loc))
-
-# else
-# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
-# endif
-#endif
-
-
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
-do { \
- if (yydebug) \
- { \
- YYFPRINTF (stderr, "%s ", Title); \
- yy_symbol_print (stderr, \
- Type, Value, Location, lexer, parser); \
- YYFPRINTF (stderr, "\n"); \
- } \
-} while (0)
-
-
-/*----------------------------------------.
-| Print this symbol's value on YYOUTPUT. |
-`----------------------------------------*/
-
-static void
-yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, ::wabt::WastLexer* lexer, ::wabt::WastParser* parser)
-{
- FILE *yyo = yyoutput;
- YYUSE (yyo);
- YYUSE (yylocationp);
- YYUSE (lexer);
- YYUSE (parser);
- if (!yyvaluep)
- return;
-# ifdef YYPRINT
- if (yytype < YYNTOKENS)
- YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
-# endif
- YYUSE (yytype);
-}
-
-
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
-
-static void
-yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, ::wabt::WastLexer* lexer, ::wabt::WastParser* parser)
-{
- YYFPRINTF (yyoutput, "%s %s (",
- yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
-
- YY_LOCATION_PRINT (yyoutput, *yylocationp);
- YYFPRINTF (yyoutput, ": ");
- yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, lexer, parser);
- YYFPRINTF (yyoutput, ")");
-}
-
-/*------------------------------------------------------------------.
-| yy_stack_print -- Print the state stack from its BOTTOM up to its |
-| TOP (included). |
-`------------------------------------------------------------------*/
-
-static void
-yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
-{
- YYFPRINTF (stderr, "Stack now");
- for (; yybottom <= yytop; yybottom++)
- {
- int yybot = *yybottom;
- YYFPRINTF (stderr, " %d", yybot);
- }
- YYFPRINTF (stderr, "\n");
-}
-
-# define YY_STACK_PRINT(Bottom, Top) \
-do { \
- if (yydebug) \
- yy_stack_print ((Bottom), (Top)); \
-} while (0)
-
-
-/*------------------------------------------------.
-| Report that the YYRULE is going to be reduced. |
-`------------------------------------------------*/
-
-static void
-yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, ::wabt::WastLexer* lexer, ::wabt::WastParser* parser)
-{
- unsigned long int yylno = yyrline[yyrule];
- int yynrhs = yyr2[yyrule];
- int yyi;
- YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
- yyrule - 1, yylno);
- /* The symbols being reduced. */
- for (yyi = 0; yyi < yynrhs; yyi++)
- {
- YYFPRINTF (stderr, " $%d = ", yyi + 1);
- yy_symbol_print (stderr,
- yystos[yyssp[yyi + 1 - yynrhs]],
- &(yyvsp[(yyi + 1) - (yynrhs)])
- , &(yylsp[(yyi + 1) - (yynrhs)]) , lexer, parser);
- YYFPRINTF (stderr, "\n");
- }
-}
-
-# define YY_REDUCE_PRINT(Rule) \
-do { \
- if (yydebug) \
- yy_reduce_print (yyssp, yyvsp, yylsp, Rule, lexer, parser); \
-} while (0)
-
-/* Nonzero means print parse trace. It is left uninitialized so that
- multiple parsers can coexist. */
-int yydebug;
-#else /* !WABT_WAST_PARSER_DEBUG */
-# define YYDPRINTF(Args)
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
-# define YY_STACK_PRINT(Bottom, Top)
-# define YY_REDUCE_PRINT(Rule)
-#endif /* !WABT_WAST_PARSER_DEBUG */
-
-
-/* YYINITDEPTH -- initial size of the parser's stacks. */
-#ifndef YYINITDEPTH
-# define YYINITDEPTH 200
-#endif
-
-/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
- if the built-in stack extension method is used).
-
- Do not make this value too large; the results are undefined if
- YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
- evaluated with infinite-precision integer arithmetic. */
-
-#ifndef YYMAXDEPTH
-# define YYMAXDEPTH 10000
-#endif
-
-
-#if YYERROR_VERBOSE
-
-# ifndef yystrlen
-# if defined __GLIBC__ && defined _STRING_H
-# define yystrlen strlen
-# else
-/* Return the length of YYSTR. */
-static YYSIZE_T
-yystrlen (const char *yystr)
-{
- YYSIZE_T yylen;
- for (yylen = 0; yystr[yylen]; yylen++)
- continue;
- return yylen;
-}
-# endif
-# endif
-
-# ifndef yystpcpy
-# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
-# define yystpcpy stpcpy
-# else
-/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
- YYDEST. */
-static char *
-yystpcpy (char *yydest, const char *yysrc)
-{
- char *yyd = yydest;
- const char *yys = yysrc;
-
- while ((*yyd++ = *yys++) != '\0')
- continue;
-
- return yyd - 1;
-}
-# endif
-# endif
-
-# ifndef yytnamerr
-/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
- quotes and backslashes, so that it's suitable for yyerror. The
- heuristic is that double-quoting is unnecessary unless the string
- contains an apostrophe, a comma, or backslash (other than
- backslash-backslash). YYSTR is taken from yytname. If YYRES is
- null, do not copy; instead, return the length of what the result
- would have been. */
-static YYSIZE_T
-yytnamerr (char *yyres, const char *yystr)
-{
- if (*yystr == '"')
- {
- YYSIZE_T yyn = 0;
- char const *yyp = yystr;
-
- for (;;)
- switch (*++yyp)
- {
- case '\'':
- case ',':
- goto do_not_strip_quotes;
-
- case '\\':
- if (*++yyp != '\\')
- goto do_not_strip_quotes;
- /* Fall through. */
- default:
- if (yyres)
- yyres[yyn] = *yyp;
- yyn++;
- break;
-
- case '"':
- if (yyres)
- yyres[yyn] = '\0';
- return yyn;
- }
- do_not_strip_quotes: ;
- }
-
- if (! yyres)
- return yystrlen (yystr);
-
- return yystpcpy (yyres, yystr) - yyres;
-}
-# endif
-
-/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
- about the unexpected token YYTOKEN for the state stack whose top is
- YYSSP.
-
- Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
- not large enough to hold the message. In that case, also set
- *YYMSG_ALLOC to the required number of bytes. Return 2 if the
- required number of bytes is too large to store. */
-static int
-yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
- yytype_int16 *yyssp, int yytoken)
-{
- YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
- YYSIZE_T yysize = yysize0;
- enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
- /* Internationalized format string. */
- const char *yyformat = YY_NULLPTR;
- /* Arguments of yyformat. */
- char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
- /* Number of reported tokens (one for the "unexpected", one per
- "expected"). */
- int yycount = 0;
-
- /* There are many possibilities here to consider:
- - If this state is a consistent state with a default action, then
- the only way this function was invoked is if the default action
- is an error action. In that case, don't check for expected
- tokens because there are none.
- - The only way there can be no lookahead present (in yychar) is if
- this state is a consistent state with a default action. Thus,
- detecting the absence of a lookahead is sufficient to determine
- that there is no unexpected or expected token to report. In that
- case, just report a simple "syntax error".
- - Don't assume there isn't a lookahead just because this state is a
- consistent state with a default action. There might have been a
- previous inconsistent state, consistent state with a non-default
- action, or user semantic action that manipulated yychar.
- - Of course, the expected token list depends on states to have
- correct lookahead information, and it depends on the parser not
- to perform extra reductions after fetching a lookahead from the
- scanner and before detecting a syntax error. Thus, state merging
- (from LALR or IELR) and default reductions corrupt the expected
- token list. However, the list is correct for canonical LR with
- one exception: it will still contain any token that will not be
- accepted due to an error action in a later state.
- */
- if (yytoken != YYEMPTY)
- {
- int yyn = yypact[*yyssp];
- yyarg[yycount++] = yytname[yytoken];
- if (!yypact_value_is_default (yyn))
- {
- /* Start YYX at -YYN if negative to avoid negative indexes in
- YYCHECK. In other words, skip the first -YYN actions for
- this state because they are default actions. */
- int yyxbegin = yyn < 0 ? -yyn : 0;
- /* Stay within bounds of both yycheck and yytname. */
- int yychecklim = YYLAST - yyn + 1;
- int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
- int yyx;
-
- for (yyx = yyxbegin; yyx < yyxend; ++yyx)
- if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
- && !yytable_value_is_error (yytable[yyx + yyn]))
- {
- if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
- {
- yycount = 1;
- yysize = yysize0;
- break;
- }
- yyarg[yycount++] = yytname[yyx];
- {
- YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
- if (! (yysize <= yysize1
- && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
- return 2;
- yysize = yysize1;
- }
- }
- }
- }
-
- switch (yycount)
- {
-# define YYCASE_(N, S) \
- case N: \
- yyformat = S; \
- break
- YYCASE_(0, YY_("syntax error"));
- YYCASE_(1, YY_("syntax error, unexpected %s"));
- YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
- YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
- YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
- YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
-# undef YYCASE_
- }
-
- {
- YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
- if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
- return 2;
- yysize = yysize1;
- }
-
- if (*yymsg_alloc < yysize)
- {
- *yymsg_alloc = 2 * yysize;
- if (! (yysize <= *yymsg_alloc
- && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
- *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
- return 1;
- }
-
- /* Avoid sprintf, as that infringes on the user's name space.
- Don't have undefined behavior even if the translation
- produced a string with the wrong number of "%s"s. */
- {
- char *yyp = *yymsg;
- int yyi = 0;
- while ((*yyp = *yyformat) != '\0')
- if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
- {
- yyp += yytnamerr (yyp, yyarg[yyi++]);
- yyformat += 2;
- }
- else
- {
- yyp++;
- yyformat++;
- }
- }
- return 0;
-}
-#endif /* YYERROR_VERBOSE */
-
-/*-----------------------------------------------.
-| Release the memory associated to this symbol. |
-`-----------------------------------------------*/
-
-static void
-yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, ::wabt::WastLexer* lexer, ::wabt::WastParser* parser)
-{
- YYUSE (yyvaluep);
- YYUSE (yylocationp);
- YYUSE (lexer);
- YYUSE (parser);
- if (!yymsg)
- yymsg = "Deleting";
- YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
-
- YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
- switch (yytype)
- {
- case 83: /* text_list */
-#line 316 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).texts); }
-#line 1803 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 84: /* text_list_opt */
-#line 316 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).texts); }
-#line 1809 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 85: /* quoted_text */
-#line 315 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).string); }
-#line 1815 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 86: /* value_type_list */
-#line 317 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).types); }
-#line 1821 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 88: /* global_type */
-#line 309 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).global); }
-#line 1827 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 89: /* func_type */
-#line 308 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).func_sig); }
-#line 1833 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 90: /* func_sig */
-#line 308 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).func_sig); }
-#line 1839 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 91: /* func_sig_result */
-#line 308 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).func_sig); }
-#line 1845 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 93: /* memory_sig */
-#line 311 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).memory); }
-#line 1851 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 95: /* type_use */
-#line 318 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).var); }
-#line 1857 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 98: /* var */
-#line 318 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).var); }
-#line 1863 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 99: /* var_list */
-#line 319 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).vars); }
-#line 1869 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 100: /* bind_var_opt */
-#line 315 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).string); }
-#line 1875 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 101: /* bind_var */
-#line 315 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).string); }
-#line 1881 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 102: /* labeling_opt */
-#line 315 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).string); }
-#line 1887 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 105: /* instr */
-#line 305 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).expr_list); }
-#line 1893 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 106: /* plain_instr */
-#line 304 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).expr); }
-#line 1899 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 107: /* block_instr */
-#line 304 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).expr); }
-#line 1905 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 108: /* block_sig */
-#line 317 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).types); }
-#line 1911 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 109: /* block */
-#line 299 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).block); }
-#line 1917 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 114: /* expr */
-#line 305 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).expr_list); }
-#line 1923 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 115: /* expr1 */
-#line 305 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).expr_list); }
-#line 1929 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 119: /* if_block */
-#line 305 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).expr_list); }
-#line 1935 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 120: /* if_ */
-#line 305 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).expr_list); }
-#line 1941 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 124: /* instr_list */
-#line 305 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).expr_list); }
-#line 1947 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 125: /* expr_list */
-#line 305 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).expr_list); }
-#line 1953 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 126: /* const_expr */
-#line 305 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).expr_list); }
-#line 1959 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 129: /* func */
-#line 306 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).module_fields); }
-#line 1965 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 130: /* func_fields */
-#line 306 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).module_fields); }
-#line 1971 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 131: /* func_fields_import */
-#line 307 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).func); }
-#line 1977 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 132: /* func_fields_import1 */
-#line 307 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).func); }
-#line 1983 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 133: /* func_fields_import_result */
-#line 307 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).func); }
-#line 1989 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 134: /* func_fields_body */
-#line 307 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).func); }
-#line 1995 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 135: /* func_fields_body1 */
-#line 307 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).func); }
-#line 2001 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 136: /* func_result_body */
-#line 307 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).func); }
-#line 2007 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 137: /* func_body */
-#line 307 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).func); }
-#line 2013 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 138: /* func_body1 */
-#line 307 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).func); }
-#line 2019 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 139: /* offset */
-#line 305 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).expr_list); }
-#line 2025 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 141: /* table */
-#line 306 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).module_fields); }
-#line 2031 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 142: /* table_fields */
-#line 306 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).module_fields); }
-#line 2037 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 144: /* memory */
-#line 306 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).module_fields); }
-#line 2043 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 145: /* memory_fields */
-#line 306 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).module_fields); }
-#line 2049 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 146: /* global */
-#line 306 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).module_fields); }
-#line 2055 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 147: /* global_fields */
-#line 306 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).module_fields); }
-#line 2061 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 148: /* import_desc */
-#line 310 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).import); }
-#line 2067 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 150: /* inline_import */
-#line 310 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).import); }
-#line 2073 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 151: /* export_desc */
-#line 303 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).export_); }
-#line 2079 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 153: /* inline_export */
-#line 303 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).export_); }
-#line 2085 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 156: /* module_field */
-#line 306 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).module_fields); }
-#line 2091 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 157: /* module_fields_opt */
-#line 312 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).module); }
-#line 2097 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 158: /* module_fields */
-#line 312 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).module); }
-#line 2103 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 159: /* module */
-#line 312 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).module); }
-#line 2109 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 160: /* inline_module */
-#line 312 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).module); }
-#line 2115 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 161: /* script_var_opt */
-#line 318 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).var); }
-#line 2121 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 162: /* script_module */
-#line 313 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).script_module); }
-#line 2127 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 163: /* action */
-#line 298 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).action); }
-#line 2133 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 164: /* assertion */
-#line 300 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).command); }
-#line 2139 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 165: /* cmd */
-#line 300 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).command); }
-#line 2145 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 166: /* cmd_list */
-#line 301 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).commands); }
-#line 2151 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 168: /* const_list */
-#line 302 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).consts); }
-#line 2157 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
- case 169: /* script */
-#line 314 "src/wast-parser.y" /* yacc.c:1257 */
- { delete ((*yyvaluep).script); }
-#line 2163 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1257 */
- break;
-
-
- default:
- break;
- }
- YY_IGNORE_MAYBE_UNINITIALIZED_END
-}
-
-
-
-
-/*----------.
-| yyparse. |
-`----------*/
-
-int
-yyparse (::wabt::WastLexer* lexer, ::wabt::WastParser* parser)
-{
-/* The lookahead symbol. */
-int yychar;
-
-
-/* The semantic value of the lookahead symbol. */
-/* Default value used for initialization, for pacifying older GCCs
- or non-GCC compilers. */
-YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
-YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
-
-/* Location data for the lookahead symbol. */
-static YYLTYPE yyloc_default
-# if defined WABT_WAST_PARSER_LTYPE_IS_TRIVIAL && WABT_WAST_PARSER_LTYPE_IS_TRIVIAL
- = { 1, 1, 1, 1 }
-# endif
-;
-YYLTYPE yylloc = yyloc_default;
-
- /* Number of syntax errors so far. */
- int yynerrs;
-
- int yystate;
- /* Number of tokens to shift before error messages enabled. */
- int yyerrstatus;
-
- /* The stacks and their tools:
- 'yyss': related to states.
- 'yyvs': related to semantic values.
- 'yyls': related to locations.
-
- Refer to the stacks through separate pointers, to allow yyoverflow
- to reallocate them elsewhere. */
-
- /* The state stack. */
- yytype_int16 yyssa[YYINITDEPTH];
- yytype_int16 *yyss;
- yytype_int16 *yyssp;
-
- /* The semantic value stack. */
- YYSTYPE yyvsa[YYINITDEPTH];
- YYSTYPE *yyvs;
- YYSTYPE *yyvsp;
-
- /* The location stack. */
- YYLTYPE yylsa[YYINITDEPTH];
- YYLTYPE *yyls;
- YYLTYPE *yylsp;
-
- /* The locations where the error started and ended. */
- YYLTYPE yyerror_range[3];
-
- YYSIZE_T yystacksize;
-
- int yyn;
- int yyresult;
- /* Lookahead token as an internal (translated) token number. */
- int yytoken = 0;
- /* The variables used to return semantic value and location from the
- action routines. */
- YYSTYPE yyval;
- YYLTYPE yyloc;
-
-#if YYERROR_VERBOSE
- /* Buffer for error messages, and its allocated size. */
- char yymsgbuf[128];
- char *yymsg = yymsgbuf;
- YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
-#endif
-
-#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
-
- /* The number of symbols on the RHS of the reduced rule.
- Keep to zero when no symbol should be popped. */
- int yylen = 0;
-
- yyssp = yyss = yyssa;
- yyvsp = yyvs = yyvsa;
- yylsp = yyls = yylsa;
- yystacksize = YYINITDEPTH;
-
- YYDPRINTF ((stderr, "Starting parse\n"));
-
- yystate = 0;
- yyerrstatus = 0;
- yynerrs = 0;
- yychar = YYEMPTY; /* Cause a token to be read. */
- yylsp[0] = yylloc;
- goto yysetstate;
-
-/*------------------------------------------------------------.
-| yynewstate -- Push a new state, which is found in yystate. |
-`------------------------------------------------------------*/
- yynewstate:
- /* In all cases, when you get here, the value and location stacks
- have just been pushed. So pushing a state here evens the stacks. */
- yyssp++;
-
- yysetstate:
- *yyssp = yystate;
-
- if (yyss + yystacksize - 1 <= yyssp)
- {
- /* Get the current used size of the three stacks, in elements. */
- YYSIZE_T yysize = yyssp - yyss + 1;
-
-#ifdef yyoverflow
- {
- /* Give user a chance to reallocate the stack. Use copies of
- these so that the &'s don't force the real ones into
- memory. */
- YYSTYPE *yyvs1 = yyvs;
- yytype_int16 *yyss1 = yyss;
- YYLTYPE *yyls1 = yyls;
-
- /* Each stack pointer address is followed by the size of the
- data in use in that stack, in bytes. This used to be a
- conditional around just the two extra args, but that might
- be undefined if yyoverflow is a macro. */
- yyoverflow (YY_("memory exhausted"),
- &yyss1, yysize * sizeof (*yyssp),
- &yyvs1, yysize * sizeof (*yyvsp),
- &yyls1, yysize * sizeof (*yylsp),
- &yystacksize);
-
- yyls = yyls1;
- yyss = yyss1;
- yyvs = yyvs1;
- }
-#else /* no yyoverflow */
-# ifndef YYSTACK_RELOCATE
- goto yyexhaustedlab;
-# else
- /* Extend the stack our own way. */
- if (YYMAXDEPTH <= yystacksize)
- goto yyexhaustedlab;
- yystacksize *= 2;
- if (YYMAXDEPTH < yystacksize)
- yystacksize = YYMAXDEPTH;
-
- {
- yytype_int16 *yyss1 = yyss;
- union yyalloc *yyptr =
- (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
- if (! yyptr)
- goto yyexhaustedlab;
- YYSTACK_RELOCATE (yyss_alloc, yyss);
- YYSTACK_RELOCATE (yyvs_alloc, yyvs);
- YYSTACK_RELOCATE (yyls_alloc, yyls);
-# undef YYSTACK_RELOCATE
- if (yyss1 != yyssa)
- YYSTACK_FREE (yyss1);
- }
-# endif
-#endif /* no yyoverflow */
-
- yyssp = yyss + yysize - 1;
- yyvsp = yyvs + yysize - 1;
- yylsp = yyls + yysize - 1;
-
- YYDPRINTF ((stderr, "Stack size increased to %lu\n",
- (unsigned long int) yystacksize));
-
- if (yyss + yystacksize - 1 <= yyssp)
- YYABORT;
- }
-
- YYDPRINTF ((stderr, "Entering state %d\n", yystate));
-
- if (yystate == YYFINAL)
- YYACCEPT;
-
- goto yybackup;
-
-/*-----------.
-| yybackup. |
-`-----------*/
-yybackup:
-
- /* Do appropriate processing given the current state. Read a
- lookahead token if we need one and don't already have one. */
-
- /* First try to decide what to do without reference to lookahead token. */
- yyn = yypact[yystate];
- if (yypact_value_is_default (yyn))
- goto yydefault;
-
- /* Not known => get a lookahead token if don't already have one. */
-
- /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
- if (yychar == YYEMPTY)
- {
- YYDPRINTF ((stderr, "Reading a token: "));
- yychar = yylex (&yylval, &yylloc);
- }
-
- if (yychar <= YYEOF)
- {
- yychar = yytoken = YYEOF;
- YYDPRINTF ((stderr, "Now at end of input.\n"));
- }
- else
- {
- yytoken = YYTRANSLATE (yychar);
- YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
- }
-
- /* If the proper action on seeing token YYTOKEN is to reduce or to
- detect an error, take that action. */
- yyn += yytoken;
- if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
- goto yydefault;
- yyn = yytable[yyn];
- if (yyn <= 0)
- {
- if (yytable_value_is_error (yyn))
- goto yyerrlab;
- yyn = -yyn;
- goto yyreduce;
- }
-
- /* Count tokens shifted since error; after three, turn off error
- status. */
- if (yyerrstatus)
- yyerrstatus--;
-
- /* Shift the lookahead token. */
- YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
-
- /* Discard the shifted token. */
- yychar = YYEMPTY;
-
- yystate = yyn;
- YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
- *++yyvsp = yylval;
- YY_IGNORE_MAYBE_UNINITIALIZED_END
- *++yylsp = yylloc;
- goto yynewstate;
-
-
-/*-----------------------------------------------------------.
-| yydefault -- do the default action for the current state. |
-`-----------------------------------------------------------*/
-yydefault:
- yyn = yydefact[yystate];
- if (yyn == 0)
- goto yyerrlab;
- goto yyreduce;
-
-
-/*-----------------------------.
-| yyreduce -- Do a reduction. |
-`-----------------------------*/
-yyreduce:
- /* yyn is the number of a rule to reduce with. */
- yylen = yyr2[yyn];
-
- /* If YYLEN is nonzero, implement the default value of the action:
- '$$ = $1'.
-
- Otherwise, the following line sets YYVAL to garbage.
- This behavior is undocumented and Bison
- users should not rely upon it. Assigning to YYVAL
- unconditionally makes the parser a bit smaller, and it avoids a
- GCC warning that YYVAL may be used uninitialized. */
- yyval = yyvsp[1-yylen];
-
- /* Default location. */
- YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
- YY_REDUCE_PRINT (yyn);
- switch (yyn)
- {
- case 2:
-#line 332 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.texts) = new TextVector();
- (yyval.texts)->emplace_back((yyvsp[0].t_text).to_string());
- }
-#line 2460 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 3:
-#line 336 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.texts) = (yyvsp[-1].texts);
- (yyval.texts)->emplace_back((yyvsp[0].t_text).to_string());
- }
-#line 2469 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 4:
-#line 342 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.texts) = new TextVector(); }
-#line 2475 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 6:
-#line 347 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.string) = new std::string();
- RemoveEscapes((yyvsp[0].t_text).to_string_view(), std::back_inserter(*(yyval.string)));
- }
-#line 2484 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 7:
-#line 356 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.types) = new TypeVector(); }
-#line 2490 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 8:
-#line 357 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.types) = (yyvsp[-1].types);
- (yyval.types)->push_back((yyvsp[0].t_type));
- }
-#line 2499 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 9:
-#line 363 "src/wast-parser.y" /* yacc.c:1646 */
- {}
-#line 2505 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 10:
-#line 366 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.global) = new Global();
- (yyval.global)->type = (yyvsp[0].t_type);
- (yyval.global)->mutable_ = false;
- }
-#line 2515 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 11:
-#line 371 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.global) = new Global();
- (yyval.global)->type = (yyvsp[-1].t_type);
- (yyval.global)->mutable_ = true;
- }
-#line 2525 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 12:
-#line 379 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.func_sig) = (yyvsp[-1].func_sig); }
-#line 2531 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 14:
-#line 384 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.func_sig) = (yyvsp[0].func_sig);
- PrependAndDelete((yyval.func_sig)->param_types, (yyvsp[-2].types));
- }
-#line 2540 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 15:
-#line 388 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.func_sig) = (yyvsp[0].func_sig);
- (yyval.func_sig)->param_types.insert((yyval.func_sig)->param_types.begin(), (yyvsp[-2].t_type));
- // Ignore bind_var.
- delete (yyvsp[-3].string);
- }
-#line 2551 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 16:
-#line 397 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.func_sig) = new FuncSignature(); }
-#line 2557 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 17:
-#line 398 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.func_sig) = (yyvsp[0].func_sig);
- PrependAndDelete((yyval.func_sig)->result_types, (yyvsp[-2].types));
- }
-#line 2566 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 18:
-#line 405 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.table) = new Table();
- (yyval.table)->elem_limits = (yyvsp[-1].limits);
- }
-#line 2575 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 19:
-#line 411 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.memory) = new Memory();
- (yyval.memory)->page_limits = (yyvsp[0].limits);
- }
-#line 2584 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 20:
-#line 417 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.limits).has_max = false;
- (yyval.limits).initial = (yyvsp[0].u64);
- (yyval.limits).max = 0;
- }
-#line 2594 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 21:
-#line 422 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.limits).has_max = true;
- (yyval.limits).initial = (yyvsp[-1].u64);
- (yyval.limits).max = (yyvsp[0].u64);
- }
-#line 2604 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 22:
-#line 429 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.var) = (yyvsp[-1].var); }
-#line 2610 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 23:
-#line 435 "src/wast-parser.y" /* yacc.c:1646 */
- {
- string_view sv = (yyvsp[0].t_literal).text.to_string_view();
- if (Failed(ParseUint64(sv.begin(), sv.end(), &(yyval.u64)))) {
- WastParserError(&(yylsp[0]), lexer, parser, "invalid int \"" PRIstringview "\"",
- WABT_PRINTF_STRING_VIEW_ARG(sv));
- }
- }
-#line 2622 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 24:
-#line 445 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.literal) = new Literal((yyvsp[0].t_literal));
- }
-#line 2630 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 25:
-#line 448 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.literal) = new Literal((yyvsp[0].t_literal));
- }
-#line 2638 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 26:
-#line 451 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.literal) = new Literal((yyvsp[0].t_literal));
- }
-#line 2646 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 27:
-#line 457 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.var) = new Var((yyvsp[0].u64), (yylsp[0]));
- }
-#line 2654 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 28:
-#line 460 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.var) = new Var((yyvsp[0].t_text).to_string_view(), (yylsp[0]));
- }
-#line 2662 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 29:
-#line 465 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.vars) = new VarVector(); }
-#line 2668 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 30:
-#line 466 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.vars) = (yyvsp[-1].vars);
- (yyval.vars)->emplace_back(MoveAndDelete((yyvsp[0].var)));
- }
-#line 2677 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 31:
-#line 472 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.string) = new std::string(); }
-#line 2683 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 33:
-#line 476 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.string) = new std::string((yyvsp[0].t_text).to_string()); }
-#line 2689 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 34:
-#line 480 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.string) = new std::string(); }
-#line 2695 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 36:
-#line 485 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.u64) = 0; }
-#line 2701 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 37:
-#line 486 "src/wast-parser.y" /* yacc.c:1646 */
- {
- uint64_t offset64;
- string_view sv = (yyvsp[0].t_text).to_string_view();
- if (Failed(ParseInt64(sv.begin(), sv.end(), &offset64,
- ParseIntType::SignedAndUnsigned))) {
- WastParserError(&(yylsp[0]), lexer, parser,
- "invalid offset \"" PRIstringview "\"",
- WABT_PRINTF_STRING_VIEW_ARG(sv));
- }
- if (offset64 > UINT32_MAX) {
- WastParserError(&(yylsp[0]), lexer, parser,
- "offset must be less than or equal to 0xffffffff");
- }
- (yyval.u64) = static_cast<uint32_t>(offset64);
- }
-#line 2721 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 38:
-#line 503 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.u32) = USE_NATURAL_ALIGNMENT; }
-#line 2727 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 39:
-#line 504 "src/wast-parser.y" /* yacc.c:1646 */
- {
- string_view sv = (yyvsp[0].t_text).to_string_view();
- if (Failed(ParseInt32(sv.begin(), sv.end(), &(yyval.u32),
- ParseIntType::UnsignedOnly))) {
- WastParserError(&(yylsp[0]), lexer, parser,
- "invalid alignment \"" PRIstringview "\"",
- WABT_PRINTF_STRING_VIEW_ARG(sv));
- }
-
- if ((yyval.u32) != WABT_USE_NATURAL_ALIGNMENT && !IsPowerOfTwo((yyval.u32))) {
- WastParserError(&(yylsp[0]), lexer, parser, "alignment must be power-of-two");
- }
- }
-#line 2745 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 40:
-#line 520 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr_list) = new ExprList((yyvsp[0].expr));
- (yyval.expr_list)->back().loc = (yylsp[0]);
- }
-#line 2754 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 41:
-#line 524 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr_list) = new ExprList((yyvsp[0].expr));
- (yyval.expr_list)->back().loc = (yylsp[0]);
- }
-#line 2763 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 43:
-#line 532 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new UnreachableExpr();
- }
-#line 2771 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 44:
-#line 535 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new NopExpr();
- }
-#line 2779 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 45:
-#line 538 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new DropExpr();
- }
-#line 2787 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 46:
-#line 541 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new SelectExpr();
- }
-#line 2795 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 47:
-#line 544 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new BrExpr(MoveAndDelete((yyvsp[0].var)));
- }
-#line 2803 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 48:
-#line 547 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new BrIfExpr(MoveAndDelete((yyvsp[0].var)));
- }
-#line 2811 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 49:
-#line 550 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new BrTableExpr((yyvsp[-1].vars), MoveAndDelete((yyvsp[0].var)));
- }
-#line 2819 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 50:
-#line 553 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new ReturnExpr();
- }
-#line 2827 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 51:
-#line 556 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new CallExpr(MoveAndDelete((yyvsp[0].var)));
- }
-#line 2835 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 52:
-#line 559 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new CallIndirectExpr(MoveAndDelete((yyvsp[0].var)));
- }
-#line 2843 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 53:
-#line 562 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new GetLocalExpr(MoveAndDelete((yyvsp[0].var)));
- }
-#line 2851 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 54:
-#line 565 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new SetLocalExpr(MoveAndDelete((yyvsp[0].var)));
- }
-#line 2859 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 55:
-#line 568 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new TeeLocalExpr(MoveAndDelete((yyvsp[0].var)));
- }
-#line 2867 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 56:
-#line 571 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new GetGlobalExpr(MoveAndDelete((yyvsp[0].var)));
- }
-#line 2875 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 57:
-#line 574 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new SetGlobalExpr(MoveAndDelete((yyvsp[0].var)));
- }
-#line 2883 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 58:
-#line 577 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new LoadExpr((yyvsp[-2].t_opcode), (yyvsp[0].u32), (yyvsp[-1].u64));
- }
-#line 2891 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 59:
-#line 580 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new StoreExpr((yyvsp[-2].t_opcode), (yyvsp[0].u32), (yyvsp[-1].u64));
- }
-#line 2899 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 60:
-#line 583 "src/wast-parser.y" /* yacc.c:1646 */
- {
- Const const_;
- const_.loc = (yylsp[-1]);
- auto literal = MoveAndDelete((yyvsp[0].literal));
- if (Failed(ParseConst((yyvsp[-1].t_type), literal, &const_))) {
- WastParserError(&(yylsp[0]), lexer, parser, "invalid literal \"%s\"",
- literal.text.c_str());
- }
- (yyval.expr) = new ConstExpr(const_);
- }
-#line 2914 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 61:
-#line 593 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new UnaryExpr((yyvsp[0].t_opcode));
- }
-#line 2922 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 62:
-#line 596 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new BinaryExpr((yyvsp[0].t_opcode));
- }
-#line 2930 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 63:
-#line 599 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new CompareExpr((yyvsp[0].t_opcode));
- }
-#line 2938 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 64:
-#line 602 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new ConvertExpr((yyvsp[0].t_opcode));
- }
-#line 2946 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 65:
-#line 605 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new CurrentMemoryExpr();
- }
-#line 2954 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 66:
-#line 608 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new GrowMemoryExpr();
- }
-#line 2962 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 67:
-#line 611 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new ThrowExpr(MoveAndDelete((yyvsp[0].var)));
- }
-#line 2970 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 68:
-#line 614 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr) = new RethrowExpr(MoveAndDelete((yyvsp[0].var)));
- }
-#line 2978 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 69:
-#line 620 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto expr = new BlockExpr((yyvsp[-2].block));
- expr->block->label = MoveAndDelete((yyvsp[-3].string));
- CHECK_END_LABEL((yylsp[0]), expr->block->label, (yyvsp[0].string));
- (yyval.expr) = expr;
- }
-#line 2989 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 70:
-#line 626 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto expr = new LoopExpr((yyvsp[-2].block));
- expr->block->label = MoveAndDelete((yyvsp[-3].string));
- CHECK_END_LABEL((yylsp[0]), expr->block->label, (yyvsp[0].string));
- (yyval.expr) = expr;
- }
-#line 3000 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 71:
-#line 632 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto expr = new IfExpr((yyvsp[-2].block));
- expr->true_->label = MoveAndDelete((yyvsp[-3].string));
- CHECK_END_LABEL((yylsp[0]), expr->true_->label, (yyvsp[0].string));
- (yyval.expr) = expr;
- }
-#line 3011 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 72:
-#line 638 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto expr = new IfExpr((yyvsp[-5].block), MoveAndDelete((yyvsp[-2].expr_list)));
- expr->true_->label = MoveAndDelete((yyvsp[-6].string));
- CHECK_END_LABEL((yylsp[-3]), expr->true_->label, (yyvsp[-3].string));
- CHECK_END_LABEL((yylsp[0]), expr->true_->label, (yyvsp[0].string));
- (yyval.expr) = expr;
- }
-#line 3023 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 73:
-#line 645 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyvsp[-3].block)->label = MoveAndDelete((yyvsp[-4].string));
- (yyval.expr) = (yyvsp[-2].try_expr);
- cast<TryExpr>((yyval.expr))->block = (yyvsp[-3].block);
- CHECK_END_LABEL((yylsp[0]), (yyvsp[-3].block)->label, (yyvsp[0].string));
- }
-#line 3034 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 74:
-#line 654 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.types) = (yyvsp[-1].types); }
-#line 3040 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 75:
-#line 657 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.block) = (yyvsp[0].block);
- AppendAndDelete((yyval.block)->sig, (yyvsp[-1].types));
- }
-#line 3049 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 76:
-#line 661 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.block) = new Block(MoveAndDelete((yyvsp[0].expr_list)));
- }
-#line 3057 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 77:
-#line 667 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.catch_) = new Catch(MoveAndDelete((yyvsp[-1].var)), MoveAndDelete((yyvsp[0].expr_list)));
- (yyval.catch_)->loc = (yylsp[-2]);
- }
-#line 3066 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 78:
-#line 673 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.catch_) = new Catch(MoveAndDelete((yyvsp[0].expr_list)));
- (yyval.catch_)->loc = (yylsp[-1]);
- }
-#line 3075 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 81:
-#line 685 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto expr = new TryExpr();
- expr->catches.push_back((yyvsp[0].catch_));
- (yyval.try_expr) = expr;
- }
-#line 3085 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 82:
-#line 690 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.try_expr) = (yyvsp[-1].try_expr);
- cast<TryExpr>((yyval.try_expr))->catches.push_back((yyvsp[0].catch_));
- }
-#line 3094 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 83:
-#line 697 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.expr_list) = (yyvsp[-1].expr_list); }
-#line 3100 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 84:
-#line 701 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr_list) = (yyvsp[0].expr_list);
- (yyval.expr_list)->push_back((yyvsp[-1].expr));
- (yyvsp[-1].expr)->loc = (yylsp[-1]);
- }
-#line 3110 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 85:
-#line 706 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto expr = new BlockExpr((yyvsp[0].block));
- expr->block->label = MoveAndDelete((yyvsp[-1].string));
- expr->loc = (yylsp[-2]);
- (yyval.expr_list) = new ExprList(expr);
- }
-#line 3121 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 86:
-#line 712 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto expr = new LoopExpr((yyvsp[0].block));
- expr->block->label = MoveAndDelete((yyvsp[-1].string));
- expr->loc = (yylsp[-2]);
- (yyval.expr_list) = new ExprList(expr);
- }
-#line 3132 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 87:
-#line 718 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr_list) = (yyvsp[0].expr_list);
- IfExpr* if_ = cast<IfExpr>(&(yyvsp[0].expr_list)->back());
- if_->true_->label = MoveAndDelete((yyvsp[-1].string));
- }
-#line 3142 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 88:
-#line 723 "src/wast-parser.y" /* yacc.c:1646 */
- {
- Block* block = (yyvsp[0].try_expr)->block;
- block->label = MoveAndDelete((yyvsp[-1].string));
- (yyvsp[0].try_expr)->loc = (yylsp[-2]);
- (yyval.expr_list) = new ExprList((yyvsp[0].try_expr));
- }
-#line 3153 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 89:
-#line 732 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.try_expr) = (yyvsp[0].try_expr);
- Block* block = (yyval.try_expr)->block;
- AppendAndDelete(block->sig, (yyvsp[-1].types));
- }
-#line 3163 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 90:
-#line 737 "src/wast-parser.y" /* yacc.c:1646 */
- {
- Block* block = new Block();
- block->exprs = MoveAndDelete((yyvsp[-1].expr_list));
- (yyval.try_expr) = (yyvsp[0].try_expr);
- (yyval.try_expr)->block = block;
- }
-#line 3174 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 91:
-#line 746 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.catch_) = (yyvsp[-1].catch_);
- }
-#line 3182 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 92:
-#line 749 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.catch_) = (yyvsp[-1].catch_);
- }
-#line 3190 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 93:
-#line 755 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto expr = new TryExpr();
- expr->catches.push_back((yyvsp[0].catch_));
- (yyval.try_expr) = expr;
- }
-#line 3200 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 94:
-#line 760 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.try_expr) = (yyvsp[-1].try_expr);
- cast<TryExpr>((yyval.try_expr))->catches.push_back((yyvsp[0].catch_));
- }
-#line 3209 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 95:
-#line 768 "src/wast-parser.y" /* yacc.c:1646 */
- {
- IfExpr* if_ = cast<IfExpr>(&(yyvsp[0].expr_list)->back());
- (yyval.expr_list) = (yyvsp[0].expr_list);
- Block* true_ = if_->true_;
- AppendAndDelete(true_->sig, (yyvsp[-1].types));
- }
-#line 3220 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 97:
-#line 777 "src/wast-parser.y" /* yacc.c:1646 */
- {
- Expr* expr = new IfExpr(new Block(MoveAndDelete((yyvsp[-5].expr_list))), MoveAndDelete((yyvsp[-1].expr_list)));
- expr->loc = (yylsp[-7]);
- (yyval.expr_list) = new ExprList(expr);
- }
-#line 3230 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 98:
-#line 782 "src/wast-parser.y" /* yacc.c:1646 */
- {
- Expr* expr = new IfExpr(new Block(MoveAndDelete((yyvsp[-1].expr_list))));
- expr->loc = (yylsp[-3]);
- (yyval.expr_list) = new ExprList(expr);
- }
-#line 3240 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 99:
-#line 787 "src/wast-parser.y" /* yacc.c:1646 */
- {
- Expr* expr = new IfExpr(new Block(MoveAndDelete((yyvsp[-5].expr_list))), MoveAndDelete((yyvsp[-1].expr_list)));
- expr->loc = (yylsp[-8]);
- (yyval.expr_list) = (yyvsp[-8].expr_list);
- (yyval.expr_list)->push_back(expr);
- }
-#line 3251 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 100:
-#line 793 "src/wast-parser.y" /* yacc.c:1646 */
- {
- Expr* expr = new IfExpr(new Block(MoveAndDelete((yyvsp[-1].expr_list))));
- expr->loc = (yylsp[-4]);
- (yyval.expr_list) = (yyvsp[-4].expr_list);
- (yyval.expr_list)->push_back(expr);
- }
-#line 3262 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 101:
-#line 799 "src/wast-parser.y" /* yacc.c:1646 */
- {
- Expr* expr = new IfExpr(new Block(MoveAndDelete((yyvsp[-1].expr_list))), MoveAndDelete((yyvsp[0].expr_list)));
- expr->loc = (yylsp[-2]);
- (yyval.expr_list) = (yyvsp[-2].expr_list);
- (yyval.expr_list)->push_back(expr);
- }
-#line 3273 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 102:
-#line 805 "src/wast-parser.y" /* yacc.c:1646 */
- {
- Expr* expr = new IfExpr(new Block(MoveAndDelete((yyvsp[0].expr_list))));
- expr->loc = (yylsp[-1]);
- (yyval.expr_list) = (yyvsp[-1].expr_list);
- (yyval.expr_list)->push_back(expr);
- }
-#line 3284 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 103:
-#line 814 "src/wast-parser.y" /* yacc.c:1646 */
- {
- CHECK_ALLOW_EXCEPTIONS(&(yylsp[0]), "rethrow");
- }
-#line 3292 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 104:
-#line 819 "src/wast-parser.y" /* yacc.c:1646 */
- {
- CHECK_ALLOW_EXCEPTIONS(&(yylsp[0]), "throw");
- }
-#line 3300 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 105:
-#line 825 "src/wast-parser.y" /* yacc.c:1646 */
- {
- CHECK_ALLOW_EXCEPTIONS(&(yylsp[0]), "try");
- }
-#line 3308 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 106:
-#line 831 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.expr_list) = new ExprList(); }
-#line 3314 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 107:
-#line 832 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr_list) = (yyvsp[0].expr_list);
- (yyval.expr_list)->splice((yyval.expr_list)->begin(), MoveAndDelete((yyvsp[-1].expr_list)));
- }
-#line 3323 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 108:
-#line 838 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.expr_list) = new ExprList(); }
-#line 3329 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 109:
-#line 839 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr_list) = (yyvsp[0].expr_list);
- (yyval.expr_list)->splice((yyval.expr_list)->begin(), MoveAndDelete((yyvsp[-1].expr_list)));
- }
-#line 3338 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 111:
-#line 850 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.exception) = new Exception(MoveAndDelete((yyvsp[-2].string)), MoveAndDelete((yyvsp[-1].types)));
- }
-#line 3346 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 112:
-#line 855 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.module_field) = new ExceptionModuleField((yyvsp[0].exception));
- }
-#line 3354 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 113:
-#line 862 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.module_fields) = (yyvsp[-1].module_fields);
- ModuleField* main_field = &(yyval.module_fields)->front();
- main_field->loc = (yylsp[-3]);
- if (auto func_field = dyn_cast<FuncModuleField>(main_field)) {
- func_field->func->name = MoveAndDelete((yyvsp[-2].string));
- } else {
- cast<ImportModuleField>(main_field)->import->func->name =
- MoveAndDelete((yyvsp[-2].string));
- }
- }
-#line 3370 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 114:
-#line 876 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto field = new FuncModuleField((yyvsp[0].func));
- field->func->decl.has_func_type = true;
- field->func->decl.type_var = MoveAndDelete((yyvsp[-1].var));
- (yyval.module_fields) = new ModuleFieldList(field);
- }
-#line 3381 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 115:
-#line 882 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.module_fields) = new ModuleFieldList(new FuncModuleField((yyvsp[0].func)));
- }
-#line 3389 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 116:
-#line 885 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto field = new ImportModuleField((yyvsp[-2].import), (yylsp[-2]));
- field->import->kind = ExternalKind::Func;
- field->import->func = (yyvsp[0].func);
- field->import->func->decl.has_func_type = true;
- field->import->func->decl.type_var = MoveAndDelete((yyvsp[-1].var));
- (yyval.module_fields) = new ModuleFieldList(field);
- }
-#line 3402 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 117:
-#line 893 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto field = new ImportModuleField((yyvsp[-1].import), (yylsp[-1]));
- field->import->kind = ExternalKind::Func;
- field->import->func = (yyvsp[0].func);
- (yyval.module_fields) = new ModuleFieldList(field);
- }
-#line 3413 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 118:
-#line 899 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto field = new ExportModuleField((yyvsp[-1].export_), (yylsp[-1]));
- field->export_->kind = ExternalKind::Func;
- (yyval.module_fields) = (yyvsp[0].module_fields);
- (yyval.module_fields)->push_back(field);
- }
-#line 3424 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 119:
-#line 908 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.func) = (yyvsp[0].func);
- ReverseBindings(&(yyval.func)->decl.sig.param_types, &(yyval.func)->param_bindings);
- }
-#line 3433 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 121:
-#line 916 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.func) = (yyvsp[0].func);
- PrependAndDelete((yyval.func)->decl.sig.param_types, (yyvsp[-2].types));
- }
-#line 3442 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 122:
-#line 920 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.func) = (yyvsp[0].func);
- (yyval.func)->param_bindings.emplace(MoveAndDelete((yyvsp[-3].string)),
- Binding((yylsp[-3]), (yyval.func)->decl.sig.param_types.size()));
- (yyval.func)->decl.sig.param_types.insert((yyval.func)->decl.sig.param_types.begin(), (yyvsp[-2].t_type));
- }
-#line 3453 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 123:
-#line 929 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.func) = new Func(); }
-#line 3459 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 124:
-#line 930 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.func) = (yyvsp[0].func);
- PrependAndDelete((yyval.func)->decl.sig.result_types, (yyvsp[-2].types));
- }
-#line 3468 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 125:
-#line 937 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.func) = (yyvsp[0].func);
- ReverseBindings(&(yyval.func)->decl.sig.param_types, &(yyval.func)->param_bindings);
- }
-#line 3477 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 127:
-#line 945 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.func) = (yyvsp[0].func);
- PrependAndDelete((yyval.func)->decl.sig.param_types, (yyvsp[-2].types));
- }
-#line 3486 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 128:
-#line 949 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.func) = (yyvsp[0].func);
- (yyval.func)->param_bindings.emplace(MoveAndDelete((yyvsp[-3].string)),
- Binding((yylsp[-3]), (yyval.func)->decl.sig.param_types.size()));
- (yyval.func)->decl.sig.param_types.insert((yyval.func)->decl.sig.param_types.begin(), (yyvsp[-2].t_type));
- }
-#line 3497 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 130:
-#line 959 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.func) = (yyvsp[0].func);
- PrependAndDelete((yyval.func)->decl.sig.result_types, (yyvsp[-2].types));
- }
-#line 3506 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 131:
-#line 966 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.func) = (yyvsp[0].func);
- ReverseBindings(&(yyval.func)->local_types, &(yyval.func)->local_bindings);
- }
-#line 3515 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 132:
-#line 973 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.func) = new Func();
- (yyval.func)->exprs = MoveAndDelete((yyvsp[0].expr_list));
- }
-#line 3524 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 133:
-#line 977 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.func) = (yyvsp[0].func);
- PrependAndDelete((yyval.func)->local_types, (yyvsp[-2].types));
- }
-#line 3533 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 134:
-#line 981 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.func) = (yyvsp[0].func);
- (yyval.func)->local_bindings.emplace(MoveAndDelete((yyvsp[-3].string)),
- Binding((yylsp[-3]), (yyval.func)->local_types.size()));
- (yyval.func)->local_types.insert((yyval.func)->local_types.begin(), (yyvsp[-2].t_type));
- }
-#line 3544 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 135:
-#line 992 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.expr_list) = (yyvsp[-1].expr_list);
- }
-#line 3552 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 137:
-#line 999 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto elem_segment = new ElemSegment();
- elem_segment->table_var = MoveAndDelete((yyvsp[-3].var));
- elem_segment->offset = MoveAndDelete((yyvsp[-2].expr_list));
- elem_segment->vars = MoveAndDelete((yyvsp[-1].vars));
- (yyval.module_field) = new ElemSegmentModuleField(elem_segment, (yylsp[-4]));
- }
-#line 3564 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 138:
-#line 1006 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto elem_segment = new ElemSegment();
- elem_segment->table_var = Var(0, (yylsp[-3]));
- elem_segment->offset = MoveAndDelete((yyvsp[-2].expr_list));
- elem_segment->vars = MoveAndDelete((yyvsp[-1].vars));
- (yyval.module_field) = new ElemSegmentModuleField(elem_segment, (yylsp[-3]));
- }
-#line 3576 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 139:
-#line 1016 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.module_fields) = (yyvsp[-1].module_fields);
- ModuleField* main_field = &(yyval.module_fields)->front();
- main_field->loc = (yylsp[-3]);
- if (auto table_field = dyn_cast<TableModuleField>(main_field)) {
- table_field->table->name = MoveAndDelete((yyvsp[-2].string));
- } else {
- cast<ImportModuleField>(main_field)->import->table->name =
- MoveAndDelete((yyvsp[-2].string));
- }
- }
-#line 3592 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 140:
-#line 1030 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.module_fields) = new ModuleFieldList(new TableModuleField((yyvsp[0].table)));
- }
-#line 3600 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 141:
-#line 1033 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto field = new ImportModuleField((yyvsp[-1].import));
- field->import->kind = ExternalKind::Table;
- field->import->table = (yyvsp[0].table);
- (yyval.module_fields) = new ModuleFieldList(field);
- }
-#line 3611 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 142:
-#line 1039 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto field = new ExportModuleField((yyvsp[-1].export_), (yylsp[-1]));
- field->export_->kind = ExternalKind::Table;
- (yyval.module_fields) = (yyvsp[0].module_fields);
- (yyval.module_fields)->push_back(field);
- }
-#line 3622 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 143:
-#line 1045 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto table = new Table();
- table->elem_limits.initial = (yyvsp[-1].vars)->size();
- table->elem_limits.max = (yyvsp[-1].vars)->size();
- table->elem_limits.has_max = true;
-
- auto elem_segment = new ElemSegment();
- elem_segment->table_var = Var(kInvalidIndex);
- elem_segment->offset.push_back(new ConstExpr(Const(Const::I32(), 0)));
- elem_segment->offset.back().loc = (yylsp[-2]);
- elem_segment->vars = MoveAndDelete((yyvsp[-1].vars));
-
- (yyval.module_fields) = new ModuleFieldList();
- (yyval.module_fields)->push_back(new TableModuleField(table));
- (yyval.module_fields)->push_back(new ElemSegmentModuleField(elem_segment, (yylsp[-2])));
- }
-#line 3643 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 144:
-#line 1064 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto data_segment = new DataSegment();
- data_segment->memory_var = MoveAndDelete((yyvsp[-3].var));
- data_segment->offset = MoveAndDelete((yyvsp[-2].expr_list));
- RemoveEscapes(MoveAndDelete((yyvsp[-1].texts)), std::back_inserter(data_segment->data));
- (yyval.module_field) = new DataSegmentModuleField(data_segment, (yylsp[-4]));
- }
-#line 3655 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 145:
-#line 1071 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto data_segment = new DataSegment();
- data_segment->memory_var = Var(0, (yylsp[-3]));
- data_segment->offset = MoveAndDelete((yyvsp[-2].expr_list));
- RemoveEscapes(MoveAndDelete((yyvsp[-1].texts)), std::back_inserter(data_segment->data));
- (yyval.module_field) = new DataSegmentModuleField(data_segment, (yylsp[-3]));
- }
-#line 3667 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 146:
-#line 1081 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.module_fields) = (yyvsp[-1].module_fields);
- ModuleField* main_field = &(yyval.module_fields)->front();
- main_field->loc = (yylsp[-3]);
- if (auto memory_field = dyn_cast<MemoryModuleField>(main_field)) {
- memory_field->memory->name = MoveAndDelete((yyvsp[-2].string));
- } else {
- cast<ImportModuleField>(main_field)->import->memory->name =
- MoveAndDelete((yyvsp[-2].string));
- }
- }
-#line 3683 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 147:
-#line 1095 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.module_fields) = new ModuleFieldList(new MemoryModuleField((yyvsp[0].memory)));
- }
-#line 3691 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 148:
-#line 1098 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto field = new ImportModuleField((yyvsp[-1].import));
- field->import->kind = ExternalKind::Memory;
- field->import->memory = (yyvsp[0].memory);
- (yyval.module_fields) = new ModuleFieldList(field);
- }
-#line 3702 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 149:
-#line 1104 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto field = new ExportModuleField((yyvsp[-1].export_), (yylsp[-1]));
- field->export_->kind = ExternalKind::Memory;
- (yyval.module_fields) = (yyvsp[0].module_fields);
- (yyval.module_fields)->push_back(field);
- }
-#line 3713 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 150:
-#line 1110 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto data_segment = new DataSegment();
- data_segment->memory_var = Var(kInvalidIndex);
- data_segment->offset.push_back(new ConstExpr(Const(Const::I32(), 0)));
- data_segment->offset.back().loc = (yylsp[-2]);
- RemoveEscapes(MoveAndDelete((yyvsp[-1].texts)), std::back_inserter(data_segment->data));
-
- uint32_t byte_size = WABT_ALIGN_UP_TO_PAGE(data_segment->data.size());
- uint32_t page_size = WABT_BYTES_TO_PAGES(byte_size);
-
- auto memory = new Memory();
- memory->page_limits.initial = page_size;
- memory->page_limits.max = page_size;
- memory->page_limits.has_max = true;
-
- (yyval.module_fields) = new ModuleFieldList();
- (yyval.module_fields)->push_back(new MemoryModuleField(memory));
- (yyval.module_fields)->push_back(new DataSegmentModuleField(data_segment, (yylsp[-2])));
- }
-#line 3737 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 151:
-#line 1132 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.module_fields) = (yyvsp[-1].module_fields);
- ModuleField* main_field = &(yyval.module_fields)->front();
- main_field->loc = (yylsp[-3]);
- if (auto global_field = dyn_cast<GlobalModuleField>(main_field)) {
- global_field->global->name = MoveAndDelete((yyvsp[-2].string));
- } else {
- cast<ImportModuleField>(main_field)->import->global->name =
- MoveAndDelete((yyvsp[-2].string));
- }
- }
-#line 3753 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 152:
-#line 1146 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto field = new GlobalModuleField((yyvsp[-1].global));
- field->global->init_expr = MoveAndDelete((yyvsp[0].expr_list));
- (yyval.module_fields) = new ModuleFieldList(field);
- }
-#line 3763 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 153:
-#line 1151 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto field = new ImportModuleField((yyvsp[-1].import));
- field->import->kind = ExternalKind::Global;
- field->import->global = (yyvsp[0].global);
- (yyval.module_fields) = new ModuleFieldList(field);
- }
-#line 3774 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 154:
-#line 1157 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto field = new ExportModuleField((yyvsp[-1].export_), (yylsp[-1]));
- field->export_->kind = ExternalKind::Global;
- (yyval.module_fields) = (yyvsp[0].module_fields);
- (yyval.module_fields)->push_back(field);
- }
-#line 3785 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 155:
-#line 1168 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.import) = new Import();
- (yyval.import)->kind = ExternalKind::Func;
- (yyval.import)->func = new Func();
- (yyval.import)->func->name = MoveAndDelete((yyvsp[-2].string));
- (yyval.import)->func->decl.has_func_type = true;
- (yyval.import)->func->decl.type_var = MoveAndDelete((yyvsp[-1].var));
- }
-#line 3798 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 156:
-#line 1176 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.import) = new Import();
- (yyval.import)->kind = ExternalKind::Func;
- (yyval.import)->func = new Func();
- (yyval.import)->func->name = MoveAndDelete((yyvsp[-2].string));
- (yyval.import)->func->decl.sig = MoveAndDelete((yyvsp[-1].func_sig));
- }
-#line 3810 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 157:
-#line 1183 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.import) = new Import();
- (yyval.import)->kind = ExternalKind::Table;
- (yyval.import)->table = (yyvsp[-1].table);
- (yyval.import)->table->name = MoveAndDelete((yyvsp[-2].string));
- }
-#line 3821 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 158:
-#line 1189 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.import) = new Import();
- (yyval.import)->kind = ExternalKind::Memory;
- (yyval.import)->memory = (yyvsp[-1].memory);
- (yyval.import)->memory->name = MoveAndDelete((yyvsp[-2].string));
- }
-#line 3832 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 159:
-#line 1195 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.import) = new Import();
- (yyval.import)->kind = ExternalKind::Global;
- (yyval.import)->global = (yyvsp[-1].global);
- (yyval.import)->global->name = MoveAndDelete((yyvsp[-2].string));
- }
-#line 3843 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 160:
-#line 1201 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.import) = new Import();
- (yyval.import)->kind = ExternalKind::Except;
- (yyval.import)->except = (yyvsp[0].exception);
- }
-#line 3853 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 161:
-#line 1209 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto field = new ImportModuleField((yyvsp[-1].import), (yylsp[-4]));
- field->import->module_name = MoveAndDelete((yyvsp[-3].string));
- field->import->field_name = MoveAndDelete((yyvsp[-2].string));
- (yyval.module_field) = field;
- }
-#line 3864 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 162:
-#line 1218 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.import) = new Import();
- (yyval.import)->module_name = MoveAndDelete((yyvsp[-2].string));
- (yyval.import)->field_name = MoveAndDelete((yyvsp[-1].string));
- }
-#line 3874 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 163:
-#line 1226 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.export_) = new Export();
- (yyval.export_)->kind = ExternalKind::Func;
- (yyval.export_)->var = MoveAndDelete((yyvsp[-1].var));
- }
-#line 3884 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 164:
-#line 1231 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.export_) = new Export();
- (yyval.export_)->kind = ExternalKind::Table;
- (yyval.export_)->var = MoveAndDelete((yyvsp[-1].var));
- }
-#line 3894 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 165:
-#line 1236 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.export_) = new Export();
- (yyval.export_)->kind = ExternalKind::Memory;
- (yyval.export_)->var = MoveAndDelete((yyvsp[-1].var));
- }
-#line 3904 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 166:
-#line 1241 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.export_) = new Export();
- (yyval.export_)->kind = ExternalKind::Global;
- (yyval.export_)->var = MoveAndDelete((yyvsp[-1].var));
- }
-#line 3914 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 167:
-#line 1246 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.export_) = new Export();
- (yyval.export_)->kind = ExternalKind::Except;
- (yyval.export_)->var = MoveAndDelete((yyvsp[-1].var));
- }
-#line 3924 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 168:
-#line 1253 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto field = new ExportModuleField((yyvsp[-1].export_), (yylsp[-3]));
- field->export_->name = MoveAndDelete((yyvsp[-2].string));
- (yyval.module_field) = field;
- }
-#line 3934 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 169:
-#line 1261 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.export_) = new Export();
- (yyval.export_)->name = MoveAndDelete((yyvsp[-1].string));
- }
-#line 3943 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 170:
-#line 1271 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto func_type = new FuncType();
- func_type->sig = MoveAndDelete((yyvsp[-1].func_sig));
- (yyval.module_field) = new FuncTypeModuleField(func_type, (yylsp[-2]));
- }
-#line 3953 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 171:
-#line 1276 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto func_type = new FuncType();
- func_type->name = MoveAndDelete((yyvsp[-2].string));
- func_type->sig = MoveAndDelete((yyvsp[-1].func_sig));
- (yyval.module_field) = new FuncTypeModuleField(func_type, (yylsp[-3]));
- }
-#line 3964 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 172:
-#line 1285 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.module_field) = new StartModuleField(MoveAndDelete((yyvsp[-1].var)), (yylsp[-2]));
- }
-#line 3972 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 173:
-#line 1291 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.module_fields) = new ModuleFieldList((yyvsp[0].module_field)); }
-#line 3978 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 178:
-#line 1296 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.module_fields) = new ModuleFieldList((yyvsp[0].module_field)); }
-#line 3984 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 179:
-#line 1297 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.module_fields) = new ModuleFieldList((yyvsp[0].module_field)); }
-#line 3990 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 180:
-#line 1298 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.module_fields) = new ModuleFieldList((yyvsp[0].module_field)); }
-#line 3996 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 181:
-#line 1299 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.module_fields) = new ModuleFieldList((yyvsp[0].module_field)); }
-#line 4002 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 182:
-#line 1300 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.module_fields) = new ModuleFieldList((yyvsp[0].module_field)); }
-#line 4008 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 183:
-#line 1301 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.module_fields) = new ModuleFieldList((yyvsp[0].module_field)); }
-#line 4014 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 184:
-#line 1305 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.module) = new Module(); }
-#line 4020 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 186:
-#line 1310 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.module) = new Module();
- CheckImportOrdering(&(yylsp[0]), lexer, parser, (yyval.module), *(yyvsp[0].module_fields));
- AppendModuleFields((yyval.module), MoveAndDelete((yyvsp[0].module_fields)));
- }
-#line 4030 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 187:
-#line 1315 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.module) = (yyvsp[-1].module);
- CheckImportOrdering(&(yylsp[0]), lexer, parser, (yyval.module), *(yyvsp[0].module_fields));
- AppendModuleFields((yyval.module), MoveAndDelete((yyvsp[0].module_fields)));
- }
-#line 4040 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 188:
-#line 1323 "src/wast-parser.y" /* yacc.c:1646 */
- {
- if ((yyvsp[0].script_module)->type == ScriptModule::Type::Text) {
- (yyval.module) = (yyvsp[0].script_module)->text;
- (yyvsp[0].script_module)->text = nullptr;
- } else {
- assert((yyvsp[0].script_module)->type == ScriptModule::Type::Binary);
- (yyval.module) = new Module();
- ReadBinaryOptions options;
- BinaryErrorHandlerModule error_handler(&(yyvsp[0].script_module)->binary.loc, lexer, parser);
- const char* filename = "<text>";
- ReadBinaryIr(filename, (yyvsp[0].script_module)->binary.data.data(), (yyvsp[0].script_module)->binary.data.size(),
- &options, &error_handler, (yyval.module));
- (yyval.module)->name = (yyvsp[0].script_module)->binary.name;
- (yyval.module)->loc = (yyvsp[0].script_module)->binary.loc;
- }
- delete (yyvsp[0].script_module);
- }
-#line 4062 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 189:
-#line 1343 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.module) = (yyvsp[0].module);
- ResolveFuncTypes((yyval.module));
- }
-#line 4071 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 190:
-#line 1353 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.var) = new Var(kInvalidIndex);
- }
-#line 4079 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 191:
-#line 1356 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.var) = new Var((yyvsp[0].t_text).to_string_view(), (yylsp[0]));
- }
-#line 4087 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 192:
-#line 1362 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.script_module) = new ScriptModule(ScriptModule::Type::Text);
- auto module = (yyvsp[-1].module);
- (yyval.script_module)->text = module;
- (yyval.script_module)->text->name = MoveAndDelete((yyvsp[-2].string));
- (yyval.script_module)->text->loc = (yylsp[-3]);
- ResolveFuncTypes(module);
- }
-#line 4100 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 193:
-#line 1370 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.script_module) = new ScriptModule(ScriptModule::Type::Binary);
- (yyval.script_module)->binary.name = MoveAndDelete((yyvsp[-3].string));
- (yyval.script_module)->binary.loc = (yylsp[-4]);
- RemoveEscapes(MoveAndDelete((yyvsp[-1].texts)), std::back_inserter((yyval.script_module)->binary.data));
- }
-#line 4111 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 194:
-#line 1376 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.script_module) = new ScriptModule(ScriptModule::Type::Quoted);
- (yyval.script_module)->quoted.name = MoveAndDelete((yyvsp[-3].string));
- (yyval.script_module)->quoted.loc = (yylsp[-4]);
- RemoveEscapes(MoveAndDelete((yyvsp[-1].texts)), std::back_inserter((yyval.script_module)->quoted.data));
- }
-#line 4122 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 195:
-#line 1385 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.action) = new Action();
- (yyval.action)->loc = (yylsp[-4]);
- (yyval.action)->module_var = MoveAndDelete((yyvsp[-3].var));
- (yyval.action)->type = ActionType::Invoke;
- (yyval.action)->name = MoveAndDelete((yyvsp[-2].string));
- (yyval.action)->invoke = new ActionInvoke();
- (yyval.action)->invoke->args = MoveAndDelete((yyvsp[-1].consts));
- }
-#line 4136 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 196:
-#line 1394 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.action) = new Action();
- (yyval.action)->loc = (yylsp[-3]);
- (yyval.action)->module_var = MoveAndDelete((yyvsp[-2].var));
- (yyval.action)->type = ActionType::Get;
- (yyval.action)->name = MoveAndDelete((yyvsp[-1].string));
- }
-#line 4148 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 197:
-#line 1404 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.command) = new AssertMalformedCommand((yyvsp[-2].script_module), MoveAndDelete((yyvsp[-1].string)));
- }
-#line 4156 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 198:
-#line 1407 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.command) = new AssertInvalidCommand((yyvsp[-2].script_module), MoveAndDelete((yyvsp[-1].string)));
- }
-#line 4164 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 199:
-#line 1410 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.command) = new AssertUnlinkableCommand((yyvsp[-2].script_module), MoveAndDelete((yyvsp[-1].string)));
- }
-#line 4172 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 200:
-#line 1413 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.command) = new AssertUninstantiableCommand((yyvsp[-2].script_module), MoveAndDelete((yyvsp[-1].string)));
- }
-#line 4180 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 201:
-#line 1416 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.command) = new AssertReturnCommand((yyvsp[-2].action), (yyvsp[-1].consts));
- }
-#line 4188 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 202:
-#line 1419 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.command) = new AssertReturnCanonicalNanCommand((yyvsp[-1].action));
- }
-#line 4196 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 203:
-#line 1422 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.command) = new AssertReturnArithmeticNanCommand((yyvsp[-1].action));
- }
-#line 4204 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 204:
-#line 1425 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.command) = new AssertTrapCommand((yyvsp[-2].action), MoveAndDelete((yyvsp[-1].string)));
- }
-#line 4212 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 205:
-#line 1428 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.command) = new AssertExhaustionCommand((yyvsp[-2].action), MoveAndDelete((yyvsp[-1].string)));
- }
-#line 4220 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 206:
-#line 1434 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.command) = new ActionCommand((yyvsp[0].action));
- }
-#line 4228 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 208:
-#line 1438 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.command) = new ModuleCommand((yyvsp[0].module));
- }
-#line 4236 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 209:
-#line 1441 "src/wast-parser.y" /* yacc.c:1646 */
- {
- auto* command = new RegisterCommand(MoveAndDelete((yyvsp[-2].string)), MoveAndDelete((yyvsp[-1].var)));
- command->var.loc = (yylsp[-1]);
- (yyval.command) = command;
- }
-#line 4246 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 210:
-#line 1448 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.commands) = new CommandPtrVector();
- (yyval.commands)->emplace_back((yyvsp[0].command));
- }
-#line 4255 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 211:
-#line 1452 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.commands) = (yyvsp[-1].commands);
- (yyval.commands)->emplace_back((yyvsp[0].command));
- }
-#line 4264 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 212:
-#line 1459 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.const_).loc = (yylsp[-2]);
- auto literal = MoveAndDelete((yyvsp[-1].literal));
- if (Failed(ParseConst((yyvsp[-2].t_type), literal, &(yyval.const_)))) {
- WastParserError(&(yylsp[-1]), lexer, parser, "invalid literal \"%s\"",
- literal.text.c_str());
- }
- }
-#line 4277 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 213:
-#line 1469 "src/wast-parser.y" /* yacc.c:1646 */
- { (yyval.consts) = new ConstVector(); }
-#line 4283 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 214:
-#line 1470 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.consts) = (yyvsp[-1].consts);
- (yyval.consts)->push_back((yyvsp[0].const_));
- }
-#line 4292 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 215:
-#line 1477 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.script) = new Script();
- }
-#line 4300 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 216:
-#line 1480 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.script) = new Script();
- (yyval.script)->commands = MoveAndDelete((yyvsp[0].commands));
-
- int last_module_index = -1;
- for (size_t i = 0; i < (yyval.script)->commands.size(); ++i) {
- Command* command = (yyval.script)->commands[i].get();
- Var* module_var = nullptr;
- switch (command->type) {
- case CommandType::Module: {
- last_module_index = i;
-
- // Wire up module name bindings.
- Module* module = cast<ModuleCommand>(command)->module;
- if (module->name.empty())
- continue;
-
- (yyval.script)->module_bindings.emplace(module->name, Binding(module->loc, i));
- break;
- }
-
- case CommandType::AssertReturn:
- module_var =
- &cast<AssertReturnCommand>(command)->action->module_var;
- goto has_module_var;
- case CommandType::AssertReturnCanonicalNan:
- module_var = &cast<AssertReturnCanonicalNanCommand>(command)
- ->action->module_var;
- goto has_module_var;
- case CommandType::AssertReturnArithmeticNan:
- module_var = &cast<AssertReturnArithmeticNanCommand>(command)
- ->action->module_var;
- goto has_module_var;
- case CommandType::AssertTrap:
- module_var = &cast<AssertTrapCommand>(command)->action->module_var;
- goto has_module_var;
- case CommandType::AssertExhaustion:
- module_var =
- &cast<AssertExhaustionCommand>(command)->action->module_var;
- goto has_module_var;
- case CommandType::Action:
- module_var = &cast<ActionCommand>(command)->action->module_var;
- goto has_module_var;
- case CommandType::Register:
- module_var = &cast<RegisterCommand>(command)->var;
- goto has_module_var;
-
- has_module_var: {
- // Resolve actions with an invalid index to use the preceding
- // module.
- if (module_var->is_index() &&
- module_var->index() == kInvalidIndex) {
- module_var->set_index(last_module_index);
- }
- break;
- }
-
- default:
- break;
- }
- }
- }
-#line 4367 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 217:
-#line 1542 "src/wast-parser.y" /* yacc.c:1646 */
- {
- (yyval.script) = new Script();
- (yyval.script)->commands.emplace_back(new ModuleCommand((yyvsp[0].module)));
- }
-#line 4376 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
- case 218:
-#line 1551 "src/wast-parser.y" /* yacc.c:1646 */
- { parser->script = (yyvsp[0].script); }
-#line 4382 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- break;
-
-
-#line 4386 "src/prebuilt/wast-parser-gen.cc" /* yacc.c:1646 */
- default: break;
- }
- /* User semantic actions sometimes alter yychar, and that requires
- that yytoken be updated with the new translation. We take the
- approach of translating immediately before every use of yytoken.
- One alternative is translating here after every semantic action,
- but that translation would be missed if the semantic action invokes
- YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
- if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
- incorrect destructor might then be invoked immediately. In the
- case of YYERROR or YYBACKUP, subsequent parser actions might lead
- to an incorrect destructor call or verbose syntax error message
- before the lookahead is translated. */
- YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
-
- YYPOPSTACK (yylen);
- yylen = 0;
- YY_STACK_PRINT (yyss, yyssp);
-
- *++yyvsp = yyval;
- *++yylsp = yyloc;
-
- /* Now 'shift' the result of the reduction. Determine what state
- that goes to, based on the state we popped back to and the rule
- number reduced by. */
-
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
- if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTOKENS];
-
- goto yynewstate;
-
-
-/*--------------------------------------.
-| yyerrlab -- here on detecting error. |
-`--------------------------------------*/
-yyerrlab:
- /* Make sure we have latest lookahead translation. See comments at
- user semantic actions for why this is necessary. */
- yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
-
- /* If not already recovering from an error, report this error. */
- if (!yyerrstatus)
- {
- ++yynerrs;
-#if ! YYERROR_VERBOSE
- yyerror (&yylloc, lexer, parser, YY_("syntax error"));
-#else
-# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
- yyssp, yytoken)
- {
- char const *yymsgp = YY_("syntax error");
- int yysyntax_error_status;
- yysyntax_error_status = YYSYNTAX_ERROR;
- if (yysyntax_error_status == 0)
- yymsgp = yymsg;
- else if (yysyntax_error_status == 1)
- {
- if (yymsg != yymsgbuf)
- YYSTACK_FREE (yymsg);
- yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
- if (!yymsg)
- {
- yymsg = yymsgbuf;
- yymsg_alloc = sizeof yymsgbuf;
- yysyntax_error_status = 2;
- }
- else
- {
- yysyntax_error_status = YYSYNTAX_ERROR;
- yymsgp = yymsg;
- }
- }
- yyerror (&yylloc, lexer, parser, yymsgp);
- if (yysyntax_error_status == 2)
- goto yyexhaustedlab;
- }
-# undef YYSYNTAX_ERROR
-#endif
- }
-
- yyerror_range[1] = yylloc;
-
- if (yyerrstatus == 3)
- {
- /* If just tried and failed to reuse lookahead token after an
- error, discard it. */
-
- if (yychar <= YYEOF)
- {
- /* Return failure if at end of input. */
- if (yychar == YYEOF)
- YYABORT;
- }
- else
- {
- yydestruct ("Error: discarding",
- yytoken, &yylval, &yylloc, lexer, parser);
- yychar = YYEMPTY;
- }
- }
-
- /* Else will try to reuse lookahead token after shifting the error
- token. */
- goto yyerrlab1;
-
-
-/*---------------------------------------------------.
-| yyerrorlab -- error raised explicitly by YYERROR. |
-`---------------------------------------------------*/
-yyerrorlab:
-
- /* Pacify compilers like GCC when the user code never invokes
- YYERROR and the label yyerrorlab therefore never appears in user
- code. */
- if (/*CONSTCOND*/ 0)
- goto yyerrorlab;
-
- yyerror_range[1] = yylsp[1-yylen];
- /* Do not reclaim the symbols of the rule whose action triggered
- this YYERROR. */
- YYPOPSTACK (yylen);
- yylen = 0;
- YY_STACK_PRINT (yyss, yyssp);
- yystate = *yyssp;
- goto yyerrlab1;
-
-
-/*-------------------------------------------------------------.
-| yyerrlab1 -- common code for both syntax error and YYERROR. |
-`-------------------------------------------------------------*/
-yyerrlab1:
- yyerrstatus = 3; /* Each real token shifted decrements this. */
-
- for (;;)
- {
- yyn = yypact[yystate];
- if (!yypact_value_is_default (yyn))
- {
- yyn += YYTERROR;
- if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
- {
- yyn = yytable[yyn];
- if (0 < yyn)
- break;
- }
- }
-
- /* Pop the current state because it cannot handle the error token. */
- if (yyssp == yyss)
- YYABORT;
-
- yyerror_range[1] = *yylsp;
- yydestruct ("Error: popping",
- yystos[yystate], yyvsp, yylsp, lexer, parser);
- YYPOPSTACK (1);
- yystate = *yyssp;
- YY_STACK_PRINT (yyss, yyssp);
- }
-
- YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
- *++yyvsp = yylval;
- YY_IGNORE_MAYBE_UNINITIALIZED_END
-
- yyerror_range[2] = yylloc;
- /* Using YYLLOC is tempting, but would change the location of
- the lookahead. YYLOC is available though. */
- YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
- *++yylsp = yyloc;
-
- /* Shift the error token. */
- YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
-
- yystate = yyn;
- goto yynewstate;
-
-
-/*-------------------------------------.
-| yyacceptlab -- YYACCEPT comes here. |
-`-------------------------------------*/
-yyacceptlab:
- yyresult = 0;
- goto yyreturn;
-
-/*-----------------------------------.
-| yyabortlab -- YYABORT comes here. |
-`-----------------------------------*/
-yyabortlab:
- yyresult = 1;
- goto yyreturn;
-
-#if !defined yyoverflow || YYERROR_VERBOSE
-/*-------------------------------------------------.
-| yyexhaustedlab -- memory exhaustion comes here. |
-`-------------------------------------------------*/
-yyexhaustedlab:
- yyerror (&yylloc, lexer, parser, YY_("memory exhausted"));
- yyresult = 2;
- /* Fall through. */
-#endif
-
-yyreturn:
- if (yychar != YYEMPTY)
- {
- /* Make sure we have latest lookahead translation. See comments at
- user semantic actions for why this is necessary. */
- yytoken = YYTRANSLATE (yychar);
- yydestruct ("Cleanup: discarding lookahead",
- yytoken, &yylval, &yylloc, lexer, parser);
- }
- /* Do not reclaim the symbols of the rule whose action triggered
- this YYABORT or YYACCEPT. */
- YYPOPSTACK (yylen);
- YY_STACK_PRINT (yyss, yyssp);
- while (yyssp != yyss)
- {
- yydestruct ("Cleanup: popping",
- yystos[*yyssp], yyvsp, yylsp, lexer, parser);
- YYPOPSTACK (1);
- }
-#ifndef yyoverflow
- if (yyss != yyssa)
- YYSTACK_FREE (yyss);
-#endif
-#if YYERROR_VERBOSE
- if (yymsg != yymsgbuf)
- YYSTACK_FREE (yymsg);
-#endif
- return yyresult;
-}
-#line 1554 "src/wast-parser.y" /* yacc.c:1906 */
-
-
-Result ParseConst(Type type, const Literal& literal, Const* out) {
- string_view sv = literal.text;
- const char* s = sv.begin();
- const char* end = sv.end();
-
- out->type = type;
- switch (type) {
- case Type::I32:
- return ParseInt32(s, end, &out->u32, ParseIntType::SignedAndUnsigned);
- case Type::I64:
- return ParseInt64(s, end, &out->u64, ParseIntType::SignedAndUnsigned);
- case Type::F32:
- return ParseFloat(literal.type, s, end, &out->f32_bits);
- case Type::F64:
- return ParseDouble(literal.type, s, end, &out->f64_bits);
- default:
- assert(0);
- break;
- }
- return Result::Error;
-}
-
-void ReverseBindings(TypeVector* types, BindingHash* bindings) {
- for (auto& pair : *bindings) {
- pair.second.index = types->size() - pair.second.index - 1;
- }
-}
-
-bool IsEmptySignature(const FuncSignature* sig) {
- return sig->result_types.empty() && sig->param_types.empty();
-}
-
-void CheckImportOrdering(Location* loc, WastLexer* lexer, WastParser* parser,
- Module* module, const ModuleFieldList& fields) {
- for (const ModuleField& field: fields) {
- if (field.type == ModuleFieldType::Import) {
- if (module->funcs.size() != module->num_func_imports ||
- module->tables.size() != module->num_table_imports ||
- module->memories.size() != module->num_memory_imports ||
- module->globals.size() != module->num_global_imports ||
- module->excepts.size() != module->num_except_imports) {
- WastParserError(loc, lexer, parser,
- "imports must occur before all non-import definitions");
- }
- }
- }
-}
-
-void AppendModuleFields(Module* module, ModuleFieldList&& fields) {
- ModuleField* main_field = &fields.front();
- Index main_index = kInvalidIndex;
-
- for (ModuleField& field : fields) {
- std::string* name = nullptr;
- BindingHash* bindings = nullptr;
- Index index = kInvalidIndex;
-
- switch (field.type) {
- case ModuleFieldType::Func: {
- Func* func = cast<FuncModuleField>(&field)->func;
- name = &func->name;
- bindings = &module->func_bindings;
- index = module->funcs.size();
- module->funcs.push_back(func);
- break;
- }
-
- case ModuleFieldType::Global: {
- Global* global = cast<GlobalModuleField>(&field)->global;
- name = &global->name;
- bindings = &module->global_bindings;
- index = module->globals.size();
- module->globals.push_back(global);
- break;
- }
-
- case ModuleFieldType::Import: {
- Import* import = cast<ImportModuleField>(&field)->import;
-
- switch (import->kind) {
- case ExternalKind::Func:
- name = &import->func->name;
- bindings = &module->func_bindings;
- index = module->funcs.size();
- module->funcs.push_back(import->func);
- ++module->num_func_imports;
- break;
- case ExternalKind::Table:
- name = &import->table->name;
- bindings = &module->table_bindings;
- index = module->tables.size();
- module->tables.push_back(import->table);
- ++module->num_table_imports;
- break;
- case ExternalKind::Memory:
- name = &import->memory->name;
- bindings = &module->memory_bindings;
- index = module->memories.size();
- module->memories.push_back(import->memory);
- ++module->num_memory_imports;
- break;
- case ExternalKind::Global:
- name = &import->global->name;
- bindings = &module->global_bindings;
- index = module->globals.size();
- module->globals.push_back(import->global);
- ++module->num_global_imports;
- break;
- case ExternalKind::Except:
- name = &import->except->name;
- bindings = &module->except_bindings;
- index = module->excepts.size();
- module->excepts.push_back(import->except);
- ++module->num_except_imports;
- break;
- }
- module->imports.push_back(import);
- break;
- }
-
- case ModuleFieldType::Export: {
- Export* export_ = cast<ExportModuleField>(&field)->export_;
- if (&field != main_field) {
- // If this is not the main field, it must be an inline export.
- export_->var.set_index(main_index);
- }
- name = &export_->name;
- bindings = &module->export_bindings;
- index = module->exports.size();
- module->exports.push_back(export_);
- break;
- }
-
- case ModuleFieldType::FuncType: {
- FuncType* func_type = cast<FuncTypeModuleField>(&field)->func_type;
- name = &func_type->name;
- bindings = &module->func_type_bindings;
- index = module->func_types.size();
- module->func_types.push_back(func_type);
- break;
- }
-
- case ModuleFieldType::Table: {
- Table* table = cast<TableModuleField>(&field)->table;
- name = &table->name;
- bindings = &module->table_bindings;
- index = module->tables.size();
- module->tables.push_back(table);
- break;
- }
-
- case ModuleFieldType::ElemSegment: {
- ElemSegment* elem_segment =
- cast<ElemSegmentModuleField>(&field)->elem_segment;
- if (&field != main_field) {
- // If this is not the main field, it must be an inline elem segment.
- elem_segment->table_var.set_index(main_index);
- }
- module->elem_segments.push_back(elem_segment);
- break;
- }
-
- case ModuleFieldType::Memory: {
- Memory* memory = cast<MemoryModuleField>(&field)->memory;
- name = &memory->name;
- bindings = &module->memory_bindings;
- index = module->memories.size();
- module->memories.push_back(memory);
- break;
- }
-
- case ModuleFieldType::DataSegment: {
- DataSegment* data_segment =
- cast<DataSegmentModuleField>(&field)->data_segment;
- if (&field != main_field) {
- // If this is not the main field, it must be an inline data segment.
- data_segment->memory_var.set_index(main_index);
- }
- module->data_segments.push_back(data_segment);
- break;
- }
-
- case ModuleFieldType::Except: {
- Exception* except = cast<ExceptionModuleField>(&field)->except;
- name = &except->name;
- bindings = &module->except_bindings;
- index = module->excepts.size();
- module->excepts.push_back(except);
- break;
- }
-
- case ModuleFieldType::Start:
- module->start = &cast<StartModuleField>(&field)->start;
- break;
- }
-
- if (&field == main_field)
- main_index = index;
-
- if (name && bindings) {
- // Exported names are allowed to be empty; other names aren't.
- if (bindings == &module->export_bindings || !name->empty()) {
- bindings->emplace(*name, Binding(field.loc, index));
- }
- }
- }
-
- module->fields.splice(module->fields.end(), fields);
-}
-
-void ResolveFuncTypes(Module* module) {
- for (ModuleField& field : module->fields) {
- Func* func = nullptr;
- if (field.type == ModuleFieldType::Func) {
- func = dyn_cast<FuncModuleField>(&field)->func;
- } else if (field.type == ModuleFieldType::Import) {
- Import* import = dyn_cast<ImportModuleField>(&field)->import;
- if (import->kind == ExternalKind::Func) {
- func = import->func;
- } else {
- continue;
- }
- } else {
- continue;
- }
-
- // Resolve func type variables where the signature was not specified
- // explicitly, e.g.: (func (type 1) ...)
- if (func->decl.has_func_type && IsEmptySignature(&func->decl.sig)) {
- FuncType* func_type = module->GetFuncType(func->decl.type_var);
- if (func_type) {
- func->decl.sig = func_type->sig;
- }
- }
-
- // Resolve implicitly defined function types, e.g.: (func (param i32) ...)
- if (!func->decl.has_func_type) {
- Index func_type_index = module->GetFuncTypeIndex(func->decl.sig);
- if (func_type_index == kInvalidIndex) {
- auto func_type = new FuncType();
- func_type->sig = func->decl.sig;
- ModuleFieldList fields;
- fields.push_back(new FuncTypeModuleField(func_type, field.loc));
- AppendModuleFields(module, std::move(fields));
- }
- }
- }
-}
-
-Result ParseWast(WastLexer * lexer, Script * *out_script,
- ErrorHandler * error_handler, WastParseOptions * options) {
- WastParser parser;
- ZeroMemory(parser);
- static WastParseOptions default_options;
- if (options == nullptr)
- options = &default_options;
- parser.options = options;
- parser.error_handler = error_handler;
- wabt_wast_parser_debug = int(options->debug_parsing);
- int result = wabt_wast_parser_parse(lexer, &parser);
- delete [] parser.yyssa;
- delete [] parser.yyvsa;
- delete [] parser.yylsa;
- if (out_script) {
- *out_script = parser.script;
- } else {
- delete parser.script;
- }
- return result == 0 && parser.errors == 0 ? Result::Ok : Result::Error;
-}
-
-BinaryErrorHandlerModule::BinaryErrorHandlerModule(
- Location* loc, WastLexer* lexer, WastParser* parser)
- : ErrorHandler(Location::Type::Binary),
- loc_(loc),
- lexer_(lexer),
- parser_(parser) {}
-
-bool BinaryErrorHandlerModule::OnError(
- const Location& binary_loc, const std::string& error,
- const std::string& source_line, size_t source_line_column_offset) {
- if (binary_loc.offset == kInvalidOffset) {
- WastParserError(loc_, lexer_, parser_, "error in binary module: %s",
- error.c_str());
- } else {
- WastParserError(loc_, lexer_, parser_,
- "error in binary module: @0x%08" PRIzx ": %s",
- binary_loc.offset, error.c_str());
- }
- return true;
-}
-
-} // namespace wabt
diff --git a/src/prebuilt/wast-parser-gen.hh b/src/prebuilt/wast-parser-gen.hh
deleted file mode 100644
index ffde5533..00000000
--- a/src/prebuilt/wast-parser-gen.hh
+++ /dev/null
@@ -1,164 +0,0 @@
-/* A Bison parser, made by GNU Bison 3.0.2. */
-
-/* Bison interface for Yacc-like parsers in C
-
- Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-/* As a special exception, you may create a larger work that contains
- part or all of the Bison parser skeleton and distribute that work
- under terms of your choice, so long as that work isn't itself a
- parser generator using the skeleton or a modified version thereof
- as a parser skeleton. Alternatively, if you modify or redistribute
- the parser skeleton itself, you may (at your option) remove this
- special exception, which will cause the skeleton and the resulting
- Bison output files to be licensed under the GNU General Public
- License without this special exception.
-
- This special exception was added by the Free Software Foundation in
- version 2.2 of Bison. */
-
-#ifndef YY_WABT_WAST_PARSER_SRC_PREBUILT_WAST_PARSER_GEN_HH_INCLUDED
-# define YY_WABT_WAST_PARSER_SRC_PREBUILT_WAST_PARSER_GEN_HH_INCLUDED
-/* Debug traces. */
-#ifndef WABT_WAST_PARSER_DEBUG
-# if defined YYDEBUG
-#if YYDEBUG
-# define WABT_WAST_PARSER_DEBUG 1
-# else
-# define WABT_WAST_PARSER_DEBUG 0
-# endif
-# else /* ! defined YYDEBUG */
-# define WABT_WAST_PARSER_DEBUG 0
-# endif /* ! defined YYDEBUG */
-#endif /* ! defined WABT_WAST_PARSER_DEBUG */
-#if WABT_WAST_PARSER_DEBUG
-extern int wabt_wast_parser_debug;
-#endif
-
-/* Token type. */
-#ifndef WABT_WAST_PARSER_TOKENTYPE
-# define WABT_WAST_PARSER_TOKENTYPE
- enum wabt_wast_parser_tokentype
- {
- WABT_TOKEN_TYPE_EOF = 0,
- WABT_TOKEN_TYPE_LPAR = 258,
- WABT_TOKEN_TYPE_RPAR = 259,
- WABT_TOKEN_TYPE_NAT = 260,
- WABT_TOKEN_TYPE_INT = 261,
- WABT_TOKEN_TYPE_FLOAT = 262,
- WABT_TOKEN_TYPE_TEXT = 263,
- WABT_TOKEN_TYPE_VAR = 264,
- WABT_TOKEN_TYPE_VALUE_TYPE = 265,
- WABT_TOKEN_TYPE_ANYFUNC = 266,
- WABT_TOKEN_TYPE_MUT = 267,
- WABT_TOKEN_TYPE_NOP = 268,
- WABT_TOKEN_TYPE_DROP = 269,
- WABT_TOKEN_TYPE_BLOCK = 270,
- WABT_TOKEN_TYPE_END = 271,
- WABT_TOKEN_TYPE_IF = 272,
- WABT_TOKEN_TYPE_THEN = 273,
- WABT_TOKEN_TYPE_ELSE = 274,
- WABT_TOKEN_TYPE_LOOP = 275,
- WABT_TOKEN_TYPE_BR = 276,
- WABT_TOKEN_TYPE_BR_IF = 277,
- WABT_TOKEN_TYPE_BR_TABLE = 278,
- WABT_TOKEN_TYPE_TRY = 279,
- WABT_TOKEN_TYPE_CATCH = 280,
- WABT_TOKEN_TYPE_CATCH_ALL = 281,
- WABT_TOKEN_TYPE_THROW = 282,
- WABT_TOKEN_TYPE_RETHROW = 283,
- WABT_TOKEN_TYPE_LPAR_CATCH = 284,
- WABT_TOKEN_TYPE_LPAR_CATCH_ALL = 285,
- WABT_TOKEN_TYPE_CALL = 286,
- WABT_TOKEN_TYPE_CALL_INDIRECT = 287,
- WABT_TOKEN_TYPE_RETURN = 288,
- WABT_TOKEN_TYPE_GET_LOCAL = 289,
- WABT_TOKEN_TYPE_SET_LOCAL = 290,
- WABT_TOKEN_TYPE_TEE_LOCAL = 291,
- WABT_TOKEN_TYPE_GET_GLOBAL = 292,
- WABT_TOKEN_TYPE_SET_GLOBAL = 293,
- WABT_TOKEN_TYPE_LOAD = 294,
- WABT_TOKEN_TYPE_STORE = 295,
- WABT_TOKEN_TYPE_OFFSET_EQ_NAT = 296,
- WABT_TOKEN_TYPE_ALIGN_EQ_NAT = 297,
- WABT_TOKEN_TYPE_CONST = 298,
- WABT_TOKEN_TYPE_UNARY = 299,
- WABT_TOKEN_TYPE_BINARY = 300,
- WABT_TOKEN_TYPE_COMPARE = 301,
- WABT_TOKEN_TYPE_CONVERT = 302,
- WABT_TOKEN_TYPE_SELECT = 303,
- WABT_TOKEN_TYPE_UNREACHABLE = 304,
- WABT_TOKEN_TYPE_CURRENT_MEMORY = 305,
- WABT_TOKEN_TYPE_GROW_MEMORY = 306,
- WABT_TOKEN_TYPE_FUNC = 307,
- WABT_TOKEN_TYPE_START = 308,
- WABT_TOKEN_TYPE_TYPE = 309,
- WABT_TOKEN_TYPE_PARAM = 310,
- WABT_TOKEN_TYPE_RESULT = 311,
- WABT_TOKEN_TYPE_LOCAL = 312,
- WABT_TOKEN_TYPE_GLOBAL = 313,
- WABT_TOKEN_TYPE_TABLE = 314,
- WABT_TOKEN_TYPE_ELEM = 315,
- WABT_TOKEN_TYPE_MEMORY = 316,
- WABT_TOKEN_TYPE_DATA = 317,
- WABT_TOKEN_TYPE_OFFSET = 318,
- WABT_TOKEN_TYPE_IMPORT = 319,
- WABT_TOKEN_TYPE_EXPORT = 320,
- WABT_TOKEN_TYPE_EXCEPT = 321,
- WABT_TOKEN_TYPE_MODULE = 322,
- WABT_TOKEN_TYPE_BIN = 323,
- WABT_TOKEN_TYPE_QUOTE = 324,
- WABT_TOKEN_TYPE_REGISTER = 325,
- WABT_TOKEN_TYPE_INVOKE = 326,
- WABT_TOKEN_TYPE_GET = 327,
- WABT_TOKEN_TYPE_ASSERT_MALFORMED = 328,
- WABT_TOKEN_TYPE_ASSERT_INVALID = 329,
- WABT_TOKEN_TYPE_ASSERT_UNLINKABLE = 330,
- WABT_TOKEN_TYPE_ASSERT_RETURN = 331,
- WABT_TOKEN_TYPE_ASSERT_RETURN_CANONICAL_NAN = 332,
- WABT_TOKEN_TYPE_ASSERT_RETURN_ARITHMETIC_NAN = 333,
- WABT_TOKEN_TYPE_ASSERT_TRAP = 334,
- WABT_TOKEN_TYPE_ASSERT_EXHAUSTION = 335,
- WABT_TOKEN_TYPE_LOW = 336
- };
-#endif
-
-/* Value type. */
-#if ! defined WABT_WAST_PARSER_STYPE && ! defined WABT_WAST_PARSER_STYPE_IS_DECLARED
-typedef ::wabt::Token WABT_WAST_PARSER_STYPE;
-# define WABT_WAST_PARSER_STYPE_IS_TRIVIAL 1
-# define WABT_WAST_PARSER_STYPE_IS_DECLARED 1
-#endif
-
-/* Location type. */
-#if ! defined WABT_WAST_PARSER_LTYPE && ! defined WABT_WAST_PARSER_LTYPE_IS_DECLARED
-typedef struct WABT_WAST_PARSER_LTYPE WABT_WAST_PARSER_LTYPE;
-struct WABT_WAST_PARSER_LTYPE
-{
- int first_line;
- int first_column;
- int last_line;
- int last_column;
-};
-# define WABT_WAST_PARSER_LTYPE_IS_DECLARED 1
-# define WABT_WAST_PARSER_LTYPE_IS_TRIVIAL 1
-#endif
-
-
-
-int wabt_wast_parser_parse (::wabt::WastLexer* lexer, ::wabt::WastParser* parser);
-
-#endif /* !YY_WABT_WAST_PARSER_SRC_PREBUILT_WAST_PARSER_GEN_HH_INCLUDED */
diff --git a/src/prebuilt/wast-parser-gen.output b/src/prebuilt/wast-parser-gen.output
deleted file mode 100644
index ebfabe54..00000000
--- a/src/prebuilt/wast-parser-gen.output
+++ /dev/null
@@ -1,6361 +0,0 @@
-Grammar
-
- 0 $accept: script_start "EOF"
-
- 1 text_list: TEXT
- 2 | text_list TEXT
-
- 3 text_list_opt: %empty
- 4 | text_list
-
- 5 quoted_text: TEXT
-
- 6 value_type_list: %empty
- 7 | value_type_list VALUE_TYPE
-
- 8 elem_type: ANYFUNC
-
- 9 global_type: VALUE_TYPE
- 10 | "(" MUT VALUE_TYPE ")"
-
- 11 func_type: "(" FUNC func_sig ")"
-
- 12 func_sig: func_sig_result
- 13 | "(" PARAM value_type_list ")" func_sig
- 14 | "(" PARAM bind_var VALUE_TYPE ")" func_sig
-
- 15 func_sig_result: %empty
- 16 | "(" RESULT value_type_list ")" func_sig_result
-
- 17 table_sig: limits elem_type
-
- 18 memory_sig: limits
-
- 19 limits: nat
- 20 | nat nat
-
- 21 type_use: "(" TYPE var ")"
-
- 22 nat: NAT
-
- 23 literal: NAT
- 24 | INT
- 25 | FLOAT
-
- 26 var: nat
- 27 | VAR
-
- 28 var_list: %empty
- 29 | var_list var
-
- 30 bind_var_opt: %empty
- 31 | bind_var
-
- 32 bind_var: VAR
-
- 33 labeling_opt: %empty
- 34 | bind_var
-
- 35 offset_opt: %empty
- 36 | OFFSET_EQ_NAT
-
- 37 align_opt: %empty
- 38 | ALIGN_EQ_NAT
-
- 39 instr: plain_instr
- 40 | block_instr
- 41 | expr
-
- 42 plain_instr: UNREACHABLE
- 43 | NOP
- 44 | DROP
- 45 | SELECT
- 46 | BR var
- 47 | BR_IF var
- 48 | BR_TABLE var_list var
- 49 | RETURN
- 50 | CALL var
- 51 | CALL_INDIRECT var
- 52 | GET_LOCAL var
- 53 | SET_LOCAL var
- 54 | TEE_LOCAL var
- 55 | GET_GLOBAL var
- 56 | SET_GLOBAL var
- 57 | LOAD offset_opt align_opt
- 58 | STORE offset_opt align_opt
- 59 | CONST literal
- 60 | UNARY
- 61 | BINARY
- 62 | COMPARE
- 63 | CONVERT
- 64 | CURRENT_MEMORY
- 65 | GROW_MEMORY
- 66 | throw_check var
- 67 | rethrow_check var
-
- 68 block_instr: BLOCK labeling_opt block END labeling_opt
- 69 | LOOP labeling_opt block END labeling_opt
- 70 | IF labeling_opt block END labeling_opt
- 71 | IF labeling_opt block ELSE labeling_opt instr_list END labeling_opt
- 72 | try_check labeling_opt block catch_instr_list END labeling_opt
-
- 73 block_sig: "(" RESULT value_type_list ")"
-
- 74 block: block_sig block
- 75 | instr_list
-
- 76 plain_catch: CATCH var instr_list
-
- 77 plain_catch_all: CATCH_ALL instr_list
-
- 78 catch_instr: plain_catch
- 79 | plain_catch_all
-
- 80 catch_instr_list: catch_instr
- 81 | catch_instr_list catch_instr
-
- 82 expr: "(" expr1 ")"
-
- 83 expr1: plain_instr expr_list
- 84 | BLOCK labeling_opt block
- 85 | LOOP labeling_opt block
- 86 | IF labeling_opt if_block
- 87 | try_check labeling_opt try_
-
- 88 try_: block_sig try_
- 89 | instr_list catch_sexp_list
-
- 90 catch_sexp: LPAR_CATCH "(" plain_catch ")"
- 91 | LPAR_CATCH_ALL "(" plain_catch_all ")"
-
- 92 catch_sexp_list: catch_sexp
- 93 | catch_sexp_list catch_sexp
-
- 94 if_block: block_sig if_block
- 95 | if_
-
- 96 if_: "(" THEN instr_list ")" "(" ELSE instr_list ")"
- 97 | "(" THEN instr_list ")"
- 98 | expr "(" THEN instr_list ")" "(" ELSE instr_list ")"
- 99 | expr "(" THEN instr_list ")"
- 100 | expr expr expr
- 101 | expr expr
-
- 102 rethrow_check: RETHROW
-
- 103 throw_check: THROW
-
- 104 try_check: TRY
-
- 105 instr_list: %empty
- 106 | instr instr_list
-
- 107 expr_list: %empty
- 108 | expr expr_list
-
- 109 const_expr: instr_list
-
- 110 exception: "(" EXCEPT bind_var_opt value_type_list ")"
-
- 111 exception_field: exception
-
- 112 func: "(" FUNC bind_var_opt func_fields ")"
-
- 113 func_fields: type_use func_fields_body
- 114 | func_fields_body
- 115 | inline_import type_use func_fields_import
- 116 | inline_import func_fields_import
- 117 | inline_export func_fields
-
- 118 func_fields_import: func_fields_import1
-
- 119 func_fields_import1: func_fields_import_result
- 120 | "(" PARAM value_type_list ")" func_fields_import1
- 121 | "(" PARAM bind_var VALUE_TYPE ")" func_fields_import1
-
- 122 func_fields_import_result: %empty
- 123 | "(" RESULT value_type_list ")" func_fields_import_result
-
- 124 func_fields_body: func_fields_body1
-
- 125 func_fields_body1: func_result_body
- 126 | "(" PARAM value_type_list ")" func_fields_body1
- 127 | "(" PARAM bind_var VALUE_TYPE ")" func_fields_body1
-
- 128 func_result_body: func_body
- 129 | "(" RESULT value_type_list ")" func_result_body
-
- 130 func_body: func_body1
-
- 131 func_body1: instr_list
- 132 | "(" LOCAL value_type_list ")" func_body1
- 133 | "(" LOCAL bind_var VALUE_TYPE ")" func_body1
-
- 134 offset: "(" OFFSET const_expr ")"
- 135 | expr
-
- 136 elem: "(" ELEM var offset var_list ")"
- 137 | "(" ELEM offset var_list ")"
-
- 138 table: "(" TABLE bind_var_opt table_fields ")"
-
- 139 table_fields: table_sig
- 140 | inline_import table_sig
- 141 | inline_export table_fields
- 142 | elem_type "(" ELEM var_list ")"
-
- 143 data: "(" DATA var offset text_list_opt ")"
- 144 | "(" DATA offset text_list_opt ")"
-
- 145 memory: "(" MEMORY bind_var_opt memory_fields ")"
-
- 146 memory_fields: memory_sig
- 147 | inline_import memory_sig
- 148 | inline_export memory_fields
- 149 | "(" DATA text_list_opt ")"
-
- 150 global: "(" GLOBAL bind_var_opt global_fields ")"
-
- 151 global_fields: global_type const_expr
- 152 | inline_import global_type
- 153 | inline_export global_fields
-
- 154 import_desc: "(" FUNC bind_var_opt type_use ")"
- 155 | "(" FUNC bind_var_opt func_sig ")"
- 156 | "(" TABLE bind_var_opt table_sig ")"
- 157 | "(" MEMORY bind_var_opt memory_sig ")"
- 158 | "(" GLOBAL bind_var_opt global_type ")"
- 159 | exception
-
- 160 import: "(" IMPORT quoted_text quoted_text import_desc ")"
-
- 161 inline_import: "(" IMPORT quoted_text quoted_text ")"
-
- 162 export_desc: "(" FUNC var ")"
- 163 | "(" TABLE var ")"
- 164 | "(" MEMORY var ")"
- 165 | "(" GLOBAL var ")"
- 166 | "(" EXCEPT var ")"
-
- 167 export: "(" EXPORT quoted_text export_desc ")"
-
- 168 inline_export: "(" EXPORT quoted_text ")"
-
- 169 type_def: "(" TYPE func_type ")"
- 170 | "(" TYPE bind_var func_type ")"
-
- 171 start: "(" START var ")"
-
- 172 module_field: type_def
- 173 | global
- 174 | table
- 175 | memory
- 176 | func
- 177 | elem
- 178 | data
- 179 | start
- 180 | import
- 181 | export
- 182 | exception_field
-
- 183 module_fields_opt: %empty
- 184 | module_fields
-
- 185 module_fields: module_field
- 186 | module_fields module_field
-
- 187 module: script_module
-
- 188 inline_module: module_fields
-
- 189 script_var_opt: %empty
- 190 | VAR
-
- 191 script_module: "(" MODULE bind_var_opt module_fields_opt ")"
- 192 | "(" MODULE bind_var_opt BIN text_list ")"
- 193 | "(" MODULE bind_var_opt QUOTE text_list ")"
-
- 194 action: "(" INVOKE script_var_opt quoted_text const_list ")"
- 195 | "(" GET script_var_opt quoted_text ")"
-
- 196 assertion: "(" ASSERT_MALFORMED script_module quoted_text ")"
- 197 | "(" ASSERT_INVALID script_module quoted_text ")"
- 198 | "(" ASSERT_UNLINKABLE script_module quoted_text ")"
- 199 | "(" ASSERT_TRAP script_module quoted_text ")"
- 200 | "(" ASSERT_RETURN action const_list ")"
- 201 | "(" ASSERT_RETURN_CANONICAL_NAN action ")"
- 202 | "(" ASSERT_RETURN_ARITHMETIC_NAN action ")"
- 203 | "(" ASSERT_TRAP action quoted_text ")"
- 204 | "(" ASSERT_EXHAUSTION action quoted_text ")"
-
- 205 cmd: action
- 206 | assertion
- 207 | module
- 208 | "(" REGISTER quoted_text script_var_opt ")"
-
- 209 cmd_list: cmd
- 210 | cmd_list cmd
-
- 211 const: "(" CONST literal ")"
-
- 212 const_list: %empty
- 213 | const_list const
-
- 214 script: %empty
- 215 | cmd_list
- 216 | inline_module
-
- 217 script_start: script
-
-
-Terminals, with rules where they appear
-
-"EOF" (0) 0
-error (256)
-"(" (258) 10 11 13 14 16 21 73 82 90 91 96 97 98 99 110 112 120 121
- 123 126 127 129 132 133 134 136 137 138 142 143 144 145 149 150
- 154 155 156 157 158 160 161 162 163 164 165 166 167 168 169 170
- 171 191 192 193 194 195 196 197 198 199 200 201 202 203 204 208
- 211
-")" (259) 10 11 13 14 16 21 73 82 90 91 96 97 98 99 110 112 120 121
- 123 126 127 129 132 133 134 136 137 138 142 143 144 145 149 150
- 154 155 156 157 158 160 161 162 163 164 165 166 167 168 169 170
- 171 191 192 193 194 195 196 197 198 199 200 201 202 203 204 208
- 211
-NAT (260) 22 23
-INT (261) 24
-FLOAT (262) 25
-TEXT (263) 1 2 5
-VAR (264) 27 32 190
-VALUE_TYPE (265) 7 9 10 14 121 127 133
-ANYFUNC (266) 8
-MUT (267) 10
-NOP (268) 43
-DROP (269) 44
-BLOCK (270) 68 84
-END (271) 68 69 70 71 72
-IF (272) 70 71 86
-THEN (273) 96 97 98 99
-ELSE (274) 71 96 98
-LOOP (275) 69 85
-BR (276) 46
-BR_IF (277) 47
-BR_TABLE (278) 48
-TRY (279) 104
-CATCH (280) 76
-CATCH_ALL (281) 77
-THROW (282) 103
-RETHROW (283) 102
-LPAR_CATCH (284) 90
-LPAR_CATCH_ALL (285) 91
-CALL (286) 50
-CALL_INDIRECT (287) 51
-RETURN (288) 49
-GET_LOCAL (289) 52
-SET_LOCAL (290) 53
-TEE_LOCAL (291) 54
-GET_GLOBAL (292) 55
-SET_GLOBAL (293) 56
-LOAD (294) 57
-STORE (295) 58
-OFFSET_EQ_NAT (296) 36
-ALIGN_EQ_NAT (297) 38
-CONST (298) 59 211
-UNARY (299) 60
-BINARY (300) 61
-COMPARE (301) 62
-CONVERT (302) 63
-SELECT (303) 45
-UNREACHABLE (304) 42
-CURRENT_MEMORY (305) 64
-GROW_MEMORY (306) 65
-FUNC (307) 11 112 154 155 162
-START (308) 171
-TYPE (309) 21 169 170
-PARAM (310) 13 14 120 121 126 127
-RESULT (311) 16 73 123 129
-LOCAL (312) 132 133
-GLOBAL (313) 150 158 165
-TABLE (314) 138 156 163
-ELEM (315) 136 137 142
-MEMORY (316) 145 157 164
-DATA (317) 143 144 149
-OFFSET (318) 134
-IMPORT (319) 160 161
-EXPORT (320) 167 168
-EXCEPT (321) 110 166
-MODULE (322) 191 192 193
-BIN (323) 192
-QUOTE (324) 193
-REGISTER (325) 208
-INVOKE (326) 194
-GET (327) 195
-ASSERT_MALFORMED (328) 196
-ASSERT_INVALID (329) 197
-ASSERT_UNLINKABLE (330) 198
-ASSERT_RETURN (331) 200
-ASSERT_RETURN_CANONICAL_NAN (332) 201
-ASSERT_RETURN_ARITHMETIC_NAN (333) 202
-ASSERT_TRAP (334) 199 203
-ASSERT_EXHAUSTION (335) 204
-LOW (336)
-
-
-Nonterminals, with rules where they appear
-
-$accept (82)
- on left: 0
-text_list (83)
- on left: 1 2, on right: 2 4 192 193
-text_list_opt (84)
- on left: 3 4, on right: 143 144 149
-quoted_text (85)
- on left: 5, on right: 160 161 167 168 194 195 196 197 198 199 203
- 204 208
-value_type_list (86)
- on left: 6 7, on right: 7 13 16 73 110 120 123 126 129 132
-elem_type (87)
- on left: 8, on right: 17 142
-global_type (88)
- on left: 9 10, on right: 151 152 158
-func_type (89)
- on left: 11, on right: 169 170
-func_sig (90)
- on left: 12 13 14, on right: 11 13 14 155
-func_sig_result (91)
- on left: 15 16, on right: 12 16
-table_sig (92)
- on left: 17, on right: 139 140 156
-memory_sig (93)
- on left: 18, on right: 146 147 157
-limits (94)
- on left: 19 20, on right: 17 18
-type_use (95)
- on left: 21, on right: 113 115 154
-nat (96)
- on left: 22, on right: 19 20 26
-literal (97)
- on left: 23 24 25, on right: 59 211
-var (98)
- on left: 26 27, on right: 21 29 46 47 48 50 51 52 53 54 55 56 66
- 67 76 136 143 162 163 164 165 166 171
-var_list (99)
- on left: 28 29, on right: 29 48 136 137 142
-bind_var_opt (100)
- on left: 30 31, on right: 110 112 138 145 150 154 155 156 157 158
- 191 192 193
-bind_var (101)
- on left: 32, on right: 14 31 34 121 127 133 170
-labeling_opt (102)
- on left: 33 34, on right: 68 69 70 71 72 84 85 86 87
-offset_opt (103)
- on left: 35 36, on right: 57 58
-align_opt (104)
- on left: 37 38, on right: 57 58
-instr (105)
- on left: 39 40 41, on right: 106
-plain_instr (106)
- on left: 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
- 60 61 62 63 64 65 66 67, on right: 39 83
-block_instr (107)
- on left: 68 69 70 71 72, on right: 40
-block_sig (108)
- on left: 73, on right: 74 88 94
-block (109)
- on left: 74 75, on right: 68 69 70 71 72 74 84 85
-plain_catch (110)
- on left: 76, on right: 78 90
-plain_catch_all (111)
- on left: 77, on right: 79 91
-catch_instr (112)
- on left: 78 79, on right: 80 81
-catch_instr_list (113)
- on left: 80 81, on right: 72 81
-expr (114)
- on left: 82, on right: 41 98 99 100 101 108 135
-expr1 (115)
- on left: 83 84 85 86 87, on right: 82
-try_ (116)
- on left: 88 89, on right: 87 88
-catch_sexp (117)
- on left: 90 91, on right: 92 93
-catch_sexp_list (118)
- on left: 92 93, on right: 89 93
-if_block (119)
- on left: 94 95, on right: 86 94
-if_ (120)
- on left: 96 97 98 99 100 101, on right: 95
-rethrow_check (121)
- on left: 102, on right: 67
-throw_check (122)
- on left: 103, on right: 66
-try_check (123)
- on left: 104, on right: 72 87
-instr_list (124)
- on left: 105 106, on right: 71 75 76 77 89 96 97 98 99 106 109
- 131
-expr_list (125)
- on left: 107 108, on right: 83 108
-const_expr (126)
- on left: 109, on right: 134 151
-exception (127)
- on left: 110, on right: 111 159
-exception_field (128)
- on left: 111, on right: 182
-func (129)
- on left: 112, on right: 176
-func_fields (130)
- on left: 113 114 115 116 117, on right: 112 117
-func_fields_import (131)
- on left: 118, on right: 115 116
-func_fields_import1 (132)
- on left: 119 120 121, on right: 118 120 121
-func_fields_import_result (133)
- on left: 122 123, on right: 119 123
-func_fields_body (134)
- on left: 124, on right: 113 114
-func_fields_body1 (135)
- on left: 125 126 127, on right: 124 126 127
-func_result_body (136)
- on left: 128 129, on right: 125 129
-func_body (137)
- on left: 130, on right: 128
-func_body1 (138)
- on left: 131 132 133, on right: 130 132 133
-offset (139)
- on left: 134 135, on right: 136 137 143 144
-elem (140)
- on left: 136 137, on right: 177
-table (141)
- on left: 138, on right: 174
-table_fields (142)
- on left: 139 140 141 142, on right: 138 141
-data (143)
- on left: 143 144, on right: 178
-memory (144)
- on left: 145, on right: 175
-memory_fields (145)
- on left: 146 147 148 149, on right: 145 148
-global (146)
- on left: 150, on right: 173
-global_fields (147)
- on left: 151 152 153, on right: 150 153
-import_desc (148)
- on left: 154 155 156 157 158 159, on right: 160
-import (149)
- on left: 160, on right: 180
-inline_import (150)
- on left: 161, on right: 115 116 140 147 152
-export_desc (151)
- on left: 162 163 164 165 166, on right: 167
-export (152)
- on left: 167, on right: 181
-inline_export (153)
- on left: 168, on right: 117 141 148 153
-type_def (154)
- on left: 169 170, on right: 172
-start (155)
- on left: 171, on right: 179
-module_field (156)
- on left: 172 173 174 175 176 177 178 179 180 181 182, on right:
- 185 186
-module_fields_opt (157)
- on left: 183 184, on right: 191
-module_fields (158)
- on left: 185 186, on right: 184 186 188
-module (159)
- on left: 187, on right: 207
-inline_module (160)
- on left: 188, on right: 216
-script_var_opt (161)
- on left: 189 190, on right: 194 195 208
-script_module (162)
- on left: 191 192 193, on right: 187 196 197 198 199
-action (163)
- on left: 194 195, on right: 200 201 202 203 204 205
-assertion (164)
- on left: 196 197 198 199 200 201 202 203 204, on right: 206
-cmd (165)
- on left: 205 206 207 208, on right: 209 210
-cmd_list (166)
- on left: 209 210, on right: 210 215
-const (167)
- on left: 211, on right: 213
-const_list (168)
- on left: 212 213, on right: 194 200 213
-script (169)
- on left: 214 215 216, on right: 217
-script_start (170)
- on left: 217, on right: 0
-
-
-State 0
-
- 0 $accept: . script_start "EOF"
-
- "(" shift, and go to state 1
-
- $default reduce using rule 214 (script)
-
- exception go to state 2
- exception_field go to state 3
- func go to state 4
- elem go to state 5
- table go to state 6
- data go to state 7
- memory go to state 8
- global go to state 9
- import go to state 10
- export go to state 11
- type_def go to state 12
- start go to state 13
- module_field go to state 14
- module_fields go to state 15
- module go to state 16
- inline_module go to state 17
- script_module go to state 18
- action go to state 19
- assertion go to state 20
- cmd go to state 21
- cmd_list go to state 22
- script go to state 23
- script_start go to state 24
-
-
-State 1
-
- 110 exception: "(" . EXCEPT bind_var_opt value_type_list ")"
- 112 func: "(" . FUNC bind_var_opt func_fields ")"
- 136 elem: "(" . ELEM var offset var_list ")"
- 137 | "(" . ELEM offset var_list ")"
- 138 table: "(" . TABLE bind_var_opt table_fields ")"
- 143 data: "(" . DATA var offset text_list_opt ")"
- 144 | "(" . DATA offset text_list_opt ")"
- 145 memory: "(" . MEMORY bind_var_opt memory_fields ")"
- 150 global: "(" . GLOBAL bind_var_opt global_fields ")"
- 160 import: "(" . IMPORT quoted_text quoted_text import_desc ")"
- 167 export: "(" . EXPORT quoted_text export_desc ")"
- 169 type_def: "(" . TYPE func_type ")"
- 170 | "(" . TYPE bind_var func_type ")"
- 171 start: "(" . START var ")"
- 191 script_module: "(" . MODULE bind_var_opt module_fields_opt ")"
- 192 | "(" . MODULE bind_var_opt BIN text_list ")"
- 193 | "(" . MODULE bind_var_opt QUOTE text_list ")"
- 194 action: "(" . INVOKE script_var_opt quoted_text const_list ")"
- 195 | "(" . GET script_var_opt quoted_text ")"
- 196 assertion: "(" . ASSERT_MALFORMED script_module quoted_text ")"
- 197 | "(" . ASSERT_INVALID script_module quoted_text ")"
- 198 | "(" . ASSERT_UNLINKABLE script_module quoted_text ")"
- 199 | "(" . ASSERT_TRAP script_module quoted_text ")"
- 200 | "(" . ASSERT_RETURN action const_list ")"
- 201 | "(" . ASSERT_RETURN_CANONICAL_NAN action ")"
- 202 | "(" . ASSERT_RETURN_ARITHMETIC_NAN action ")"
- 203 | "(" . ASSERT_TRAP action quoted_text ")"
- 204 | "(" . ASSERT_EXHAUSTION action quoted_text ")"
- 208 cmd: "(" . REGISTER quoted_text script_var_opt ")"
-
- FUNC shift, and go to state 25
- START shift, and go to state 26
- TYPE shift, and go to state 27
- GLOBAL shift, and go to state 28
- TABLE shift, and go to state 29
- ELEM shift, and go to state 30
- MEMORY shift, and go to state 31
- DATA shift, and go to state 32
- IMPORT shift, and go to state 33
- EXPORT shift, and go to state 34
- EXCEPT shift, and go to state 35
- MODULE shift, and go to state 36
- REGISTER shift, and go to state 37
- INVOKE shift, and go to state 38
- GET shift, and go to state 39
- ASSERT_MALFORMED shift, and go to state 40
- ASSERT_INVALID shift, and go to state 41
- ASSERT_UNLINKABLE shift, and go to state 42
- ASSERT_RETURN shift, and go to state 43
- ASSERT_RETURN_CANONICAL_NAN shift, and go to state 44
- ASSERT_RETURN_ARITHMETIC_NAN shift, and go to state 45
- ASSERT_TRAP shift, and go to state 46
- ASSERT_EXHAUSTION shift, and go to state 47
-
-
-State 2
-
- 111 exception_field: exception .
-
- $default reduce using rule 111 (exception_field)
-
-
-State 3
-
- 182 module_field: exception_field .
-
- $default reduce using rule 182 (module_field)
-
-
-State 4
-
- 176 module_field: func .
-
- $default reduce using rule 176 (module_field)
-
-
-State 5
-
- 177 module_field: elem .
-
- $default reduce using rule 177 (module_field)
-
-
-State 6
-
- 174 module_field: table .
-
- $default reduce using rule 174 (module_field)
-
-
-State 7
-
- 178 module_field: data .
-
- $default reduce using rule 178 (module_field)
-
-
-State 8
-
- 175 module_field: memory .
-
- $default reduce using rule 175 (module_field)
-
-
-State 9
-
- 173 module_field: global .
-
- $default reduce using rule 173 (module_field)
-
-
-State 10
-
- 180 module_field: import .
-
- $default reduce using rule 180 (module_field)
-
-
-State 11
-
- 181 module_field: export .
-
- $default reduce using rule 181 (module_field)
-
-
-State 12
-
- 172 module_field: type_def .
-
- $default reduce using rule 172 (module_field)
-
-
-State 13
-
- 179 module_field: start .
-
- $default reduce using rule 179 (module_field)
-
-
-State 14
-
- 185 module_fields: module_field .
-
- $default reduce using rule 185 (module_fields)
-
-
-State 15
-
- 186 module_fields: module_fields . module_field
- 188 inline_module: module_fields .
-
- "(" shift, and go to state 48
-
- $default reduce using rule 188 (inline_module)
-
- exception go to state 2
- exception_field go to state 3
- func go to state 4
- elem go to state 5
- table go to state 6
- data go to state 7
- memory go to state 8
- global go to state 9
- import go to state 10
- export go to state 11
- type_def go to state 12
- start go to state 13
- module_field go to state 49
-
-
-State 16
-
- 207 cmd: module .
-
- $default reduce using rule 207 (cmd)
-
-
-State 17
-
- 216 script: inline_module .
-
- $default reduce using rule 216 (script)
-
-
-State 18
-
- 187 module: script_module .
-
- $default reduce using rule 187 (module)
-
-
-State 19
-
- 205 cmd: action .
-
- $default reduce using rule 205 (cmd)
-
-
-State 20
-
- 206 cmd: assertion .
-
- $default reduce using rule 206 (cmd)
-
-
-State 21
-
- 209 cmd_list: cmd .
-
- $default reduce using rule 209 (cmd_list)
-
-
-State 22
-
- 210 cmd_list: cmd_list . cmd
- 215 script: cmd_list .
-
- "(" shift, and go to state 50
-
- $default reduce using rule 215 (script)
-
- module go to state 16
- script_module go to state 18
- action go to state 19
- assertion go to state 20
- cmd go to state 51
-
-
-State 23
-
- 217 script_start: script .
-
- $default reduce using rule 217 (script_start)
-
-
-State 24
-
- 0 $accept: script_start . "EOF"
-
- "EOF" shift, and go to state 52
-
-
-State 25
-
- 112 func: "(" FUNC . bind_var_opt func_fields ")"
-
- VAR shift, and go to state 53
-
- $default reduce using rule 30 (bind_var_opt)
-
- bind_var_opt go to state 54
- bind_var go to state 55
-
-
-State 26
-
- 171 start: "(" START . var ")"
-
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 59
-
-
-State 27
-
- 169 type_def: "(" TYPE . func_type ")"
- 170 | "(" TYPE . bind_var func_type ")"
-
- "(" shift, and go to state 60
- VAR shift, and go to state 53
-
- func_type go to state 61
- bind_var go to state 62
-
-
-State 28
-
- 150 global: "(" GLOBAL . bind_var_opt global_fields ")"
-
- VAR shift, and go to state 53
-
- $default reduce using rule 30 (bind_var_opt)
-
- bind_var_opt go to state 63
- bind_var go to state 55
-
-
-State 29
-
- 138 table: "(" TABLE . bind_var_opt table_fields ")"
-
- VAR shift, and go to state 53
-
- $default reduce using rule 30 (bind_var_opt)
-
- bind_var_opt go to state 64
- bind_var go to state 55
-
-
-State 30
-
- 136 elem: "(" ELEM . var offset var_list ")"
- 137 | "(" ELEM . offset var_list ")"
-
- "(" shift, and go to state 65
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 66
- expr go to state 67
- offset go to state 68
-
-
-State 31
-
- 145 memory: "(" MEMORY . bind_var_opt memory_fields ")"
-
- VAR shift, and go to state 53
-
- $default reduce using rule 30 (bind_var_opt)
-
- bind_var_opt go to state 69
- bind_var go to state 55
-
-
-State 32
-
- 143 data: "(" DATA . var offset text_list_opt ")"
- 144 | "(" DATA . offset text_list_opt ")"
-
- "(" shift, and go to state 65
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 70
- expr go to state 67
- offset go to state 71
-
-
-State 33
-
- 160 import: "(" IMPORT . quoted_text quoted_text import_desc ")"
-
- TEXT shift, and go to state 72
-
- quoted_text go to state 73
-
-
-State 34
-
- 167 export: "(" EXPORT . quoted_text export_desc ")"
-
- TEXT shift, and go to state 72
-
- quoted_text go to state 74
-
-
-State 35
-
- 110 exception: "(" EXCEPT . bind_var_opt value_type_list ")"
-
- VAR shift, and go to state 53
-
- $default reduce using rule 30 (bind_var_opt)
-
- bind_var_opt go to state 75
- bind_var go to state 55
-
-
-State 36
-
- 191 script_module: "(" MODULE . bind_var_opt module_fields_opt ")"
- 192 | "(" MODULE . bind_var_opt BIN text_list ")"
- 193 | "(" MODULE . bind_var_opt QUOTE text_list ")"
-
- VAR shift, and go to state 53
-
- $default reduce using rule 30 (bind_var_opt)
-
- bind_var_opt go to state 76
- bind_var go to state 55
-
-
-State 37
-
- 208 cmd: "(" REGISTER . quoted_text script_var_opt ")"
-
- TEXT shift, and go to state 72
-
- quoted_text go to state 77
-
-
-State 38
-
- 194 action: "(" INVOKE . script_var_opt quoted_text const_list ")"
-
- VAR shift, and go to state 78
-
- $default reduce using rule 189 (script_var_opt)
-
- script_var_opt go to state 79
-
-
-State 39
-
- 195 action: "(" GET . script_var_opt quoted_text ")"
-
- VAR shift, and go to state 78
-
- $default reduce using rule 189 (script_var_opt)
-
- script_var_opt go to state 80
-
-
-State 40
-
- 196 assertion: "(" ASSERT_MALFORMED . script_module quoted_text ")"
-
- "(" shift, and go to state 81
-
- script_module go to state 82
-
-
-State 41
-
- 197 assertion: "(" ASSERT_INVALID . script_module quoted_text ")"
-
- "(" shift, and go to state 81
-
- script_module go to state 83
-
-
-State 42
-
- 198 assertion: "(" ASSERT_UNLINKABLE . script_module quoted_text ")"
-
- "(" shift, and go to state 81
-
- script_module go to state 84
-
-
-State 43
-
- 200 assertion: "(" ASSERT_RETURN . action const_list ")"
-
- "(" shift, and go to state 85
-
- action go to state 86
-
-
-State 44
-
- 201 assertion: "(" ASSERT_RETURN_CANONICAL_NAN . action ")"
-
- "(" shift, and go to state 85
-
- action go to state 87
-
-
-State 45
-
- 202 assertion: "(" ASSERT_RETURN_ARITHMETIC_NAN . action ")"
-
- "(" shift, and go to state 85
-
- action go to state 88
-
-
-State 46
-
- 199 assertion: "(" ASSERT_TRAP . script_module quoted_text ")"
- 203 | "(" ASSERT_TRAP . action quoted_text ")"
-
- "(" shift, and go to state 89
-
- script_module go to state 90
- action go to state 91
-
-
-State 47
-
- 204 assertion: "(" ASSERT_EXHAUSTION . action quoted_text ")"
-
- "(" shift, and go to state 85
-
- action go to state 92
-
-
-State 48
-
- 110 exception: "(" . EXCEPT bind_var_opt value_type_list ")"
- 112 func: "(" . FUNC bind_var_opt func_fields ")"
- 136 elem: "(" . ELEM var offset var_list ")"
- 137 | "(" . ELEM offset var_list ")"
- 138 table: "(" . TABLE bind_var_opt table_fields ")"
- 143 data: "(" . DATA var offset text_list_opt ")"
- 144 | "(" . DATA offset text_list_opt ")"
- 145 memory: "(" . MEMORY bind_var_opt memory_fields ")"
- 150 global: "(" . GLOBAL bind_var_opt global_fields ")"
- 160 import: "(" . IMPORT quoted_text quoted_text import_desc ")"
- 167 export: "(" . EXPORT quoted_text export_desc ")"
- 169 type_def: "(" . TYPE func_type ")"
- 170 | "(" . TYPE bind_var func_type ")"
- 171 start: "(" . START var ")"
-
- FUNC shift, and go to state 25
- START shift, and go to state 26
- TYPE shift, and go to state 27
- GLOBAL shift, and go to state 28
- TABLE shift, and go to state 29
- ELEM shift, and go to state 30
- MEMORY shift, and go to state 31
- DATA shift, and go to state 32
- IMPORT shift, and go to state 33
- EXPORT shift, and go to state 34
- EXCEPT shift, and go to state 35
-
-
-State 49
-
- 186 module_fields: module_fields module_field .
-
- $default reduce using rule 186 (module_fields)
-
-
-State 50
-
- 191 script_module: "(" . MODULE bind_var_opt module_fields_opt ")"
- 192 | "(" . MODULE bind_var_opt BIN text_list ")"
- 193 | "(" . MODULE bind_var_opt QUOTE text_list ")"
- 194 action: "(" . INVOKE script_var_opt quoted_text const_list ")"
- 195 | "(" . GET script_var_opt quoted_text ")"
- 196 assertion: "(" . ASSERT_MALFORMED script_module quoted_text ")"
- 197 | "(" . ASSERT_INVALID script_module quoted_text ")"
- 198 | "(" . ASSERT_UNLINKABLE script_module quoted_text ")"
- 199 | "(" . ASSERT_TRAP script_module quoted_text ")"
- 200 | "(" . ASSERT_RETURN action const_list ")"
- 201 | "(" . ASSERT_RETURN_CANONICAL_NAN action ")"
- 202 | "(" . ASSERT_RETURN_ARITHMETIC_NAN action ")"
- 203 | "(" . ASSERT_TRAP action quoted_text ")"
- 204 | "(" . ASSERT_EXHAUSTION action quoted_text ")"
- 208 cmd: "(" . REGISTER quoted_text script_var_opt ")"
-
- MODULE shift, and go to state 36
- REGISTER shift, and go to state 37
- INVOKE shift, and go to state 38
- GET shift, and go to state 39
- ASSERT_MALFORMED shift, and go to state 40
- ASSERT_INVALID shift, and go to state 41
- ASSERT_UNLINKABLE shift, and go to state 42
- ASSERT_RETURN shift, and go to state 43
- ASSERT_RETURN_CANONICAL_NAN shift, and go to state 44
- ASSERT_RETURN_ARITHMETIC_NAN shift, and go to state 45
- ASSERT_TRAP shift, and go to state 46
- ASSERT_EXHAUSTION shift, and go to state 47
-
-
-State 51
-
- 210 cmd_list: cmd_list cmd .
-
- $default reduce using rule 210 (cmd_list)
-
-
-State 52
-
- 0 $accept: script_start "EOF" .
-
- $default accept
-
-
-State 53
-
- 32 bind_var: VAR .
-
- $default reduce using rule 32 (bind_var)
-
-
-State 54
-
- 112 func: "(" FUNC bind_var_opt . func_fields ")"
-
- "(" shift, and go to state 93
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- type_use go to state 124
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 132
- func_fields go to state 133
- func_fields_body go to state 134
- func_fields_body1 go to state 135
- func_result_body go to state 136
- func_body go to state 137
- func_body1 go to state 138
- inline_import go to state 139
- inline_export go to state 140
-
-
-State 55
-
- 31 bind_var_opt: bind_var .
-
- $default reduce using rule 31 (bind_var_opt)
-
-
-State 56
-
- 22 nat: NAT .
-
- $default reduce using rule 22 (nat)
-
-
-State 57
-
- 27 var: VAR .
-
- $default reduce using rule 27 (var)
-
-
-State 58
-
- 26 var: nat .
-
- $default reduce using rule 26 (var)
-
-
-State 59
-
- 171 start: "(" START var . ")"
-
- ")" shift, and go to state 141
-
-
-State 60
-
- 11 func_type: "(" . FUNC func_sig ")"
-
- FUNC shift, and go to state 142
-
-
-State 61
-
- 169 type_def: "(" TYPE func_type . ")"
-
- ")" shift, and go to state 143
-
-
-State 62
-
- 170 type_def: "(" TYPE bind_var . func_type ")"
-
- "(" shift, and go to state 60
-
- func_type go to state 144
-
-
-State 63
-
- 150 global: "(" GLOBAL bind_var_opt . global_fields ")"
-
- "(" shift, and go to state 145
- VALUE_TYPE shift, and go to state 146
-
- global_type go to state 147
- global_fields go to state 148
- inline_import go to state 149
- inline_export go to state 150
-
-
-State 64
-
- 138 table: "(" TABLE bind_var_opt . table_fields ")"
-
- "(" shift, and go to state 151
- NAT shift, and go to state 56
- ANYFUNC shift, and go to state 152
-
- elem_type go to state 153
- table_sig go to state 154
- limits go to state 155
- nat go to state 156
- table_fields go to state 157
- inline_import go to state 158
- inline_export go to state 159
-
-
-State 65
-
- 82 expr: "(" . expr1 ")"
- 134 offset: "(" . OFFSET const_expr ")"
-
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 160
- IF shift, and go to state 161
- LOOP shift, and go to state 162
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
- OFFSET shift, and go to state 163
-
- plain_instr go to state 164
- expr1 go to state 165
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 166
-
-
-State 66
-
- 136 elem: "(" ELEM var . offset var_list ")"
-
- "(" shift, and go to state 65
-
- expr go to state 67
- offset go to state 167
-
-
-State 67
-
- 135 offset: expr .
-
- $default reduce using rule 135 (offset)
-
-
-State 68
-
- 137 elem: "(" ELEM offset . var_list ")"
-
- $default reduce using rule 28 (var_list)
-
- var_list go to state 168
-
-
-State 69
-
- 145 memory: "(" MEMORY bind_var_opt . memory_fields ")"
-
- "(" shift, and go to state 169
- NAT shift, and go to state 56
-
- memory_sig go to state 170
- limits go to state 171
- nat go to state 156
- memory_fields go to state 172
- inline_import go to state 173
- inline_export go to state 174
-
-
-State 70
-
- 143 data: "(" DATA var . offset text_list_opt ")"
-
- "(" shift, and go to state 65
-
- expr go to state 67
- offset go to state 175
-
-
-State 71
-
- 144 data: "(" DATA offset . text_list_opt ")"
-
- TEXT shift, and go to state 176
-
- $default reduce using rule 3 (text_list_opt)
-
- text_list go to state 177
- text_list_opt go to state 178
-
-
-State 72
-
- 5 quoted_text: TEXT .
-
- $default reduce using rule 5 (quoted_text)
-
-
-State 73
-
- 160 import: "(" IMPORT quoted_text . quoted_text import_desc ")"
-
- TEXT shift, and go to state 72
-
- quoted_text go to state 179
-
-
-State 74
-
- 167 export: "(" EXPORT quoted_text . export_desc ")"
-
- "(" shift, and go to state 180
-
- export_desc go to state 181
-
-
-State 75
-
- 110 exception: "(" EXCEPT bind_var_opt . value_type_list ")"
-
- $default reduce using rule 6 (value_type_list)
-
- value_type_list go to state 182
-
-
-State 76
-
- 191 script_module: "(" MODULE bind_var_opt . module_fields_opt ")"
- 192 | "(" MODULE bind_var_opt . BIN text_list ")"
- 193 | "(" MODULE bind_var_opt . QUOTE text_list ")"
-
- "(" shift, and go to state 48
- BIN shift, and go to state 183
- QUOTE shift, and go to state 184
-
- $default reduce using rule 183 (module_fields_opt)
-
- exception go to state 2
- exception_field go to state 3
- func go to state 4
- elem go to state 5
- table go to state 6
- data go to state 7
- memory go to state 8
- global go to state 9
- import go to state 10
- export go to state 11
- type_def go to state 12
- start go to state 13
- module_field go to state 14
- module_fields_opt go to state 185
- module_fields go to state 186
-
-
-State 77
-
- 208 cmd: "(" REGISTER quoted_text . script_var_opt ")"
-
- VAR shift, and go to state 78
-
- $default reduce using rule 189 (script_var_opt)
-
- script_var_opt go to state 187
-
-
-State 78
-
- 190 script_var_opt: VAR .
-
- $default reduce using rule 190 (script_var_opt)
-
-
-State 79
-
- 194 action: "(" INVOKE script_var_opt . quoted_text const_list ")"
-
- TEXT shift, and go to state 72
-
- quoted_text go to state 188
-
-
-State 80
-
- 195 action: "(" GET script_var_opt . quoted_text ")"
-
- TEXT shift, and go to state 72
-
- quoted_text go to state 189
-
-
-State 81
-
- 191 script_module: "(" . MODULE bind_var_opt module_fields_opt ")"
- 192 | "(" . MODULE bind_var_opt BIN text_list ")"
- 193 | "(" . MODULE bind_var_opt QUOTE text_list ")"
-
- MODULE shift, and go to state 36
-
-
-State 82
-
- 196 assertion: "(" ASSERT_MALFORMED script_module . quoted_text ")"
-
- TEXT shift, and go to state 72
-
- quoted_text go to state 190
-
-
-State 83
-
- 197 assertion: "(" ASSERT_INVALID script_module . quoted_text ")"
-
- TEXT shift, and go to state 72
-
- quoted_text go to state 191
-
-
-State 84
-
- 198 assertion: "(" ASSERT_UNLINKABLE script_module . quoted_text ")"
-
- TEXT shift, and go to state 72
-
- quoted_text go to state 192
-
-
-State 85
-
- 194 action: "(" . INVOKE script_var_opt quoted_text const_list ")"
- 195 | "(" . GET script_var_opt quoted_text ")"
-
- INVOKE shift, and go to state 38
- GET shift, and go to state 39
-
-
-State 86
-
- 200 assertion: "(" ASSERT_RETURN action . const_list ")"
-
- $default reduce using rule 212 (const_list)
-
- const_list go to state 193
-
-
-State 87
-
- 201 assertion: "(" ASSERT_RETURN_CANONICAL_NAN action . ")"
-
- ")" shift, and go to state 194
-
-
-State 88
-
- 202 assertion: "(" ASSERT_RETURN_ARITHMETIC_NAN action . ")"
-
- ")" shift, and go to state 195
-
-
-State 89
-
- 191 script_module: "(" . MODULE bind_var_opt module_fields_opt ")"
- 192 | "(" . MODULE bind_var_opt BIN text_list ")"
- 193 | "(" . MODULE bind_var_opt QUOTE text_list ")"
- 194 action: "(" . INVOKE script_var_opt quoted_text const_list ")"
- 195 | "(" . GET script_var_opt quoted_text ")"
-
- MODULE shift, and go to state 36
- INVOKE shift, and go to state 38
- GET shift, and go to state 39
-
-
-State 90
-
- 199 assertion: "(" ASSERT_TRAP script_module . quoted_text ")"
-
- TEXT shift, and go to state 72
-
- quoted_text go to state 196
-
-
-State 91
-
- 203 assertion: "(" ASSERT_TRAP action . quoted_text ")"
-
- TEXT shift, and go to state 72
-
- quoted_text go to state 197
-
-
-State 92
-
- 204 assertion: "(" ASSERT_EXHAUSTION action . quoted_text ")"
-
- TEXT shift, and go to state 72
-
- quoted_text go to state 198
-
-
-State 93
-
- 21 type_use: "(" . TYPE var ")"
- 82 expr: "(" . expr1 ")"
- 126 func_fields_body1: "(" . PARAM value_type_list ")" func_fields_body1
- 127 | "(" . PARAM bind_var VALUE_TYPE ")" func_fields_body1
- 129 func_result_body: "(" . RESULT value_type_list ")" func_result_body
- 132 func_body1: "(" . LOCAL value_type_list ")" func_body1
- 133 | "(" . LOCAL bind_var VALUE_TYPE ")" func_body1
- 161 inline_import: "(" . IMPORT quoted_text quoted_text ")"
- 168 inline_export: "(" . EXPORT quoted_text ")"
-
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 160
- IF shift, and go to state 161
- LOOP shift, and go to state 162
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
- TYPE shift, and go to state 199
- PARAM shift, and go to state 200
- RESULT shift, and go to state 201
- LOCAL shift, and go to state 202
- IMPORT shift, and go to state 203
- EXPORT shift, and go to state 204
-
- plain_instr go to state 164
- expr1 go to state 165
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 166
-
-
-State 94
-
- 43 plain_instr: NOP .
-
- $default reduce using rule 43 (plain_instr)
-
-
-State 95
-
- 44 plain_instr: DROP .
-
- $default reduce using rule 44 (plain_instr)
-
-
-State 96
-
- 68 block_instr: BLOCK . labeling_opt block END labeling_opt
-
- VAR shift, and go to state 53
-
- $default reduce using rule 33 (labeling_opt)
-
- bind_var go to state 205
- labeling_opt go to state 206
-
-
-State 97
-
- 70 block_instr: IF . labeling_opt block END labeling_opt
- 71 | IF . labeling_opt block ELSE labeling_opt instr_list END labeling_opt
-
- VAR shift, and go to state 53
-
- $default reduce using rule 33 (labeling_opt)
-
- bind_var go to state 205
- labeling_opt go to state 207
-
-
-State 98
-
- 69 block_instr: LOOP . labeling_opt block END labeling_opt
-
- VAR shift, and go to state 53
-
- $default reduce using rule 33 (labeling_opt)
-
- bind_var go to state 205
- labeling_opt go to state 208
-
-
-State 99
-
- 46 plain_instr: BR . var
-
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 209
-
-
-State 100
-
- 47 plain_instr: BR_IF . var
-
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 210
-
-
-State 101
-
- 48 plain_instr: BR_TABLE . var_list var
-
- $default reduce using rule 28 (var_list)
-
- var_list go to state 211
-
-
-State 102
-
- 104 try_check: TRY .
-
- $default reduce using rule 104 (try_check)
-
-
-State 103
-
- 103 throw_check: THROW .
-
- $default reduce using rule 103 (throw_check)
-
-
-State 104
-
- 102 rethrow_check: RETHROW .
-
- $default reduce using rule 102 (rethrow_check)
-
-
-State 105
-
- 50 plain_instr: CALL . var
-
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 212
-
-
-State 106
-
- 51 plain_instr: CALL_INDIRECT . var
-
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 213
-
-
-State 107
-
- 49 plain_instr: RETURN .
-
- $default reduce using rule 49 (plain_instr)
-
-
-State 108
-
- 52 plain_instr: GET_LOCAL . var
-
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 214
-
-
-State 109
-
- 53 plain_instr: SET_LOCAL . var
-
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 215
-
-
-State 110
-
- 54 plain_instr: TEE_LOCAL . var
-
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 216
-
-
-State 111
-
- 55 plain_instr: GET_GLOBAL . var
-
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 217
-
-
-State 112
-
- 56 plain_instr: SET_GLOBAL . var
-
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 218
-
-
-State 113
-
- 57 plain_instr: LOAD . offset_opt align_opt
-
- OFFSET_EQ_NAT shift, and go to state 219
-
- $default reduce using rule 35 (offset_opt)
-
- offset_opt go to state 220
-
-
-State 114
-
- 58 plain_instr: STORE . offset_opt align_opt
-
- OFFSET_EQ_NAT shift, and go to state 219
-
- $default reduce using rule 35 (offset_opt)
-
- offset_opt go to state 221
-
-
-State 115
-
- 59 plain_instr: CONST . literal
-
- NAT shift, and go to state 222
- INT shift, and go to state 223
- FLOAT shift, and go to state 224
-
- literal go to state 225
-
-
-State 116
-
- 60 plain_instr: UNARY .
-
- $default reduce using rule 60 (plain_instr)
-
-
-State 117
-
- 61 plain_instr: BINARY .
-
- $default reduce using rule 61 (plain_instr)
-
-
-State 118
-
- 62 plain_instr: COMPARE .
-
- $default reduce using rule 62 (plain_instr)
-
-
-State 119
-
- 63 plain_instr: CONVERT .
-
- $default reduce using rule 63 (plain_instr)
-
-
-State 120
-
- 45 plain_instr: SELECT .
-
- $default reduce using rule 45 (plain_instr)
-
-
-State 121
-
- 42 plain_instr: UNREACHABLE .
-
- $default reduce using rule 42 (plain_instr)
-
-
-State 122
-
- 64 plain_instr: CURRENT_MEMORY .
-
- $default reduce using rule 64 (plain_instr)
-
-
-State 123
-
- 65 plain_instr: GROW_MEMORY .
-
- $default reduce using rule 65 (plain_instr)
-
-
-State 124
-
- 113 func_fields: type_use . func_fields_body
-
- "(" shift, and go to state 226
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 132
- func_fields_body go to state 227
- func_fields_body1 go to state 135
- func_result_body go to state 136
- func_body go to state 137
- func_body1 go to state 138
-
-
-State 125
-
- 106 instr_list: instr . instr_list
-
- "(" shift, and go to state 228
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 229
-
-
-State 126
-
- 39 instr: plain_instr .
-
- $default reduce using rule 39 (instr)
-
-
-State 127
-
- 40 instr: block_instr .
-
- $default reduce using rule 40 (instr)
-
-
-State 128
-
- 41 instr: expr .
-
- $default reduce using rule 41 (instr)
-
-
-State 129
-
- 67 plain_instr: rethrow_check . var
-
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 230
-
-
-State 130
-
- 66 plain_instr: throw_check . var
-
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 231
-
-
-State 131
-
- 72 block_instr: try_check . labeling_opt block catch_instr_list END labeling_opt
-
- VAR shift, and go to state 53
-
- $default reduce using rule 33 (labeling_opt)
-
- bind_var go to state 205
- labeling_opt go to state 232
-
-
-State 132
-
- 131 func_body1: instr_list .
-
- $default reduce using rule 131 (func_body1)
-
-
-State 133
-
- 112 func: "(" FUNC bind_var_opt func_fields . ")"
-
- ")" shift, and go to state 233
-
-
-State 134
-
- 114 func_fields: func_fields_body .
-
- $default reduce using rule 114 (func_fields)
-
-
-State 135
-
- 124 func_fields_body: func_fields_body1 .
-
- $default reduce using rule 124 (func_fields_body)
-
-
-State 136
-
- 125 func_fields_body1: func_result_body .
-
- $default reduce using rule 125 (func_fields_body1)
-
-
-State 137
-
- 128 func_result_body: func_body .
-
- $default reduce using rule 128 (func_result_body)
-
-
-State 138
-
- 130 func_body: func_body1 .
-
- $default reduce using rule 130 (func_body)
-
-
-State 139
-
- 115 func_fields: inline_import . type_use func_fields_import
- 116 | inline_import . func_fields_import
-
- "(" shift, and go to state 234
-
- $default reduce using rule 122 (func_fields_import_result)
-
- type_use go to state 235
- func_fields_import go to state 236
- func_fields_import1 go to state 237
- func_fields_import_result go to state 238
-
-
-State 140
-
- 117 func_fields: inline_export . func_fields
-
- "(" shift, and go to state 93
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- type_use go to state 124
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 132
- func_fields go to state 239
- func_fields_body go to state 134
- func_fields_body1 go to state 135
- func_result_body go to state 136
- func_body go to state 137
- func_body1 go to state 138
- inline_import go to state 139
- inline_export go to state 140
-
-
-State 141
-
- 171 start: "(" START var ")" .
-
- $default reduce using rule 171 (start)
-
-
-State 142
-
- 11 func_type: "(" FUNC . func_sig ")"
-
- "(" shift, and go to state 240
-
- $default reduce using rule 15 (func_sig_result)
-
- func_sig go to state 241
- func_sig_result go to state 242
-
-
-State 143
-
- 169 type_def: "(" TYPE func_type ")" .
-
- $default reduce using rule 169 (type_def)
-
-
-State 144
-
- 170 type_def: "(" TYPE bind_var func_type . ")"
-
- ")" shift, and go to state 243
-
-
-State 145
-
- 10 global_type: "(" . MUT VALUE_TYPE ")"
- 161 inline_import: "(" . IMPORT quoted_text quoted_text ")"
- 168 inline_export: "(" . EXPORT quoted_text ")"
-
- MUT shift, and go to state 244
- IMPORT shift, and go to state 203
- EXPORT shift, and go to state 204
-
-
-State 146
-
- 9 global_type: VALUE_TYPE .
-
- $default reduce using rule 9 (global_type)
-
-
-State 147
-
- 151 global_fields: global_type . const_expr
-
- "(" shift, and go to state 228
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 245
- const_expr go to state 246
-
-
-State 148
-
- 150 global: "(" GLOBAL bind_var_opt global_fields . ")"
-
- ")" shift, and go to state 247
-
-
-State 149
-
- 152 global_fields: inline_import . global_type
-
- "(" shift, and go to state 248
- VALUE_TYPE shift, and go to state 146
-
- global_type go to state 249
-
-
-State 150
-
- 153 global_fields: inline_export . global_fields
-
- "(" shift, and go to state 145
- VALUE_TYPE shift, and go to state 146
-
- global_type go to state 147
- global_fields go to state 250
- inline_import go to state 149
- inline_export go to state 150
-
-
-State 151
-
- 161 inline_import: "(" . IMPORT quoted_text quoted_text ")"
- 168 inline_export: "(" . EXPORT quoted_text ")"
-
- IMPORT shift, and go to state 203
- EXPORT shift, and go to state 204
-
-
-State 152
-
- 8 elem_type: ANYFUNC .
-
- $default reduce using rule 8 (elem_type)
-
-
-State 153
-
- 142 table_fields: elem_type . "(" ELEM var_list ")"
-
- "(" shift, and go to state 251
-
-
-State 154
-
- 139 table_fields: table_sig .
-
- $default reduce using rule 139 (table_fields)
-
-
-State 155
-
- 17 table_sig: limits . elem_type
-
- ANYFUNC shift, and go to state 152
-
- elem_type go to state 252
-
-
-State 156
-
- 19 limits: nat .
- 20 | nat . nat
-
- NAT shift, and go to state 56
-
- $default reduce using rule 19 (limits)
-
- nat go to state 253
-
-
-State 157
-
- 138 table: "(" TABLE bind_var_opt table_fields . ")"
-
- ")" shift, and go to state 254
-
-
-State 158
-
- 140 table_fields: inline_import . table_sig
-
- NAT shift, and go to state 56
-
- table_sig go to state 255
- limits go to state 155
- nat go to state 156
-
-
-State 159
-
- 141 table_fields: inline_export . table_fields
-
- "(" shift, and go to state 151
- NAT shift, and go to state 56
- ANYFUNC shift, and go to state 152
-
- elem_type go to state 153
- table_sig go to state 154
- limits go to state 155
- nat go to state 156
- table_fields go to state 256
- inline_import go to state 158
- inline_export go to state 159
-
-
-State 160
-
- 84 expr1: BLOCK . labeling_opt block
-
- VAR shift, and go to state 53
-
- $default reduce using rule 33 (labeling_opt)
-
- bind_var go to state 205
- labeling_opt go to state 257
-
-
-State 161
-
- 86 expr1: IF . labeling_opt if_block
-
- VAR shift, and go to state 53
-
- $default reduce using rule 33 (labeling_opt)
-
- bind_var go to state 205
- labeling_opt go to state 258
-
-
-State 162
-
- 85 expr1: LOOP . labeling_opt block
-
- VAR shift, and go to state 53
-
- $default reduce using rule 33 (labeling_opt)
-
- bind_var go to state 205
- labeling_opt go to state 259
-
-
-State 163
-
- 134 offset: "(" OFFSET . const_expr ")"
-
- "(" shift, and go to state 228
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 245
- const_expr go to state 260
-
-
-State 164
-
- 83 expr1: plain_instr . expr_list
-
- "(" shift, and go to state 228
-
- $default reduce using rule 107 (expr_list)
-
- expr go to state 261
- expr_list go to state 262
-
-
-State 165
-
- 82 expr: "(" expr1 . ")"
-
- ")" shift, and go to state 263
-
-
-State 166
-
- 87 expr1: try_check . labeling_opt try_
-
- VAR shift, and go to state 53
-
- $default reduce using rule 33 (labeling_opt)
-
- bind_var go to state 205
- labeling_opt go to state 264
-
-
-State 167
-
- 136 elem: "(" ELEM var offset . var_list ")"
-
- $default reduce using rule 28 (var_list)
-
- var_list go to state 265
-
-
-State 168
-
- 29 var_list: var_list . var
- 137 elem: "(" ELEM offset var_list . ")"
-
- ")" shift, and go to state 266
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 267
-
-
-State 169
-
- 149 memory_fields: "(" . DATA text_list_opt ")"
- 161 inline_import: "(" . IMPORT quoted_text quoted_text ")"
- 168 inline_export: "(" . EXPORT quoted_text ")"
-
- DATA shift, and go to state 268
- IMPORT shift, and go to state 203
- EXPORT shift, and go to state 204
-
-
-State 170
-
- 146 memory_fields: memory_sig .
-
- $default reduce using rule 146 (memory_fields)
-
-
-State 171
-
- 18 memory_sig: limits .
-
- $default reduce using rule 18 (memory_sig)
-
-
-State 172
-
- 145 memory: "(" MEMORY bind_var_opt memory_fields . ")"
-
- ")" shift, and go to state 269
-
-
-State 173
-
- 147 memory_fields: inline_import . memory_sig
-
- NAT shift, and go to state 56
-
- memory_sig go to state 270
- limits go to state 171
- nat go to state 156
-
-
-State 174
-
- 148 memory_fields: inline_export . memory_fields
-
- "(" shift, and go to state 169
- NAT shift, and go to state 56
-
- memory_sig go to state 170
- limits go to state 171
- nat go to state 156
- memory_fields go to state 271
- inline_import go to state 173
- inline_export go to state 174
-
-
-State 175
-
- 143 data: "(" DATA var offset . text_list_opt ")"
-
- TEXT shift, and go to state 176
-
- $default reduce using rule 3 (text_list_opt)
-
- text_list go to state 177
- text_list_opt go to state 272
-
-
-State 176
-
- 1 text_list: TEXT .
-
- $default reduce using rule 1 (text_list)
-
-
-State 177
-
- 2 text_list: text_list . TEXT
- 4 text_list_opt: text_list .
-
- TEXT shift, and go to state 273
-
- $default reduce using rule 4 (text_list_opt)
-
-
-State 178
-
- 144 data: "(" DATA offset text_list_opt . ")"
-
- ")" shift, and go to state 274
-
-
-State 179
-
- 160 import: "(" IMPORT quoted_text quoted_text . import_desc ")"
-
- "(" shift, and go to state 275
-
- exception go to state 276
- import_desc go to state 277
-
-
-State 180
-
- 162 export_desc: "(" . FUNC var ")"
- 163 | "(" . TABLE var ")"
- 164 | "(" . MEMORY var ")"
- 165 | "(" . GLOBAL var ")"
- 166 | "(" . EXCEPT var ")"
-
- FUNC shift, and go to state 278
- GLOBAL shift, and go to state 279
- TABLE shift, and go to state 280
- MEMORY shift, and go to state 281
- EXCEPT shift, and go to state 282
-
-
-State 181
-
- 167 export: "(" EXPORT quoted_text export_desc . ")"
-
- ")" shift, and go to state 283
-
-
-State 182
-
- 7 value_type_list: value_type_list . VALUE_TYPE
- 110 exception: "(" EXCEPT bind_var_opt value_type_list . ")"
-
- ")" shift, and go to state 284
- VALUE_TYPE shift, and go to state 285
-
-
-State 183
-
- 192 script_module: "(" MODULE bind_var_opt BIN . text_list ")"
-
- TEXT shift, and go to state 176
-
- text_list go to state 286
-
-
-State 184
-
- 193 script_module: "(" MODULE bind_var_opt QUOTE . text_list ")"
-
- TEXT shift, and go to state 176
-
- text_list go to state 287
-
-
-State 185
-
- 191 script_module: "(" MODULE bind_var_opt module_fields_opt . ")"
-
- ")" shift, and go to state 288
-
-
-State 186
-
- 184 module_fields_opt: module_fields .
- 186 module_fields: module_fields . module_field
-
- "(" shift, and go to state 48
-
- $default reduce using rule 184 (module_fields_opt)
-
- exception go to state 2
- exception_field go to state 3
- func go to state 4
- elem go to state 5
- table go to state 6
- data go to state 7
- memory go to state 8
- global go to state 9
- import go to state 10
- export go to state 11
- type_def go to state 12
- start go to state 13
- module_field go to state 49
-
-
-State 187
-
- 208 cmd: "(" REGISTER quoted_text script_var_opt . ")"
-
- ")" shift, and go to state 289
-
-
-State 188
-
- 194 action: "(" INVOKE script_var_opt quoted_text . const_list ")"
-
- $default reduce using rule 212 (const_list)
-
- const_list go to state 290
-
-
-State 189
-
- 195 action: "(" GET script_var_opt quoted_text . ")"
-
- ")" shift, and go to state 291
-
-
-State 190
-
- 196 assertion: "(" ASSERT_MALFORMED script_module quoted_text . ")"
-
- ")" shift, and go to state 292
-
-
-State 191
-
- 197 assertion: "(" ASSERT_INVALID script_module quoted_text . ")"
-
- ")" shift, and go to state 293
-
-
-State 192
-
- 198 assertion: "(" ASSERT_UNLINKABLE script_module quoted_text . ")"
-
- ")" shift, and go to state 294
-
-
-State 193
-
- 200 assertion: "(" ASSERT_RETURN action const_list . ")"
- 213 const_list: const_list . const
-
- "(" shift, and go to state 295
- ")" shift, and go to state 296
-
- const go to state 297
-
-
-State 194
-
- 201 assertion: "(" ASSERT_RETURN_CANONICAL_NAN action ")" .
-
- $default reduce using rule 201 (assertion)
-
-
-State 195
-
- 202 assertion: "(" ASSERT_RETURN_ARITHMETIC_NAN action ")" .
-
- $default reduce using rule 202 (assertion)
-
-
-State 196
-
- 199 assertion: "(" ASSERT_TRAP script_module quoted_text . ")"
-
- ")" shift, and go to state 298
-
-
-State 197
-
- 203 assertion: "(" ASSERT_TRAP action quoted_text . ")"
-
- ")" shift, and go to state 299
-
-
-State 198
-
- 204 assertion: "(" ASSERT_EXHAUSTION action quoted_text . ")"
-
- ")" shift, and go to state 300
-
-
-State 199
-
- 21 type_use: "(" TYPE . var ")"
-
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 301
-
-
-State 200
-
- 126 func_fields_body1: "(" PARAM . value_type_list ")" func_fields_body1
- 127 | "(" PARAM . bind_var VALUE_TYPE ")" func_fields_body1
-
- VAR shift, and go to state 53
-
- $default reduce using rule 6 (value_type_list)
-
- value_type_list go to state 302
- bind_var go to state 303
-
-
-State 201
-
- 129 func_result_body: "(" RESULT . value_type_list ")" func_result_body
-
- $default reduce using rule 6 (value_type_list)
-
- value_type_list go to state 304
-
-
-State 202
-
- 132 func_body1: "(" LOCAL . value_type_list ")" func_body1
- 133 | "(" LOCAL . bind_var VALUE_TYPE ")" func_body1
-
- VAR shift, and go to state 53
-
- $default reduce using rule 6 (value_type_list)
-
- value_type_list go to state 305
- bind_var go to state 306
-
-
-State 203
-
- 161 inline_import: "(" IMPORT . quoted_text quoted_text ")"
-
- TEXT shift, and go to state 72
-
- quoted_text go to state 307
-
-
-State 204
-
- 168 inline_export: "(" EXPORT . quoted_text ")"
-
- TEXT shift, and go to state 72
-
- quoted_text go to state 308
-
-
-State 205
-
- 34 labeling_opt: bind_var .
-
- $default reduce using rule 34 (labeling_opt)
-
-
-State 206
-
- 68 block_instr: BLOCK labeling_opt . block END labeling_opt
-
- "(" shift, and go to state 309
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- block_sig go to state 310
- block go to state 311
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 312
-
-
-State 207
-
- 70 block_instr: IF labeling_opt . block END labeling_opt
- 71 | IF labeling_opt . block ELSE labeling_opt instr_list END labeling_opt
-
- "(" shift, and go to state 309
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- block_sig go to state 310
- block go to state 313
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 312
-
-
-State 208
-
- 69 block_instr: LOOP labeling_opt . block END labeling_opt
-
- "(" shift, and go to state 309
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- block_sig go to state 310
- block go to state 314
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 312
-
-
-State 209
-
- 46 plain_instr: BR var .
-
- $default reduce using rule 46 (plain_instr)
-
-
-State 210
-
- 47 plain_instr: BR_IF var .
-
- $default reduce using rule 47 (plain_instr)
-
-
-State 211
-
- 29 var_list: var_list . var
- 48 plain_instr: BR_TABLE var_list . var
-
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 315
-
-
-State 212
-
- 50 plain_instr: CALL var .
-
- $default reduce using rule 50 (plain_instr)
-
-
-State 213
-
- 51 plain_instr: CALL_INDIRECT var .
-
- $default reduce using rule 51 (plain_instr)
-
-
-State 214
-
- 52 plain_instr: GET_LOCAL var .
-
- $default reduce using rule 52 (plain_instr)
-
-
-State 215
-
- 53 plain_instr: SET_LOCAL var .
-
- $default reduce using rule 53 (plain_instr)
-
-
-State 216
-
- 54 plain_instr: TEE_LOCAL var .
-
- $default reduce using rule 54 (plain_instr)
-
-
-State 217
-
- 55 plain_instr: GET_GLOBAL var .
-
- $default reduce using rule 55 (plain_instr)
-
-
-State 218
-
- 56 plain_instr: SET_GLOBAL var .
-
- $default reduce using rule 56 (plain_instr)
-
-
-State 219
-
- 36 offset_opt: OFFSET_EQ_NAT .
-
- $default reduce using rule 36 (offset_opt)
-
-
-State 220
-
- 57 plain_instr: LOAD offset_opt . align_opt
-
- ALIGN_EQ_NAT shift, and go to state 316
-
- $default reduce using rule 37 (align_opt)
-
- align_opt go to state 317
-
-
-State 221
-
- 58 plain_instr: STORE offset_opt . align_opt
-
- ALIGN_EQ_NAT shift, and go to state 316
-
- $default reduce using rule 37 (align_opt)
-
- align_opt go to state 318
-
-
-State 222
-
- 23 literal: NAT .
-
- $default reduce using rule 23 (literal)
-
-
-State 223
-
- 24 literal: INT .
-
- $default reduce using rule 24 (literal)
-
-
-State 224
-
- 25 literal: FLOAT .
-
- $default reduce using rule 25 (literal)
-
-
-State 225
-
- 59 plain_instr: CONST literal .
-
- $default reduce using rule 59 (plain_instr)
-
-
-State 226
-
- 82 expr: "(" . expr1 ")"
- 126 func_fields_body1: "(" . PARAM value_type_list ")" func_fields_body1
- 127 | "(" . PARAM bind_var VALUE_TYPE ")" func_fields_body1
- 129 func_result_body: "(" . RESULT value_type_list ")" func_result_body
- 132 func_body1: "(" . LOCAL value_type_list ")" func_body1
- 133 | "(" . LOCAL bind_var VALUE_TYPE ")" func_body1
-
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 160
- IF shift, and go to state 161
- LOOP shift, and go to state 162
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
- PARAM shift, and go to state 200
- RESULT shift, and go to state 201
- LOCAL shift, and go to state 202
-
- plain_instr go to state 164
- expr1 go to state 165
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 166
-
-
-State 227
-
- 113 func_fields: type_use func_fields_body .
-
- $default reduce using rule 113 (func_fields)
-
-
-State 228
-
- 82 expr: "(" . expr1 ")"
-
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 160
- IF shift, and go to state 161
- LOOP shift, and go to state 162
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- plain_instr go to state 164
- expr1 go to state 165
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 166
-
-
-State 229
-
- 106 instr_list: instr instr_list .
-
- $default reduce using rule 106 (instr_list)
-
-
-State 230
-
- 67 plain_instr: rethrow_check var .
-
- $default reduce using rule 67 (plain_instr)
-
-
-State 231
-
- 66 plain_instr: throw_check var .
-
- $default reduce using rule 66 (plain_instr)
-
-
-State 232
-
- 72 block_instr: try_check labeling_opt . block catch_instr_list END labeling_opt
-
- "(" shift, and go to state 309
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- block_sig go to state 310
- block go to state 319
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 312
-
-
-State 233
-
- 112 func: "(" FUNC bind_var_opt func_fields ")" .
-
- $default reduce using rule 112 (func)
-
-
-State 234
-
- 21 type_use: "(" . TYPE var ")"
- 120 func_fields_import1: "(" . PARAM value_type_list ")" func_fields_import1
- 121 | "(" . PARAM bind_var VALUE_TYPE ")" func_fields_import1
- 123 func_fields_import_result: "(" . RESULT value_type_list ")" func_fields_import_result
-
- TYPE shift, and go to state 199
- PARAM shift, and go to state 320
- RESULT shift, and go to state 321
-
-
-State 235
-
- 115 func_fields: inline_import type_use . func_fields_import
-
- "(" shift, and go to state 322
-
- $default reduce using rule 122 (func_fields_import_result)
-
- func_fields_import go to state 323
- func_fields_import1 go to state 237
- func_fields_import_result go to state 238
-
-
-State 236
-
- 116 func_fields: inline_import func_fields_import .
-
- $default reduce using rule 116 (func_fields)
-
-
-State 237
-
- 118 func_fields_import: func_fields_import1 .
-
- $default reduce using rule 118 (func_fields_import)
-
-
-State 238
-
- 119 func_fields_import1: func_fields_import_result .
-
- $default reduce using rule 119 (func_fields_import1)
-
-
-State 239
-
- 117 func_fields: inline_export func_fields .
-
- $default reduce using rule 117 (func_fields)
-
-
-State 240
-
- 13 func_sig: "(" . PARAM value_type_list ")" func_sig
- 14 | "(" . PARAM bind_var VALUE_TYPE ")" func_sig
- 16 func_sig_result: "(" . RESULT value_type_list ")" func_sig_result
-
- PARAM shift, and go to state 324
- RESULT shift, and go to state 325
-
-
-State 241
-
- 11 func_type: "(" FUNC func_sig . ")"
-
- ")" shift, and go to state 326
-
-
-State 242
-
- 12 func_sig: func_sig_result .
-
- $default reduce using rule 12 (func_sig)
-
-
-State 243
-
- 170 type_def: "(" TYPE bind_var func_type ")" .
-
- $default reduce using rule 170 (type_def)
-
-
-State 244
-
- 10 global_type: "(" MUT . VALUE_TYPE ")"
-
- VALUE_TYPE shift, and go to state 327
-
-
-State 245
-
- 109 const_expr: instr_list .
-
- $default reduce using rule 109 (const_expr)
-
-
-State 246
-
- 151 global_fields: global_type const_expr .
-
- $default reduce using rule 151 (global_fields)
-
-
-State 247
-
- 150 global: "(" GLOBAL bind_var_opt global_fields ")" .
-
- $default reduce using rule 150 (global)
-
-
-State 248
-
- 10 global_type: "(" . MUT VALUE_TYPE ")"
-
- MUT shift, and go to state 244
-
-
-State 249
-
- 152 global_fields: inline_import global_type .
-
- $default reduce using rule 152 (global_fields)
-
-
-State 250
-
- 153 global_fields: inline_export global_fields .
-
- $default reduce using rule 153 (global_fields)
-
-
-State 251
-
- 142 table_fields: elem_type "(" . ELEM var_list ")"
-
- ELEM shift, and go to state 328
-
-
-State 252
-
- 17 table_sig: limits elem_type .
-
- $default reduce using rule 17 (table_sig)
-
-
-State 253
-
- 20 limits: nat nat .
-
- $default reduce using rule 20 (limits)
-
-
-State 254
-
- 138 table: "(" TABLE bind_var_opt table_fields ")" .
-
- $default reduce using rule 138 (table)
-
-
-State 255
-
- 140 table_fields: inline_import table_sig .
-
- $default reduce using rule 140 (table_fields)
-
-
-State 256
-
- 141 table_fields: inline_export table_fields .
-
- $default reduce using rule 141 (table_fields)
-
-
-State 257
-
- 84 expr1: BLOCK labeling_opt . block
-
- "(" shift, and go to state 309
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- block_sig go to state 310
- block go to state 329
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 312
-
-
-State 258
-
- 86 expr1: IF labeling_opt . if_block
-
- "(" shift, and go to state 330
-
- block_sig go to state 331
- expr go to state 332
- if_block go to state 333
- if_ go to state 334
-
-
-State 259
-
- 85 expr1: LOOP labeling_opt . block
-
- "(" shift, and go to state 309
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- block_sig go to state 310
- block go to state 335
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 312
-
-
-State 260
-
- 134 offset: "(" OFFSET const_expr . ")"
-
- ")" shift, and go to state 336
-
-
-State 261
-
- 108 expr_list: expr . expr_list
-
- "(" shift, and go to state 228
-
- $default reduce using rule 107 (expr_list)
-
- expr go to state 261
- expr_list go to state 337
-
-
-State 262
-
- 83 expr1: plain_instr expr_list .
-
- $default reduce using rule 83 (expr1)
-
-
-State 263
-
- 82 expr: "(" expr1 ")" .
-
- $default reduce using rule 82 (expr)
-
-
-State 264
-
- 87 expr1: try_check labeling_opt . try_
-
- "(" shift, and go to state 309
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- block_sig go to state 338
- expr go to state 128
- try_ go to state 339
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 340
-
-
-State 265
-
- 29 var_list: var_list . var
- 136 elem: "(" ELEM var offset var_list . ")"
-
- ")" shift, and go to state 341
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 267
-
-
-State 266
-
- 137 elem: "(" ELEM offset var_list ")" .
-
- $default reduce using rule 137 (elem)
-
-
-State 267
-
- 29 var_list: var_list var .
-
- $default reduce using rule 29 (var_list)
-
-
-State 268
-
- 149 memory_fields: "(" DATA . text_list_opt ")"
-
- TEXT shift, and go to state 176
-
- $default reduce using rule 3 (text_list_opt)
-
- text_list go to state 177
- text_list_opt go to state 342
-
-
-State 269
-
- 145 memory: "(" MEMORY bind_var_opt memory_fields ")" .
-
- $default reduce using rule 145 (memory)
-
-
-State 270
-
- 147 memory_fields: inline_import memory_sig .
-
- $default reduce using rule 147 (memory_fields)
-
-
-State 271
-
- 148 memory_fields: inline_export memory_fields .
-
- $default reduce using rule 148 (memory_fields)
-
-
-State 272
-
- 143 data: "(" DATA var offset text_list_opt . ")"
-
- ")" shift, and go to state 343
-
-
-State 273
-
- 2 text_list: text_list TEXT .
-
- $default reduce using rule 2 (text_list)
-
-
-State 274
-
- 144 data: "(" DATA offset text_list_opt ")" .
-
- $default reduce using rule 144 (data)
-
-
-State 275
-
- 110 exception: "(" . EXCEPT bind_var_opt value_type_list ")"
- 154 import_desc: "(" . FUNC bind_var_opt type_use ")"
- 155 | "(" . FUNC bind_var_opt func_sig ")"
- 156 | "(" . TABLE bind_var_opt table_sig ")"
- 157 | "(" . MEMORY bind_var_opt memory_sig ")"
- 158 | "(" . GLOBAL bind_var_opt global_type ")"
-
- FUNC shift, and go to state 344
- GLOBAL shift, and go to state 345
- TABLE shift, and go to state 346
- MEMORY shift, and go to state 347
- EXCEPT shift, and go to state 35
-
-
-State 276
-
- 159 import_desc: exception .
-
- $default reduce using rule 159 (import_desc)
-
-
-State 277
-
- 160 import: "(" IMPORT quoted_text quoted_text import_desc . ")"
-
- ")" shift, and go to state 348
-
-
-State 278
-
- 162 export_desc: "(" FUNC . var ")"
-
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 349
-
-
-State 279
-
- 165 export_desc: "(" GLOBAL . var ")"
-
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 350
-
-
-State 280
-
- 163 export_desc: "(" TABLE . var ")"
-
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 351
-
-
-State 281
-
- 164 export_desc: "(" MEMORY . var ")"
-
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 352
-
-
-State 282
-
- 166 export_desc: "(" EXCEPT . var ")"
-
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 353
-
-
-State 283
-
- 167 export: "(" EXPORT quoted_text export_desc ")" .
-
- $default reduce using rule 167 (export)
-
-
-State 284
-
- 110 exception: "(" EXCEPT bind_var_opt value_type_list ")" .
-
- $default reduce using rule 110 (exception)
-
-
-State 285
-
- 7 value_type_list: value_type_list VALUE_TYPE .
-
- $default reduce using rule 7 (value_type_list)
-
-
-State 286
-
- 2 text_list: text_list . TEXT
- 192 script_module: "(" MODULE bind_var_opt BIN text_list . ")"
-
- ")" shift, and go to state 354
- TEXT shift, and go to state 273
-
-
-State 287
-
- 2 text_list: text_list . TEXT
- 193 script_module: "(" MODULE bind_var_opt QUOTE text_list . ")"
-
- ")" shift, and go to state 355
- TEXT shift, and go to state 273
-
-
-State 288
-
- 191 script_module: "(" MODULE bind_var_opt module_fields_opt ")" .
-
- $default reduce using rule 191 (script_module)
-
-
-State 289
-
- 208 cmd: "(" REGISTER quoted_text script_var_opt ")" .
-
- $default reduce using rule 208 (cmd)
-
-
-State 290
-
- 194 action: "(" INVOKE script_var_opt quoted_text const_list . ")"
- 213 const_list: const_list . const
-
- "(" shift, and go to state 295
- ")" shift, and go to state 356
-
- const go to state 297
-
-
-State 291
-
- 195 action: "(" GET script_var_opt quoted_text ")" .
-
- $default reduce using rule 195 (action)
-
-
-State 292
-
- 196 assertion: "(" ASSERT_MALFORMED script_module quoted_text ")" .
-
- $default reduce using rule 196 (assertion)
-
-
-State 293
-
- 197 assertion: "(" ASSERT_INVALID script_module quoted_text ")" .
-
- $default reduce using rule 197 (assertion)
-
-
-State 294
-
- 198 assertion: "(" ASSERT_UNLINKABLE script_module quoted_text ")" .
-
- $default reduce using rule 198 (assertion)
-
-
-State 295
-
- 211 const: "(" . CONST literal ")"
-
- CONST shift, and go to state 357
-
-
-State 296
-
- 200 assertion: "(" ASSERT_RETURN action const_list ")" .
-
- $default reduce using rule 200 (assertion)
-
-
-State 297
-
- 213 const_list: const_list const .
-
- $default reduce using rule 213 (const_list)
-
-
-State 298
-
- 199 assertion: "(" ASSERT_TRAP script_module quoted_text ")" .
-
- $default reduce using rule 199 (assertion)
-
-
-State 299
-
- 203 assertion: "(" ASSERT_TRAP action quoted_text ")" .
-
- $default reduce using rule 203 (assertion)
-
-
-State 300
-
- 204 assertion: "(" ASSERT_EXHAUSTION action quoted_text ")" .
-
- $default reduce using rule 204 (assertion)
-
-
-State 301
-
- 21 type_use: "(" TYPE var . ")"
-
- ")" shift, and go to state 358
-
-
-State 302
-
- 7 value_type_list: value_type_list . VALUE_TYPE
- 126 func_fields_body1: "(" PARAM value_type_list . ")" func_fields_body1
-
- ")" shift, and go to state 359
- VALUE_TYPE shift, and go to state 285
-
-
-State 303
-
- 127 func_fields_body1: "(" PARAM bind_var . VALUE_TYPE ")" func_fields_body1
-
- VALUE_TYPE shift, and go to state 360
-
-
-State 304
-
- 7 value_type_list: value_type_list . VALUE_TYPE
- 129 func_result_body: "(" RESULT value_type_list . ")" func_result_body
-
- ")" shift, and go to state 361
- VALUE_TYPE shift, and go to state 285
-
-
-State 305
-
- 7 value_type_list: value_type_list . VALUE_TYPE
- 132 func_body1: "(" LOCAL value_type_list . ")" func_body1
-
- ")" shift, and go to state 362
- VALUE_TYPE shift, and go to state 285
-
-
-State 306
-
- 133 func_body1: "(" LOCAL bind_var . VALUE_TYPE ")" func_body1
-
- VALUE_TYPE shift, and go to state 363
-
-
-State 307
-
- 161 inline_import: "(" IMPORT quoted_text . quoted_text ")"
-
- TEXT shift, and go to state 72
-
- quoted_text go to state 364
-
-
-State 308
-
- 168 inline_export: "(" EXPORT quoted_text . ")"
-
- ")" shift, and go to state 365
-
-
-State 309
-
- 73 block_sig: "(" . RESULT value_type_list ")"
- 82 expr: "(" . expr1 ")"
-
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 160
- IF shift, and go to state 161
- LOOP shift, and go to state 162
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
- RESULT shift, and go to state 366
-
- plain_instr go to state 164
- expr1 go to state 165
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 166
-
-
-State 310
-
- 74 block: block_sig . block
-
- "(" shift, and go to state 309
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- block_sig go to state 310
- block go to state 367
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 312
-
-
-State 311
-
- 68 block_instr: BLOCK labeling_opt block . END labeling_opt
-
- END shift, and go to state 368
-
-
-State 312
-
- 75 block: instr_list .
-
- $default reduce using rule 75 (block)
-
-
-State 313
-
- 70 block_instr: IF labeling_opt block . END labeling_opt
- 71 | IF labeling_opt block . ELSE labeling_opt instr_list END labeling_opt
-
- END shift, and go to state 369
- ELSE shift, and go to state 370
-
-
-State 314
-
- 69 block_instr: LOOP labeling_opt block . END labeling_opt
-
- END shift, and go to state 371
-
-
-State 315
-
- 29 var_list: var_list var .
- 48 plain_instr: BR_TABLE var_list var .
-
- NAT reduce using rule 29 (var_list)
- VAR reduce using rule 29 (var_list)
- $default reduce using rule 48 (plain_instr)
-
-
-State 316
-
- 38 align_opt: ALIGN_EQ_NAT .
-
- $default reduce using rule 38 (align_opt)
-
-
-State 317
-
- 57 plain_instr: LOAD offset_opt align_opt .
-
- $default reduce using rule 57 (plain_instr)
-
-
-State 318
-
- 58 plain_instr: STORE offset_opt align_opt .
-
- $default reduce using rule 58 (plain_instr)
-
-
-State 319
-
- 72 block_instr: try_check labeling_opt block . catch_instr_list END labeling_opt
-
- CATCH shift, and go to state 372
- CATCH_ALL shift, and go to state 373
-
- plain_catch go to state 374
- plain_catch_all go to state 375
- catch_instr go to state 376
- catch_instr_list go to state 377
-
-
-State 320
-
- 120 func_fields_import1: "(" PARAM . value_type_list ")" func_fields_import1
- 121 | "(" PARAM . bind_var VALUE_TYPE ")" func_fields_import1
-
- VAR shift, and go to state 53
-
- $default reduce using rule 6 (value_type_list)
-
- value_type_list go to state 378
- bind_var go to state 379
-
-
-State 321
-
- 123 func_fields_import_result: "(" RESULT . value_type_list ")" func_fields_import_result
-
- $default reduce using rule 6 (value_type_list)
-
- value_type_list go to state 380
-
-
-State 322
-
- 120 func_fields_import1: "(" . PARAM value_type_list ")" func_fields_import1
- 121 | "(" . PARAM bind_var VALUE_TYPE ")" func_fields_import1
- 123 func_fields_import_result: "(" . RESULT value_type_list ")" func_fields_import_result
-
- PARAM shift, and go to state 320
- RESULT shift, and go to state 321
-
-
-State 323
-
- 115 func_fields: inline_import type_use func_fields_import .
-
- $default reduce using rule 115 (func_fields)
-
-
-State 324
-
- 13 func_sig: "(" PARAM . value_type_list ")" func_sig
- 14 | "(" PARAM . bind_var VALUE_TYPE ")" func_sig
-
- VAR shift, and go to state 53
-
- $default reduce using rule 6 (value_type_list)
-
- value_type_list go to state 381
- bind_var go to state 382
-
-
-State 325
-
- 16 func_sig_result: "(" RESULT . value_type_list ")" func_sig_result
-
- $default reduce using rule 6 (value_type_list)
-
- value_type_list go to state 383
-
-
-State 326
-
- 11 func_type: "(" FUNC func_sig ")" .
-
- $default reduce using rule 11 (func_type)
-
-
-State 327
-
- 10 global_type: "(" MUT VALUE_TYPE . ")"
-
- ")" shift, and go to state 384
-
-
-State 328
-
- 142 table_fields: elem_type "(" ELEM . var_list ")"
-
- $default reduce using rule 28 (var_list)
-
- var_list go to state 385
-
-
-State 329
-
- 84 expr1: BLOCK labeling_opt block .
-
- $default reduce using rule 84 (expr1)
-
-
-State 330
-
- 73 block_sig: "(" . RESULT value_type_list ")"
- 82 expr: "(" . expr1 ")"
- 96 if_: "(" . THEN instr_list ")" "(" ELSE instr_list ")"
- 97 | "(" . THEN instr_list ")"
-
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 160
- IF shift, and go to state 161
- THEN shift, and go to state 386
- LOOP shift, and go to state 162
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
- RESULT shift, and go to state 366
-
- plain_instr go to state 164
- expr1 go to state 165
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 166
-
-
-State 331
-
- 94 if_block: block_sig . if_block
-
- "(" shift, and go to state 330
-
- block_sig go to state 331
- expr go to state 332
- if_block go to state 387
- if_ go to state 334
-
-
-State 332
-
- 98 if_: expr . "(" THEN instr_list ")" "(" ELSE instr_list ")"
- 99 | expr . "(" THEN instr_list ")"
- 100 | expr . expr expr
- 101 | expr . expr
-
- "(" shift, and go to state 388
-
- expr go to state 389
-
-
-State 333
-
- 86 expr1: IF labeling_opt if_block .
-
- $default reduce using rule 86 (expr1)
-
-
-State 334
-
- 95 if_block: if_ .
-
- $default reduce using rule 95 (if_block)
-
-
-State 335
-
- 85 expr1: LOOP labeling_opt block .
-
- $default reduce using rule 85 (expr1)
-
-
-State 336
-
- 134 offset: "(" OFFSET const_expr ")" .
-
- $default reduce using rule 134 (offset)
-
-
-State 337
-
- 108 expr_list: expr expr_list .
-
- $default reduce using rule 108 (expr_list)
-
-
-State 338
-
- 88 try_: block_sig . try_
-
- "(" shift, and go to state 309
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- block_sig go to state 338
- expr go to state 128
- try_ go to state 390
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 340
-
-
-State 339
-
- 87 expr1: try_check labeling_opt try_ .
-
- $default reduce using rule 87 (expr1)
-
-
-State 340
-
- 89 try_: instr_list . catch_sexp_list
-
- LPAR_CATCH shift, and go to state 391
- LPAR_CATCH_ALL shift, and go to state 392
-
- catch_sexp go to state 393
- catch_sexp_list go to state 394
-
-
-State 341
-
- 136 elem: "(" ELEM var offset var_list ")" .
-
- $default reduce using rule 136 (elem)
-
-
-State 342
-
- 149 memory_fields: "(" DATA text_list_opt . ")"
-
- ")" shift, and go to state 395
-
-
-State 343
-
- 143 data: "(" DATA var offset text_list_opt ")" .
-
- $default reduce using rule 143 (data)
-
-
-State 344
-
- 154 import_desc: "(" FUNC . bind_var_opt type_use ")"
- 155 | "(" FUNC . bind_var_opt func_sig ")"
-
- VAR shift, and go to state 53
-
- $default reduce using rule 30 (bind_var_opt)
-
- bind_var_opt go to state 396
- bind_var go to state 55
-
-
-State 345
-
- 158 import_desc: "(" GLOBAL . bind_var_opt global_type ")"
-
- VAR shift, and go to state 53
-
- $default reduce using rule 30 (bind_var_opt)
-
- bind_var_opt go to state 397
- bind_var go to state 55
-
-
-State 346
-
- 156 import_desc: "(" TABLE . bind_var_opt table_sig ")"
-
- VAR shift, and go to state 53
-
- $default reduce using rule 30 (bind_var_opt)
-
- bind_var_opt go to state 398
- bind_var go to state 55
-
-
-State 347
-
- 157 import_desc: "(" MEMORY . bind_var_opt memory_sig ")"
-
- VAR shift, and go to state 53
-
- $default reduce using rule 30 (bind_var_opt)
-
- bind_var_opt go to state 399
- bind_var go to state 55
-
-
-State 348
-
- 160 import: "(" IMPORT quoted_text quoted_text import_desc ")" .
-
- $default reduce using rule 160 (import)
-
-
-State 349
-
- 162 export_desc: "(" FUNC var . ")"
-
- ")" shift, and go to state 400
-
-
-State 350
-
- 165 export_desc: "(" GLOBAL var . ")"
-
- ")" shift, and go to state 401
-
-
-State 351
-
- 163 export_desc: "(" TABLE var . ")"
-
- ")" shift, and go to state 402
-
-
-State 352
-
- 164 export_desc: "(" MEMORY var . ")"
-
- ")" shift, and go to state 403
-
-
-State 353
-
- 166 export_desc: "(" EXCEPT var . ")"
-
- ")" shift, and go to state 404
-
-
-State 354
-
- 192 script_module: "(" MODULE bind_var_opt BIN text_list ")" .
-
- $default reduce using rule 192 (script_module)
-
-
-State 355
-
- 193 script_module: "(" MODULE bind_var_opt QUOTE text_list ")" .
-
- $default reduce using rule 193 (script_module)
-
-
-State 356
-
- 194 action: "(" INVOKE script_var_opt quoted_text const_list ")" .
-
- $default reduce using rule 194 (action)
-
-
-State 357
-
- 211 const: "(" CONST . literal ")"
-
- NAT shift, and go to state 222
- INT shift, and go to state 223
- FLOAT shift, and go to state 224
-
- literal go to state 405
-
-
-State 358
-
- 21 type_use: "(" TYPE var ")" .
-
- $default reduce using rule 21 (type_use)
-
-
-State 359
-
- 126 func_fields_body1: "(" PARAM value_type_list ")" . func_fields_body1
-
- "(" shift, and go to state 226
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 132
- func_fields_body1 go to state 406
- func_result_body go to state 136
- func_body go to state 137
- func_body1 go to state 138
-
-
-State 360
-
- 127 func_fields_body1: "(" PARAM bind_var VALUE_TYPE . ")" func_fields_body1
-
- ")" shift, and go to state 407
-
-
-State 361
-
- 129 func_result_body: "(" RESULT value_type_list ")" . func_result_body
-
- "(" shift, and go to state 408
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 132
- func_result_body go to state 409
- func_body go to state 137
- func_body1 go to state 138
-
-
-State 362
-
- 132 func_body1: "(" LOCAL value_type_list ")" . func_body1
-
- "(" shift, and go to state 410
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 132
- func_body1 go to state 411
-
-
-State 363
-
- 133 func_body1: "(" LOCAL bind_var VALUE_TYPE . ")" func_body1
-
- ")" shift, and go to state 412
-
-
-State 364
-
- 161 inline_import: "(" IMPORT quoted_text quoted_text . ")"
-
- ")" shift, and go to state 413
-
-
-State 365
-
- 168 inline_export: "(" EXPORT quoted_text ")" .
-
- $default reduce using rule 168 (inline_export)
-
-
-State 366
-
- 73 block_sig: "(" RESULT . value_type_list ")"
-
- $default reduce using rule 6 (value_type_list)
-
- value_type_list go to state 414
-
-
-State 367
-
- 74 block: block_sig block .
-
- $default reduce using rule 74 (block)
-
-
-State 368
-
- 68 block_instr: BLOCK labeling_opt block END . labeling_opt
-
- VAR shift, and go to state 53
-
- $default reduce using rule 33 (labeling_opt)
-
- bind_var go to state 205
- labeling_opt go to state 415
-
-
-State 369
-
- 70 block_instr: IF labeling_opt block END . labeling_opt
-
- VAR shift, and go to state 53
-
- $default reduce using rule 33 (labeling_opt)
-
- bind_var go to state 205
- labeling_opt go to state 416
-
-
-State 370
-
- 71 block_instr: IF labeling_opt block ELSE . labeling_opt instr_list END labeling_opt
-
- VAR shift, and go to state 53
-
- $default reduce using rule 33 (labeling_opt)
-
- bind_var go to state 205
- labeling_opt go to state 417
-
-
-State 371
-
- 69 block_instr: LOOP labeling_opt block END . labeling_opt
-
- VAR shift, and go to state 53
-
- $default reduce using rule 33 (labeling_opt)
-
- bind_var go to state 205
- labeling_opt go to state 418
-
-
-State 372
-
- 76 plain_catch: CATCH . var instr_list
-
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 419
-
-
-State 373
-
- 77 plain_catch_all: CATCH_ALL . instr_list
-
- "(" shift, and go to state 228
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 420
-
-
-State 374
-
- 78 catch_instr: plain_catch .
-
- $default reduce using rule 78 (catch_instr)
-
-
-State 375
-
- 79 catch_instr: plain_catch_all .
-
- $default reduce using rule 79 (catch_instr)
-
-
-State 376
-
- 80 catch_instr_list: catch_instr .
-
- $default reduce using rule 80 (catch_instr_list)
-
-
-State 377
-
- 72 block_instr: try_check labeling_opt block catch_instr_list . END labeling_opt
- 81 catch_instr_list: catch_instr_list . catch_instr
-
- END shift, and go to state 421
- CATCH shift, and go to state 372
- CATCH_ALL shift, and go to state 373
-
- plain_catch go to state 374
- plain_catch_all go to state 375
- catch_instr go to state 422
-
-
-State 378
-
- 7 value_type_list: value_type_list . VALUE_TYPE
- 120 func_fields_import1: "(" PARAM value_type_list . ")" func_fields_import1
-
- ")" shift, and go to state 423
- VALUE_TYPE shift, and go to state 285
-
-
-State 379
-
- 121 func_fields_import1: "(" PARAM bind_var . VALUE_TYPE ")" func_fields_import1
-
- VALUE_TYPE shift, and go to state 424
-
-
-State 380
-
- 7 value_type_list: value_type_list . VALUE_TYPE
- 123 func_fields_import_result: "(" RESULT value_type_list . ")" func_fields_import_result
-
- ")" shift, and go to state 425
- VALUE_TYPE shift, and go to state 285
-
-
-State 381
-
- 7 value_type_list: value_type_list . VALUE_TYPE
- 13 func_sig: "(" PARAM value_type_list . ")" func_sig
-
- ")" shift, and go to state 426
- VALUE_TYPE shift, and go to state 285
-
-
-State 382
-
- 14 func_sig: "(" PARAM bind_var . VALUE_TYPE ")" func_sig
-
- VALUE_TYPE shift, and go to state 427
-
-
-State 383
-
- 7 value_type_list: value_type_list . VALUE_TYPE
- 16 func_sig_result: "(" RESULT value_type_list . ")" func_sig_result
-
- ")" shift, and go to state 428
- VALUE_TYPE shift, and go to state 285
-
-
-State 384
-
- 10 global_type: "(" MUT VALUE_TYPE ")" .
-
- $default reduce using rule 10 (global_type)
-
-
-State 385
-
- 29 var_list: var_list . var
- 142 table_fields: elem_type "(" ELEM var_list . ")"
-
- ")" shift, and go to state 429
- NAT shift, and go to state 56
- VAR shift, and go to state 57
-
- nat go to state 58
- var go to state 267
-
-
-State 386
-
- 96 if_: "(" THEN . instr_list ")" "(" ELSE instr_list ")"
- 97 | "(" THEN . instr_list ")"
-
- "(" shift, and go to state 228
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 430
-
-
-State 387
-
- 94 if_block: block_sig if_block .
-
- $default reduce using rule 94 (if_block)
-
-
-State 388
-
- 82 expr: "(" . expr1 ")"
- 98 if_: expr "(" . THEN instr_list ")" "(" ELSE instr_list ")"
- 99 | expr "(" . THEN instr_list ")"
-
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 160
- IF shift, and go to state 161
- THEN shift, and go to state 431
- LOOP shift, and go to state 162
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- plain_instr go to state 164
- expr1 go to state 165
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 166
-
-
-State 389
-
- 100 if_: expr expr . expr
- 101 | expr expr .
-
- "(" shift, and go to state 228
-
- $default reduce using rule 101 (if_)
-
- expr go to state 432
-
-
-State 390
-
- 88 try_: block_sig try_ .
-
- $default reduce using rule 88 (try_)
-
-
-State 391
-
- 90 catch_sexp: LPAR_CATCH . "(" plain_catch ")"
-
- "(" shift, and go to state 433
-
-
-State 392
-
- 91 catch_sexp: LPAR_CATCH_ALL . "(" plain_catch_all ")"
-
- "(" shift, and go to state 434
-
-
-State 393
-
- 92 catch_sexp_list: catch_sexp .
-
- $default reduce using rule 92 (catch_sexp_list)
-
-
-State 394
-
- 89 try_: instr_list catch_sexp_list .
- 93 catch_sexp_list: catch_sexp_list . catch_sexp
-
- LPAR_CATCH shift, and go to state 391
- LPAR_CATCH_ALL shift, and go to state 392
-
- $default reduce using rule 89 (try_)
-
- catch_sexp go to state 435
-
-
-State 395
-
- 149 memory_fields: "(" DATA text_list_opt ")" .
-
- $default reduce using rule 149 (memory_fields)
-
-
-State 396
-
- 154 import_desc: "(" FUNC bind_var_opt . type_use ")"
- 155 | "(" FUNC bind_var_opt . func_sig ")"
-
- "(" shift, and go to state 436
-
- $default reduce using rule 15 (func_sig_result)
-
- func_sig go to state 437
- func_sig_result go to state 242
- type_use go to state 438
-
-
-State 397
-
- 158 import_desc: "(" GLOBAL bind_var_opt . global_type ")"
-
- "(" shift, and go to state 248
- VALUE_TYPE shift, and go to state 146
-
- global_type go to state 439
-
-
-State 398
-
- 156 import_desc: "(" TABLE bind_var_opt . table_sig ")"
-
- NAT shift, and go to state 56
-
- table_sig go to state 440
- limits go to state 155
- nat go to state 156
-
-
-State 399
-
- 157 import_desc: "(" MEMORY bind_var_opt . memory_sig ")"
-
- NAT shift, and go to state 56
-
- memory_sig go to state 441
- limits go to state 171
- nat go to state 156
-
-
-State 400
-
- 162 export_desc: "(" FUNC var ")" .
-
- $default reduce using rule 162 (export_desc)
-
-
-State 401
-
- 165 export_desc: "(" GLOBAL var ")" .
-
- $default reduce using rule 165 (export_desc)
-
-
-State 402
-
- 163 export_desc: "(" TABLE var ")" .
-
- $default reduce using rule 163 (export_desc)
-
-
-State 403
-
- 164 export_desc: "(" MEMORY var ")" .
-
- $default reduce using rule 164 (export_desc)
-
-
-State 404
-
- 166 export_desc: "(" EXCEPT var ")" .
-
- $default reduce using rule 166 (export_desc)
-
-
-State 405
-
- 211 const: "(" CONST literal . ")"
-
- ")" shift, and go to state 442
-
-
-State 406
-
- 126 func_fields_body1: "(" PARAM value_type_list ")" func_fields_body1 .
-
- $default reduce using rule 126 (func_fields_body1)
-
-
-State 407
-
- 127 func_fields_body1: "(" PARAM bind_var VALUE_TYPE ")" . func_fields_body1
-
- "(" shift, and go to state 226
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 132
- func_fields_body1 go to state 443
- func_result_body go to state 136
- func_body go to state 137
- func_body1 go to state 138
-
-
-State 408
-
- 82 expr: "(" . expr1 ")"
- 129 func_result_body: "(" . RESULT value_type_list ")" func_result_body
- 132 func_body1: "(" . LOCAL value_type_list ")" func_body1
- 133 | "(" . LOCAL bind_var VALUE_TYPE ")" func_body1
-
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 160
- IF shift, and go to state 161
- LOOP shift, and go to state 162
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
- RESULT shift, and go to state 201
- LOCAL shift, and go to state 202
-
- plain_instr go to state 164
- expr1 go to state 165
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 166
-
-
-State 409
-
- 129 func_result_body: "(" RESULT value_type_list ")" func_result_body .
-
- $default reduce using rule 129 (func_result_body)
-
-
-State 410
-
- 82 expr: "(" . expr1 ")"
- 132 func_body1: "(" . LOCAL value_type_list ")" func_body1
- 133 | "(" . LOCAL bind_var VALUE_TYPE ")" func_body1
-
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 160
- IF shift, and go to state 161
- LOOP shift, and go to state 162
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
- LOCAL shift, and go to state 202
-
- plain_instr go to state 164
- expr1 go to state 165
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 166
-
-
-State 411
-
- 132 func_body1: "(" LOCAL value_type_list ")" func_body1 .
-
- $default reduce using rule 132 (func_body1)
-
-
-State 412
-
- 133 func_body1: "(" LOCAL bind_var VALUE_TYPE ")" . func_body1
-
- "(" shift, and go to state 410
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 132
- func_body1 go to state 444
-
-
-State 413
-
- 161 inline_import: "(" IMPORT quoted_text quoted_text ")" .
-
- $default reduce using rule 161 (inline_import)
-
-
-State 414
-
- 7 value_type_list: value_type_list . VALUE_TYPE
- 73 block_sig: "(" RESULT value_type_list . ")"
-
- ")" shift, and go to state 445
- VALUE_TYPE shift, and go to state 285
-
-
-State 415
-
- 68 block_instr: BLOCK labeling_opt block END labeling_opt .
-
- $default reduce using rule 68 (block_instr)
-
-
-State 416
-
- 70 block_instr: IF labeling_opt block END labeling_opt .
-
- $default reduce using rule 70 (block_instr)
-
-
-State 417
-
- 71 block_instr: IF labeling_opt block ELSE labeling_opt . instr_list END labeling_opt
-
- "(" shift, and go to state 228
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 446
-
-
-State 418
-
- 69 block_instr: LOOP labeling_opt block END labeling_opt .
-
- $default reduce using rule 69 (block_instr)
-
-
-State 419
-
- 76 plain_catch: CATCH var . instr_list
-
- "(" shift, and go to state 228
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 447
-
-
-State 420
-
- 77 plain_catch_all: CATCH_ALL instr_list .
-
- $default reduce using rule 77 (plain_catch_all)
-
-
-State 421
-
- 72 block_instr: try_check labeling_opt block catch_instr_list END . labeling_opt
-
- VAR shift, and go to state 53
-
- $default reduce using rule 33 (labeling_opt)
-
- bind_var go to state 205
- labeling_opt go to state 448
-
-
-State 422
-
- 81 catch_instr_list: catch_instr_list catch_instr .
-
- $default reduce using rule 81 (catch_instr_list)
-
-
-State 423
-
- 120 func_fields_import1: "(" PARAM value_type_list ")" . func_fields_import1
-
- "(" shift, and go to state 322
-
- $default reduce using rule 122 (func_fields_import_result)
-
- func_fields_import1 go to state 449
- func_fields_import_result go to state 238
-
-
-State 424
-
- 121 func_fields_import1: "(" PARAM bind_var VALUE_TYPE . ")" func_fields_import1
-
- ")" shift, and go to state 450
-
-
-State 425
-
- 123 func_fields_import_result: "(" RESULT value_type_list ")" . func_fields_import_result
-
- "(" shift, and go to state 451
-
- $default reduce using rule 122 (func_fields_import_result)
-
- func_fields_import_result go to state 452
-
-
-State 426
-
- 13 func_sig: "(" PARAM value_type_list ")" . func_sig
-
- "(" shift, and go to state 240
-
- $default reduce using rule 15 (func_sig_result)
-
- func_sig go to state 453
- func_sig_result go to state 242
-
-
-State 427
-
- 14 func_sig: "(" PARAM bind_var VALUE_TYPE . ")" func_sig
-
- ")" shift, and go to state 454
-
-
-State 428
-
- 16 func_sig_result: "(" RESULT value_type_list ")" . func_sig_result
-
- "(" shift, and go to state 455
-
- $default reduce using rule 15 (func_sig_result)
-
- func_sig_result go to state 456
-
-
-State 429
-
- 142 table_fields: elem_type "(" ELEM var_list ")" .
-
- $default reduce using rule 142 (table_fields)
-
-
-State 430
-
- 96 if_: "(" THEN instr_list . ")" "(" ELSE instr_list ")"
- 97 | "(" THEN instr_list . ")"
-
- ")" shift, and go to state 457
-
-
-State 431
-
- 98 if_: expr "(" THEN . instr_list ")" "(" ELSE instr_list ")"
- 99 | expr "(" THEN . instr_list ")"
-
- "(" shift, and go to state 228
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 458
-
-
-State 432
-
- 100 if_: expr expr expr .
-
- $default reduce using rule 100 (if_)
-
-
-State 433
-
- 90 catch_sexp: LPAR_CATCH "(" . plain_catch ")"
-
- CATCH shift, and go to state 372
-
- plain_catch go to state 459
-
-
-State 434
-
- 91 catch_sexp: LPAR_CATCH_ALL "(" . plain_catch_all ")"
-
- CATCH_ALL shift, and go to state 373
-
- plain_catch_all go to state 460
-
-
-State 435
-
- 93 catch_sexp_list: catch_sexp_list catch_sexp .
-
- $default reduce using rule 93 (catch_sexp_list)
-
-
-State 436
-
- 13 func_sig: "(" . PARAM value_type_list ")" func_sig
- 14 | "(" . PARAM bind_var VALUE_TYPE ")" func_sig
- 16 func_sig_result: "(" . RESULT value_type_list ")" func_sig_result
- 21 type_use: "(" . TYPE var ")"
-
- TYPE shift, and go to state 199
- PARAM shift, and go to state 324
- RESULT shift, and go to state 325
-
-
-State 437
-
- 155 import_desc: "(" FUNC bind_var_opt func_sig . ")"
-
- ")" shift, and go to state 461
-
-
-State 438
-
- 154 import_desc: "(" FUNC bind_var_opt type_use . ")"
-
- ")" shift, and go to state 462
-
-
-State 439
-
- 158 import_desc: "(" GLOBAL bind_var_opt global_type . ")"
-
- ")" shift, and go to state 463
-
-
-State 440
-
- 156 import_desc: "(" TABLE bind_var_opt table_sig . ")"
-
- ")" shift, and go to state 464
-
-
-State 441
-
- 157 import_desc: "(" MEMORY bind_var_opt memory_sig . ")"
-
- ")" shift, and go to state 465
-
-
-State 442
-
- 211 const: "(" CONST literal ")" .
-
- $default reduce using rule 211 (const)
-
-
-State 443
-
- 127 func_fields_body1: "(" PARAM bind_var VALUE_TYPE ")" func_fields_body1 .
-
- $default reduce using rule 127 (func_fields_body1)
-
-
-State 444
-
- 133 func_body1: "(" LOCAL bind_var VALUE_TYPE ")" func_body1 .
-
- $default reduce using rule 133 (func_body1)
-
-
-State 445
-
- 73 block_sig: "(" RESULT value_type_list ")" .
-
- $default reduce using rule 73 (block_sig)
-
-
-State 446
-
- 71 block_instr: IF labeling_opt block ELSE labeling_opt instr_list . END labeling_opt
-
- END shift, and go to state 466
-
-
-State 447
-
- 76 plain_catch: CATCH var instr_list .
-
- $default reduce using rule 76 (plain_catch)
-
-
-State 448
-
- 72 block_instr: try_check labeling_opt block catch_instr_list END labeling_opt .
-
- $default reduce using rule 72 (block_instr)
-
-
-State 449
-
- 120 func_fields_import1: "(" PARAM value_type_list ")" func_fields_import1 .
-
- $default reduce using rule 120 (func_fields_import1)
-
-
-State 450
-
- 121 func_fields_import1: "(" PARAM bind_var VALUE_TYPE ")" . func_fields_import1
-
- "(" shift, and go to state 322
-
- $default reduce using rule 122 (func_fields_import_result)
-
- func_fields_import1 go to state 467
- func_fields_import_result go to state 238
-
-
-State 451
-
- 123 func_fields_import_result: "(" . RESULT value_type_list ")" func_fields_import_result
-
- RESULT shift, and go to state 321
-
-
-State 452
-
- 123 func_fields_import_result: "(" RESULT value_type_list ")" func_fields_import_result .
-
- $default reduce using rule 123 (func_fields_import_result)
-
-
-State 453
-
- 13 func_sig: "(" PARAM value_type_list ")" func_sig .
-
- $default reduce using rule 13 (func_sig)
-
-
-State 454
-
- 14 func_sig: "(" PARAM bind_var VALUE_TYPE ")" . func_sig
-
- "(" shift, and go to state 240
-
- $default reduce using rule 15 (func_sig_result)
-
- func_sig go to state 468
- func_sig_result go to state 242
-
-
-State 455
-
- 16 func_sig_result: "(" . RESULT value_type_list ")" func_sig_result
-
- RESULT shift, and go to state 325
-
-
-State 456
-
- 16 func_sig_result: "(" RESULT value_type_list ")" func_sig_result .
-
- $default reduce using rule 16 (func_sig_result)
-
-
-State 457
-
- 96 if_: "(" THEN instr_list ")" . "(" ELSE instr_list ")"
- 97 | "(" THEN instr_list ")" .
-
- "(" shift, and go to state 469
-
- $default reduce using rule 97 (if_)
-
-
-State 458
-
- 98 if_: expr "(" THEN instr_list . ")" "(" ELSE instr_list ")"
- 99 | expr "(" THEN instr_list . ")"
-
- ")" shift, and go to state 470
-
-
-State 459
-
- 90 catch_sexp: LPAR_CATCH "(" plain_catch . ")"
-
- ")" shift, and go to state 471
-
-
-State 460
-
- 91 catch_sexp: LPAR_CATCH_ALL "(" plain_catch_all . ")"
-
- ")" shift, and go to state 472
-
-
-State 461
-
- 155 import_desc: "(" FUNC bind_var_opt func_sig ")" .
-
- $default reduce using rule 155 (import_desc)
-
-
-State 462
-
- 154 import_desc: "(" FUNC bind_var_opt type_use ")" .
-
- $default reduce using rule 154 (import_desc)
-
-
-State 463
-
- 158 import_desc: "(" GLOBAL bind_var_opt global_type ")" .
-
- $default reduce using rule 158 (import_desc)
-
-
-State 464
-
- 156 import_desc: "(" TABLE bind_var_opt table_sig ")" .
-
- $default reduce using rule 156 (import_desc)
-
-
-State 465
-
- 157 import_desc: "(" MEMORY bind_var_opt memory_sig ")" .
-
- $default reduce using rule 157 (import_desc)
-
-
-State 466
-
- 71 block_instr: IF labeling_opt block ELSE labeling_opt instr_list END . labeling_opt
-
- VAR shift, and go to state 53
-
- $default reduce using rule 33 (labeling_opt)
-
- bind_var go to state 205
- labeling_opt go to state 473
-
-
-State 467
-
- 121 func_fields_import1: "(" PARAM bind_var VALUE_TYPE ")" func_fields_import1 .
-
- $default reduce using rule 121 (func_fields_import1)
-
-
-State 468
-
- 14 func_sig: "(" PARAM bind_var VALUE_TYPE ")" func_sig .
-
- $default reduce using rule 14 (func_sig)
-
-
-State 469
-
- 96 if_: "(" THEN instr_list ")" "(" . ELSE instr_list ")"
-
- ELSE shift, and go to state 474
-
-
-State 470
-
- 98 if_: expr "(" THEN instr_list ")" . "(" ELSE instr_list ")"
- 99 | expr "(" THEN instr_list ")" .
-
- "(" shift, and go to state 475
-
- $default reduce using rule 99 (if_)
-
-
-State 471
-
- 90 catch_sexp: LPAR_CATCH "(" plain_catch ")" .
-
- $default reduce using rule 90 (catch_sexp)
-
-
-State 472
-
- 91 catch_sexp: LPAR_CATCH_ALL "(" plain_catch_all ")" .
-
- $default reduce using rule 91 (catch_sexp)
-
-
-State 473
-
- 71 block_instr: IF labeling_opt block ELSE labeling_opt instr_list END labeling_opt .
-
- $default reduce using rule 71 (block_instr)
-
-
-State 474
-
- 96 if_: "(" THEN instr_list ")" "(" ELSE . instr_list ")"
-
- "(" shift, and go to state 228
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 476
-
-
-State 475
-
- 98 if_: expr "(" THEN instr_list ")" "(" . ELSE instr_list ")"
-
- ELSE shift, and go to state 477
-
-
-State 476
-
- 96 if_: "(" THEN instr_list ")" "(" ELSE instr_list . ")"
-
- ")" shift, and go to state 478
-
-
-State 477
-
- 98 if_: expr "(" THEN instr_list ")" "(" ELSE . instr_list ")"
-
- "(" shift, and go to state 228
- NOP shift, and go to state 94
- DROP shift, and go to state 95
- BLOCK shift, and go to state 96
- IF shift, and go to state 97
- LOOP shift, and go to state 98
- BR shift, and go to state 99
- BR_IF shift, and go to state 100
- BR_TABLE shift, and go to state 101
- TRY shift, and go to state 102
- THROW shift, and go to state 103
- RETHROW shift, and go to state 104
- CALL shift, and go to state 105
- CALL_INDIRECT shift, and go to state 106
- RETURN shift, and go to state 107
- GET_LOCAL shift, and go to state 108
- SET_LOCAL shift, and go to state 109
- TEE_LOCAL shift, and go to state 110
- GET_GLOBAL shift, and go to state 111
- SET_GLOBAL shift, and go to state 112
- LOAD shift, and go to state 113
- STORE shift, and go to state 114
- CONST shift, and go to state 115
- UNARY shift, and go to state 116
- BINARY shift, and go to state 117
- COMPARE shift, and go to state 118
- CONVERT shift, and go to state 119
- SELECT shift, and go to state 120
- UNREACHABLE shift, and go to state 121
- CURRENT_MEMORY shift, and go to state 122
- GROW_MEMORY shift, and go to state 123
-
- $default reduce using rule 105 (instr_list)
-
- instr go to state 125
- plain_instr go to state 126
- block_instr go to state 127
- expr go to state 128
- rethrow_check go to state 129
- throw_check go to state 130
- try_check go to state 131
- instr_list go to state 479
-
-
-State 478
-
- 96 if_: "(" THEN instr_list ")" "(" ELSE instr_list ")" .
-
- $default reduce using rule 96 (if_)
-
-
-State 479
-
- 98 if_: expr "(" THEN instr_list ")" "(" ELSE instr_list . ")"
-
- ")" shift, and go to state 480
-
-
-State 480
-
- 98 if_: expr "(" THEN instr_list ")" "(" ELSE instr_list ")" .
-
- $default reduce using rule 98 (if_)
diff --git a/src/resolve-names.cc b/src/resolve-names.cc
index e10bb4ae..c18dd557 100644
--- a/src/resolve-names.cc
+++ b/src/resolve-names.cc
@@ -20,8 +20,10 @@
#include <cstdio>
#include "cast.h"
+#include "error-handler.h"
#include "expr-visitor.h"
#include "ir.h"
+#include "wast-lexer.h"
#include "wast-parser-lexer-shared.h"
namespace wabt {
diff --git a/src/tools/wasm-interp.cc b/src/tools/wasm-interp.cc
index 4a06925d..234f3c0a 100644
--- a/src/tools/wasm-interp.cc
+++ b/src/tools/wasm-interp.cc
@@ -235,7 +235,7 @@ static interpreter::Result RunStartFunction(Thread* thread,
}
static interpreter::Result RunExport(Thread* thread,
- const Export* export_,
+ const interpreter::Export* export_,
const std::vector<TypedValue>& args,
std::vector<TypedValue>* out_results) {
if (s_trace) {
@@ -248,12 +248,12 @@ static interpreter::Result RunExport(Thread* thread,
}
static interpreter::Result RunExportByName(Thread* thread,
- Module* module,
+ interpreter::Module* module,
string_view name,
const std::vector<TypedValue>& args,
std::vector<TypedValue>* out_results,
RunVerbosity verbose) {
- Export* export_ = module->GetExport(name);
+ interpreter::Export* export_ = module->GetExport(name);
if (!export_)
return interpreter::Result::UnknownExport;
if (export_->kind != ExternalKind::Func)
@@ -263,27 +263,27 @@ static interpreter::Result RunExportByName(Thread* thread,
static interpreter::Result GetGlobalExportByName(
Thread* thread,
- Module* module,
+ interpreter::Module* module,
string_view name,
std::vector<TypedValue>* out_results) {
- Export* export_ = module->GetExport(name);
+ interpreter::Export* export_ = module->GetExport(name);
if (!export_)
return interpreter::Result::UnknownExport;
if (export_->kind != ExternalKind::Global)
return interpreter::Result::ExportKindMismatch;
- Global* global = thread->env()->GetGlobal(export_->index);
+ interpreter::Global* global = thread->env()->GetGlobal(export_->index);
out_results->clear();
out_results->push_back(global->typed_value);
return interpreter::Result::Ok;
}
-static void RunAllExports(Module* module,
+static void RunAllExports(interpreter::Module* module,
Thread* thread,
RunVerbosity verbose) {
std::vector<TypedValue> args;
std::vector<TypedValue> results;
- for (const Export& export_ : module->exports) {
+ for (const interpreter::Export& export_ : module->exports) {
interpreter::Result iresult = RunExport(thread, &export_, args, &results);
if (verbose == RunVerbosity::Verbose) {
PrintCall(string_view(), export_.name, args, results, iresult);
@@ -314,13 +314,14 @@ static wabt::Result ReadModule(const char* module_filename,
return result;
}
-static interpreter::Result DefaultHostCallback(const HostFunc* func,
- const FuncSignature* sig,
- Index num_args,
- TypedValue* args,
- Index num_results,
- TypedValue* out_results,
- void* user_data) {
+static interpreter::Result DefaultHostCallback(
+ const HostFunc* func,
+ const interpreter::FuncSignature* sig,
+ Index num_args,
+ TypedValue* args,
+ Index num_results,
+ TypedValue* out_results,
+ void* user_data) {
memset(out_results, 0, sizeof(TypedValue) * num_results);
for (Index i = 0; i < num_results; ++i)
out_results[i].type = sig->result_types[i];
@@ -341,9 +342,9 @@ static interpreter::Result DefaultHostCallback(const HostFunc* func,
class SpectestHostImportDelegate : public HostImportDelegate {
public:
- wabt::Result ImportFunc(Import* import,
- Func* func,
- FuncSignature* func_sig,
+ wabt::Result ImportFunc(interpreter::Import* import,
+ interpreter::Func* func,
+ interpreter::FuncSignature* func_sig,
const ErrorCallback& callback) override {
if (import->field_name == "print") {
func->as_host()->callback = DefaultHostCallback;
@@ -355,8 +356,8 @@ class SpectestHostImportDelegate : public HostImportDelegate {
}
}
- wabt::Result ImportTable(Import* import,
- Table* table,
+ wabt::Result ImportTable(interpreter::Import* import,
+ interpreter::Table* table,
const ErrorCallback& callback) override {
if (import->field_name == "table") {
table->limits.has_max = true;
@@ -370,8 +371,8 @@ class SpectestHostImportDelegate : public HostImportDelegate {
}
}
- wabt::Result ImportMemory(Import* import,
- Memory* memory,
+ wabt::Result ImportMemory(interpreter::Import* import,
+ interpreter::Memory* memory,
const ErrorCallback& callback) override {
if (import->field_name == "memory") {
memory->page_limits.has_max = true;
@@ -386,8 +387,8 @@ class SpectestHostImportDelegate : public HostImportDelegate {
}
}
- wabt::Result ImportGlobal(Import* import,
- Global* global,
+ wabt::Result ImportGlobal(interpreter::Import* import,
+ interpreter::Global* global,
const ErrorCallback& callback) override {
if (import->field_name == "global") {
switch (global->typed_value.type) {
@@ -464,7 +465,7 @@ enum class ActionType {
};
struct Action {
- ActionType type = ActionType::Invoke;
+ ::ActionType type = ::ActionType::Invoke;
std::string module_name;
std::string field_name;
std::vector<TypedValue> args;
@@ -501,17 +502,17 @@ class SpecJSONParser {
wabt::Result ParseTypeVector(TypeVector* out_types);
wabt::Result ParseConst(TypedValue* out_value);
wabt::Result ParseConstVector(std::vector<TypedValue>* out_values);
- wabt::Result ParseAction(Action* out_action);
+ wabt::Result ParseAction(::Action* out_action);
wabt::Result ParseModuleType(ModuleType* out_type);
std::string CreateModulePath(string_view filename);
wabt::Result OnModuleCommand(string_view filename, string_view name);
- wabt::Result RunAction(Action* action,
+ wabt::Result RunAction(::Action* action,
interpreter::Result* out_iresult,
std::vector<TypedValue>* out_results,
RunVerbosity verbose);
- wabt::Result OnActionCommand(Action* action);
+ wabt::Result OnActionCommand(::Action* action);
wabt::Result ReadInvalidTextModule(const char* module_filename,
Environment* env,
ErrorHandler* error_handler);
@@ -532,11 +533,11 @@ class SpecJSONParser {
wabt::Result OnAssertUninstantiableCommand(string_view filename,
string_view text,
ModuleType module_type);
- wabt::Result OnAssertReturnCommand(Action* action,
+ wabt::Result OnAssertReturnCommand(::Action* action,
const std::vector<TypedValue>& expected);
- wabt::Result OnAssertReturnNanCommand(Action* action, bool canonical);
- wabt::Result OnAssertTrapCommand(Action* action, string_view text);
- wabt::Result OnAssertExhaustionCommand(Action* action);
+ wabt::Result OnAssertReturnNanCommand(::Action* action, bool canonical);
+ wabt::Result OnAssertTrapCommand(::Action* action, string_view text);
+ wabt::Result OnAssertExhaustionCommand(::Action* action);
wabt::Result ParseCommand();
Environment env_;
@@ -862,15 +863,15 @@ wabt::Result SpecJSONParser::ParseConstVector(
return wabt::Result::Ok;
}
-wabt::Result SpecJSONParser::ParseAction(Action* out_action) {
+wabt::Result SpecJSONParser::ParseAction(::Action* out_action) {
EXPECT_KEY("action");
EXPECT("{");
EXPECT_KEY("type");
if (Match("\"invoke\"")) {
- out_action->type = ActionType::Invoke;
+ out_action->type = ::ActionType::Invoke;
} else {
EXPECT("\"get\"");
- out_action->type = ActionType::Get;
+ out_action->type = ::ActionType::Get;
}
EXPECT(",");
if (Match("\"module\"")) {
@@ -879,7 +880,7 @@ wabt::Result SpecJSONParser::ParseAction(Action* out_action) {
EXPECT(",");
}
PARSE_KEY_STRING_VALUE("field", &out_action->field_name);
- if (out_action->type == ActionType::Invoke) {
+ if (out_action->type == ::ActionType::Invoke) {
EXPECT(",");
EXPECT_KEY("args");
CHECK_RESULT(ParseConstVector(&out_action->args));
@@ -951,13 +952,13 @@ wabt::Result SpecJSONParser::OnModuleCommand(string_view filename,
return wabt::Result::Ok;
}
-wabt::Result SpecJSONParser::RunAction(Action* action,
+wabt::Result SpecJSONParser::RunAction(::Action* action,
interpreter::Result* out_iresult,
std::vector<TypedValue>* out_results,
RunVerbosity verbose) {
out_results->clear();
- Module* module;
+ interpreter::Module* module;
if (!action->module_name.empty()) {
module = env_.FindModule(action->module_name);
} else {
@@ -966,7 +967,7 @@ wabt::Result SpecJSONParser::RunAction(Action* action,
assert(module);
switch (action->type) {
- case ActionType::Invoke:
+ case ::ActionType::Invoke:
*out_iresult = RunExportByName(&thread_, module, action->field_name,
action->args, out_results, verbose);
if (verbose == RunVerbosity::Verbose) {
@@ -975,7 +976,7 @@ wabt::Result SpecJSONParser::RunAction(Action* action,
}
return wabt::Result::Ok;
- case ActionType::Get: {
+ case ::ActionType::Get: {
*out_iresult = GetGlobalExportByName(&thread_, module, action->field_name,
out_results);
return wabt::Result::Ok;
@@ -988,7 +989,7 @@ wabt::Result SpecJSONParser::RunAction(Action* action,
}
}
-wabt::Result SpecJSONParser::OnActionCommand(Action* action) {
+wabt::Result SpecJSONParser::OnActionCommand(::Action* action) {
std::vector<TypedValue> results;
interpreter::Result iresult;
@@ -1178,7 +1179,7 @@ static bool TypedValuesAreEqual(const TypedValue* tv1, const TypedValue* tv2) {
}
wabt::Result SpecJSONParser::OnAssertReturnCommand(
- Action* action,
+ ::Action* action,
const std::vector<TypedValue>& expected) {
std::vector<TypedValue> results;
interpreter::Result iresult;
@@ -1224,7 +1225,7 @@ wabt::Result SpecJSONParser::OnAssertReturnCommand(
return result;
}
-wabt::Result SpecJSONParser::OnAssertReturnNanCommand(Action* action,
+wabt::Result SpecJSONParser::OnAssertReturnNanCommand(::Action* action,
bool canonical) {
std::vector<TypedValue> results;
interpreter::Result iresult;
@@ -1284,7 +1285,7 @@ wabt::Result SpecJSONParser::OnAssertReturnNanCommand(Action* action,
return wabt::Result::Ok;
}
-wabt::Result SpecJSONParser::OnAssertTrapCommand(Action* action,
+wabt::Result SpecJSONParser::OnAssertTrapCommand(::Action* action,
string_view text) {
std::vector<TypedValue> results;
interpreter::Result iresult;
@@ -1305,7 +1306,7 @@ wabt::Result SpecJSONParser::OnAssertTrapCommand(Action* action,
return result;
}
-wabt::Result SpecJSONParser::OnAssertExhaustionCommand(Action* action) {
+wabt::Result SpecJSONParser::OnAssertExhaustionCommand(::Action* action) {
std::vector<TypedValue> results;
interpreter::Result iresult;
@@ -1339,7 +1340,7 @@ wabt::Result SpecJSONParser::ParseCommand() {
PARSE_KEY_STRING_VALUE("filename", &filename);
OnModuleCommand(filename, name);
} else if (Match("\"action\"")) {
- Action action;
+ ::Action action;
EXPECT(",");
CHECK_RESULT(ParseLine());
@@ -1413,7 +1414,7 @@ wabt::Result SpecJSONParser::ParseCommand() {
CHECK_RESULT(ParseModuleType(&module_type));
OnAssertUninstantiableCommand(filename, text, module_type);
} else if (Match("\"assert_return\"")) {
- Action action;
+ ::Action action;
std::vector<TypedValue> expected;
EXPECT(",");
@@ -1425,7 +1426,7 @@ wabt::Result SpecJSONParser::ParseCommand() {
CHECK_RESULT(ParseConstVector(&expected));
OnAssertReturnCommand(&action, expected);
} else if (Match("\"assert_return_canonical_nan\"")) {
- Action action;
+ ::Action action;
TypeVector expected;
EXPECT(",");
@@ -1438,7 +1439,7 @@ wabt::Result SpecJSONParser::ParseCommand() {
CHECK_RESULT(ParseTypeVector(&expected));
OnAssertReturnNanCommand(&action, true);
} else if (Match("\"assert_return_arithmetic_nan\"")) {
- Action action;
+ ::Action action;
TypeVector expected;
EXPECT(",");
@@ -1451,7 +1452,7 @@ wabt::Result SpecJSONParser::ParseCommand() {
CHECK_RESULT(ParseTypeVector(&expected));
OnAssertReturnNanCommand(&action, false);
} else if (Match("\"assert_trap\"")) {
- Action action;
+ ::Action action;
std::string text;
EXPECT(",");
@@ -1462,7 +1463,7 @@ wabt::Result SpecJSONParser::ParseCommand() {
PARSE_KEY_STRING_VALUE("text", &text);
OnAssertTrapCommand(&action, text);
} else if (Match("\"assert_exhaustion\"")) {
- Action action;
+ ::Action action;
std::string text;
EXPECT(",");
diff --git a/src/validator.cc b/src/validator.cc
index 8cf10be8..a1afab1e 100644
--- a/src/validator.cc
+++ b/src/validator.cc
@@ -25,6 +25,7 @@
#include "binary-reader.h"
#include "cast.h"
#include "error-handler.h"
+#include "ir.h"
#include "type-checker.h"
#include "wast-parser-lexer-shared.h"
diff --git a/src/wast-lexer.cc b/src/wast-lexer.cc
index 0c4c3bd0..ce929d81 100644
--- a/src/wast-lexer.cc
+++ b/src/wast-lexer.cc
@@ -22,48 +22,22 @@
#include "config.h"
#include "circular-array.h"
+#include "error-handler.h"
#include "lexer-source.h"
#include "wast-parser.h"
-#include "wast-parser-lexer-shared.h"
-
-/* must be included after so some typedefs will be defined */
-#include "wast-parser-gen.hh"
/*!max:re2c */
#define INITIAL_LEXER_BUFFER_SIZE (64 * 1024)
-#define NAME_TO_VALUE(name) WABT_TOKEN_TYPE_##name
-
-#define LOOKAHEAD(name) \
- SetLookaheadToken(NAME_TO_VALUE(name)); \
- next_pos_ = cursor_; \
- continue
-
-#define RETURN(name) \
- SetToken(NAME_TO_VALUE(name)); \
- return PopLookaheadToken(lval, loc);
-
-#define RETURN_LPAR(name) \
- SetToken(NAME_TO_VALUE(name)); \
- if (IsLookaheadLpar()) { \
- SetLocation(loc); \
- return NAME_TO_VALUE(LPAR_##name); \
- } \
- return PopLookaheadToken(lval, loc);
-
-#define ERROR(...) \
- SetLocation(loc); \
- WastParserError(loc, this, parser, __VA_ARGS__)
+#define ERROR(...) parser->Error(GetLocation(), __VA_ARGS__)
#define BEGIN(c) cond = (c)
-#define FILL(n) \
- do { \
- if (Failed(Fill(loc, parser, (n)))) { \
- int value = NAME_TO_VALUE(EOF); \
- SetToken(value); \
- return PopLookaheadToken(lval, loc); \
- } \
+#define FILL(n) \
+ do { \
+ if (Failed(Fill((n)))) { \
+ RETURN(Eof); \
+ } \
} while (0)
#define MAYBE_MALFORMED_UTF8(desc) \
@@ -86,23 +60,163 @@
line_file_offset_ = FILE_OFFSET(cursor_); \
} while (0)
-#define TYPE(type_) SetType(Type::type_)
+#define RETURN(token) return Token(GetLocation(), TokenType::token);
-#define OPCODE(name) SetOpcode(Opcode::name);
+#define RETURN_LITERAL(token, literal) \
+ return Token(GetLocation(), TokenType::token, \
+ MakeLiteral(LiteralType::literal))
-#define LITERAL(type_) SetLiteral(LiteralType::type_)
+#define RETURN_TYPE(token, type) \
+ return Token(GetLocation(), TokenType::token, Type::type)
+
+#define RETURN_OPCODE(token, opcode) \
+ return Token(GetLocation(), TokenType::token, Opcode::opcode)
+
+#define RETURN_TEXT(token) \
+ return Token(GetLocation(), TokenType::token, GetText())
+
+#define RETURN_TEXT_AT(token, at) \
+ return Token(GetLocation(), TokenType::token, GetText(at))
namespace wabt {
-struct WastLexer::LexToken {
- Location loc_;
- int value_ = 0;
- Token lval_;
-};
+const char* GetTokenTypeName(TokenType token_type) {
+ static const char* s_names[] = {
+ "Invalid",
+ "Reserved",
+ "EOF",
+ "(",
+ ")",
+ "NAT",
+ "INT",
+ "FLOAT",
+ "TEXT",
+ "VAR",
+ "VALUETYPE",
+ "anyfunc",
+ "mut",
+ "nop",
+ "drop",
+ "block",
+ "end",
+ "if",
+ "then",
+ "else",
+ "loop",
+ "br",
+ "br_if",
+ "br_table",
+ "try",
+ "catch",
+ "catch_all",
+ "throw",
+ "rethrow",
+ "call",
+ "call_indirect",
+ "return",
+ "get_local",
+ "set_local",
+ "tee_local",
+ "get_global",
+ "set_global",
+ "LOAD",
+ "STORE",
+ "offset=",
+ "align=",
+ "CONST",
+ "UNARY",
+ "BINARY",
+ "COMPARE",
+ "CONVERT",
+ "select",
+ "unreachable",
+ "current_memory",
+ "grow_memory",
+ "func",
+ "start",
+ "type",
+ "param",
+ "result",
+ "local",
+ "global",
+ "table",
+ "elem",
+ "memory",
+ "data",
+ "offset",
+ "import",
+ "export",
+ "except",
+ "module",
+ "bin",
+ "quote",
+ "register",
+ "invoke",
+ "get",
+ "assert_malformed",
+ "assert_invalid",
+ "assert_unlinkable",
+ "assert_return",
+ "assert_return_canonical_nan",
+ "assert_return_arithmetic_nan",
+ "assert_trap",
+ "assert_exhaustion",
+ };
+
+ static_assert(
+ WABT_ARRAY_SIZE(s_names) == WABT_ENUM_COUNT(TokenType),
+ "Expected TokenType names list length to match number of TokenTypes.");
+
+ int x = static_cast<int>(token_type);
+ if (x < WABT_ENUM_COUNT(TokenType))
+ return s_names[x];
+
+ return "Invalid";
+}
+
+Token::Token(Location loc, TokenType token_type)
+ : loc(loc), token_type(token_type) {}
-struct WastLexer::Lookahead {
- CircularArray<LexToken, 4> tokens_;
-};
+Token::Token(Location loc, TokenType token_type, Type type)
+ : loc(loc), token_type(token_type), type(type) {}
+
+Token::Token(Location loc, TokenType token_type, StringTerminal text)
+ : loc(loc), token_type(token_type), text(text) {}
+
+Token::Token(Location loc, TokenType token_type, Opcode opcode)
+ : loc(loc), token_type(token_type), opcode(opcode) {}
+
+Token::Token(Location loc, TokenType token_type, LiteralTerminal literal)
+ : loc(loc), token_type(token_type), literal(literal) {}
+
+std::string Token::to_string() const {
+ switch (token_type) {
+ case TokenType::Nat:
+ case TokenType::Int:
+ case TokenType::Float:
+ return literal.text.to_string();
+
+ case TokenType::Reserved:
+ case TokenType::Text:
+ case TokenType::Var:
+ return text.to_string();
+
+ case TokenType::ValueType:
+ return GetTypeName(type);
+
+ case TokenType::Load:
+ case TokenType::Store:
+ case TokenType::Const:
+ case TokenType::Unary:
+ case TokenType::Binary:
+ case TokenType::Compare:
+ case TokenType::Convert:
+ return opcode.GetName();
+
+ default:
+ return GetTokenTypeName(token_type);
+ }
+}
WastLexer::WastLexer(std::unique_ptr<LexerSource> source, const char* filename)
: source_(std::move(source)),
@@ -112,8 +226,6 @@ WastLexer::WastLexer(std::unique_ptr<LexerSource> source, const char* filename)
comment_nesting_(0),
buffer_file_offset_(0),
line_file_offset_(0),
- lookahead_(new WastLexer::Lookahead()),
- token_(nullptr),
eof_(false),
buffer_(nullptr),
buffer_size_(0),
@@ -124,7 +236,6 @@ WastLexer::WastLexer(std::unique_ptr<LexerSource> source, const char* filename)
WastLexer::~WastLexer() {
delete[] buffer_;
- delete lookahead_;
}
// static
@@ -141,70 +252,19 @@ std::unique_ptr<WastLexer> WastLexer::CreateBufferLexer(const char* filename,
return std::unique_ptr<WastLexer>(new WastLexer(std::move(source), filename));
}
-bool WastLexer::IsLookaheadLpar() {
- return lookahead_->tokens_.size() == 2 // ignore current token
- && lookahead_->tokens_[0].value_ == WABT_TOKEN_TYPE_LPAR;
+Location WastLexer::GetLocation() {
+ return Location(filename_, line_, COLUMN(next_pos_), COLUMN(cursor_));
}
-int WastLexer::PopLookaheadToken(Token* lval, Location* loc) {
- WastLexer::LexToken* tok = &lookahead_->tokens_.front();
- *loc = tok->loc_;
- *lval = tok->lval_;
- int Result = tok->value_;
- lookahead_->tokens_.pop_front();
- if (lookahead_->tokens_.empty()) token_ = nullptr;
- return Result; \
+LiteralTerminal WastLexer::MakeLiteral(LiteralType type) {
+ return LiteralTerminal(type, GetText());
}
-void WastLexer::PushLookaheadToken() {
- WastLexer::LexToken tok;
- lookahead_->tokens_.push_back(tok);
- token_ = &lookahead_->tokens_.back();
+StringTerminal WastLexer::GetText(size_t offset) {
+ return StringTerminal(yytext + offset, yyleng - offset);
}
-void WastLexer::SetLiteral(LiteralType lit_typ) {
- token_->lval_.t_literal.type = lit_typ;
- token_->lval_.t_literal.text.data = yytext;
- token_->lval_.t_literal.text.size = yyleng;
-}
-
-void WastLexer::SetLocation(Location* loc) {
- loc->filename = filename_;
- loc->line = line_;
- loc->first_column = COLUMN(next_pos_);
- loc->last_column = COLUMN(cursor_);
-}
-
-void WastLexer::SetLookaheadToken(int value) {
- SetToken(value);
- PushLookaheadToken();
-}
-
-void WastLexer::SetOpcode(Opcode opc) {
- token_->lval_.t_opcode = opc;
-}
-
-void WastLexer::SetText() {
- token_->lval_.t_text.data = yytext;
- token_->lval_.t_text.size = yyleng;
-}
-
-void WastLexer::SetTextAt(size_t offset) {
- token_->lval_.t_text.data = yytext + offset;
- token_->lval_.t_text.size = yyleng - offset;
-}
-
-void WastLexer::SetToken(int value) {
- SetLocation(&token_->loc_);
- token_->value_ = value;
- next_pos_ = cursor_;
-}
-
-void WastLexer::SetType(Type ty) {
- token_->lval_.t_type = ty;
-}
-
-Result WastLexer::Fill(Location* loc, WastParser* parser, size_t need) {
+Result WastLexer::Fill(size_t need) {
if (eof_)
return Result::Error;
size_t free = next_pos_ - buffer_;
@@ -258,16 +318,10 @@ Result WastLexer::Fill(Location* loc, WastParser* parser, size_t need) {
return Result::Ok;
}
-int WastLexer::GetToken(Token* lval, Location* loc, WastParser* parser) {
+Token WastLexer::GetToken(WastParser* parser) {
/*!types:re2c*/
YYCONDTYPE cond = YYCOND_i; // i is the initial state.
- if (!lookahead_->tokens_.empty()) {
- return PopLookaheadToken(lval, loc);
- }
-
- PushLookaheadToken();
-
for (;;) {
next_pos_ = cursor_;
/*!re2c
@@ -309,15 +363,15 @@ int WastLexer::GetToken(Token* lval, Location* loc, WastParser* parser) {
// Should be ([\x21-\x7e] \ [()"; ])+ , but re2c doesn't like this...
reserved = [\x21\x23-\x27\x2a-\x3a\x3c-\x7e]+;
- <i> "(" { LOOKAHEAD(LPAR); }
- <i> ")" { RETURN(RPAR); }
- <i> nat { LITERAL(Int); RETURN(NAT); }
- <i> int { LITERAL(Int); RETURN(INT); }
- <i> float { LITERAL(Float); RETURN(FLOAT); }
- <i> hexfloat { LITERAL(Hexfloat); RETURN(FLOAT); }
- <i> infinity { LITERAL(Infinity); RETURN(FLOAT); }
- <i> nan { LITERAL(Nan); RETURN(FLOAT); }
- <i> text { SetText(); RETURN(TEXT); }
+ <i> "(" { RETURN(Lpar); }
+ <i> ")" { RETURN(Rpar); }
+ <i> nat { RETURN_LITERAL(Nat, Int); }
+ <i> int { RETURN_LITERAL(Int, Int); }
+ <i> float { RETURN_LITERAL(Float, Float); }
+ <i> hexfloat { RETURN_LITERAL(Float, Hexfloat); }
+ <i> infinity { RETURN_LITERAL(Float, Infinity); }
+ <i> nan { RETURN_LITERAL(Float, Nan); }
+ <i> text { RETURN_TEXT(Text); }
<i> '"' => BAD_TEXT { continue; }
<BAD_TEXT> character { continue; }
<BAD_TEXT> "\n" => i { ERROR("newline in string");
@@ -326,228 +380,226 @@ int WastLexer::GetToken(Token* lval, Location* loc, WastParser* parser) {
<BAD_TEXT> "\\". { ERROR("bad escape \"%.*s\"",
static_cast<int>(yyleng), yytext);
continue; }
- <BAD_TEXT> '"' => i { SetText(); RETURN(TEXT); }
+ <BAD_TEXT> '"' => i { RETURN_TEXT(Text); }
<BAD_TEXT> [^] { ERROR("illegal character in string");
continue; }
<BAD_TEXT> * { MAYBE_MALFORMED_UTF8(" in string"); }
- <i> "i32" { TYPE(I32); RETURN(VALUE_TYPE); }
- <i> "i64" { TYPE(I64); RETURN(VALUE_TYPE); }
- <i> "f32" { TYPE(F32); RETURN(VALUE_TYPE); }
- <i> "f64" { TYPE(F64); RETURN(VALUE_TYPE); }
- <i> "anyfunc" { RETURN(ANYFUNC); }
- <i> "mut" { RETURN(MUT); }
- <i> "nop" { RETURN(NOP); }
- <i> "block" { RETURN(BLOCK); }
- <i> "if" { RETURN(IF); }
- <i> "then" { RETURN(THEN); }
- <i> "else" { RETURN(ELSE); }
- <i> "loop" { RETURN(LOOP); }
- <i> "br" { RETURN(BR); }
- <i> "br_if" { RETURN(BR_IF); }
- <i> "br_table" { RETURN(BR_TABLE); }
- <i> "call" { RETURN(CALL); }
- <i> "call_indirect" { RETURN(CALL_INDIRECT); }
- <i> "drop" { RETURN(DROP); }
- <i> "end" { RETURN(END); }
- <i> "return" { RETURN(RETURN); }
- <i> "get_local" { RETURN(GET_LOCAL); }
- <i> "set_local" { RETURN(SET_LOCAL); }
- <i> "tee_local" { RETURN(TEE_LOCAL); }
- <i> "get_global" { RETURN(GET_GLOBAL); }
- <i> "set_global" { RETURN(SET_GLOBAL); }
- <i> "i32.load" { OPCODE(I32Load); RETURN(LOAD); }
- <i> "i64.load" { OPCODE(I64Load); RETURN(LOAD); }
- <i> "f32.load" { OPCODE(F32Load); RETURN(LOAD); }
- <i> "f64.load" { OPCODE(F64Load); RETURN(LOAD); }
- <i> "i32.store" { OPCODE(I32Store); RETURN(STORE); }
- <i> "i64.store" { OPCODE(I64Store); RETURN(STORE); }
- <i> "f32.store" { OPCODE(F32Store); RETURN(STORE); }
- <i> "f64.store" { OPCODE(F64Store); RETURN(STORE); }
- <i> "i32.load8_s" { OPCODE(I32Load8S); RETURN(LOAD); }
- <i> "i64.load8_s" { OPCODE(I64Load8S); RETURN(LOAD); }
- <i> "i32.load8_u" { OPCODE(I32Load8U); RETURN(LOAD); }
- <i> "i64.load8_u" { OPCODE(I64Load8U); RETURN(LOAD); }
- <i> "i32.load16_s" { OPCODE(I32Load16S); RETURN(LOAD); }
- <i> "i64.load16_s" { OPCODE(I64Load16S); RETURN(LOAD); }
- <i> "i32.load16_u" { OPCODE(I32Load16U); RETURN(LOAD); }
- <i> "i64.load16_u" { OPCODE(I64Load16U); RETURN(LOAD); }
- <i> "i64.load32_s" { OPCODE(I64Load32S); RETURN(LOAD); }
- <i> "i64.load32_u" { OPCODE(I64Load32U); RETURN(LOAD); }
- <i> "i32.store8" { OPCODE(I32Store8); RETURN(STORE); }
- <i> "i64.store8" { OPCODE(I64Store8); RETURN(STORE); }
- <i> "i32.store16" { OPCODE(I32Store16); RETURN(STORE); }
- <i> "i64.store16" { OPCODE(I64Store16); RETURN(STORE); }
- <i> "i64.store32" { OPCODE(I64Store32); RETURN(STORE); }
- <i> "offset=" nat { SetTextAt(7); RETURN(OFFSET_EQ_NAT); }
- <i> "align=" nat { SetTextAt(6); RETURN(ALIGN_EQ_NAT); }
- <i> "i32.const" { TYPE(I32); RETURN(CONST); }
- <i> "i64.const" { TYPE(I64); RETURN(CONST); }
- <i> "f32.const" { TYPE(F32); RETURN(CONST); }
- <i> "f64.const" { TYPE(F64); RETURN(CONST); }
- <i> "i32.eqz" { OPCODE(I32Eqz); RETURN(CONVERT); }
- <i> "i64.eqz" { OPCODE(I64Eqz); RETURN(CONVERT); }
- <i> "i32.clz" { OPCODE(I32Clz); RETURN(UNARY); }
- <i> "i64.clz" { OPCODE(I64Clz); RETURN(UNARY); }
- <i> "i32.ctz" { OPCODE(I32Ctz); RETURN(UNARY); }
- <i> "i64.ctz" { OPCODE(I64Ctz); RETURN(UNARY); }
- <i> "i32.popcnt" { OPCODE(I32Popcnt); RETURN(UNARY); }
- <i> "i64.popcnt" { OPCODE(I64Popcnt); RETURN(UNARY); }
- <i> "f32.neg" { OPCODE(F32Neg); RETURN(UNARY); }
- <i> "f64.neg" { OPCODE(F64Neg); RETURN(UNARY); }
- <i> "f32.abs" { OPCODE(F32Abs); RETURN(UNARY); }
- <i> "f64.abs" { OPCODE(F64Abs); RETURN(UNARY); }
- <i> "f32.sqrt" { OPCODE(F32Sqrt); RETURN(UNARY); }
- <i> "f64.sqrt" { OPCODE(F64Sqrt); RETURN(UNARY); }
- <i> "f32.ceil" { OPCODE(F32Ceil); RETURN(UNARY); }
- <i> "f64.ceil" { OPCODE(F64Ceil); RETURN(UNARY); }
- <i> "f32.floor" { OPCODE(F32Floor); RETURN(UNARY); }
- <i> "f64.floor" { OPCODE(F64Floor); RETURN(UNARY); }
- <i> "f32.trunc" { OPCODE(F32Trunc); RETURN(UNARY); }
- <i> "f64.trunc" { OPCODE(F64Trunc); RETURN(UNARY); }
- <i> "f32.nearest" { OPCODE(F32Nearest); RETURN(UNARY); }
- <i> "f64.nearest" { OPCODE(F64Nearest); RETURN(UNARY); }
- <i> "i32.add" { OPCODE(I32Add); RETURN(BINARY); }
- <i> "i64.add" { OPCODE(I64Add); RETURN(BINARY); }
- <i> "i32.sub" { OPCODE(I32Sub); RETURN(BINARY); }
- <i> "i64.sub" { OPCODE(I64Sub); RETURN(BINARY); }
- <i> "i32.mul" { OPCODE(I32Mul); RETURN(BINARY); }
- <i> "i64.mul" { OPCODE(I64Mul); RETURN(BINARY); }
- <i> "i32.div_s" { OPCODE(I32DivS); RETURN(BINARY); }
- <i> "i64.div_s" { OPCODE(I64DivS); RETURN(BINARY); }
- <i> "i32.div_u" { OPCODE(I32DivU); RETURN(BINARY); }
- <i> "i64.div_u" { OPCODE(I64DivU); RETURN(BINARY); }
- <i> "i32.rem_s" { OPCODE(I32RemS); RETURN(BINARY); }
- <i> "i64.rem_s" { OPCODE(I64RemS); RETURN(BINARY); }
- <i> "i32.rem_u" { OPCODE(I32RemU); RETURN(BINARY); }
- <i> "i64.rem_u" { OPCODE(I64RemU); RETURN(BINARY); }
- <i> "i32.and" { OPCODE(I32And); RETURN(BINARY); }
- <i> "i64.and" { OPCODE(I64And); RETURN(BINARY); }
- <i> "i32.or" { OPCODE(I32Or); RETURN(BINARY); }
- <i> "i64.or" { OPCODE(I64Or); RETURN(BINARY); }
- <i> "i32.xor" { OPCODE(I32Xor); RETURN(BINARY); }
- <i> "i64.xor" { OPCODE(I64Xor); RETURN(BINARY); }
- <i> "i32.shl" { OPCODE(I32Shl); RETURN(BINARY); }
- <i> "i64.shl" { OPCODE(I64Shl); RETURN(BINARY); }
- <i> "i32.shr_s" { OPCODE(I32ShrS); RETURN(BINARY); }
- <i> "i64.shr_s" { OPCODE(I64ShrS); RETURN(BINARY); }
- <i> "i32.shr_u" { OPCODE(I32ShrU); RETURN(BINARY); }
- <i> "i64.shr_u" { OPCODE(I64ShrU); RETURN(BINARY); }
- <i> "i32.rotl" { OPCODE(I32Rotl); RETURN(BINARY); }
- <i> "i64.rotl" { OPCODE(I64Rotl); RETURN(BINARY); }
- <i> "i32.rotr" { OPCODE(I32Rotr); RETURN(BINARY); }
- <i> "i64.rotr" { OPCODE(I64Rotr); RETURN(BINARY); }
- <i> "f32.add" { OPCODE(F32Add); RETURN(BINARY); }
- <i> "f64.add" { OPCODE(F64Add); RETURN(BINARY); }
- <i> "f32.sub" { OPCODE(F32Sub); RETURN(BINARY); }
- <i> "f64.sub" { OPCODE(F64Sub); RETURN(BINARY); }
- <i> "f32.mul" { OPCODE(F32Mul); RETURN(BINARY); }
- <i> "f64.mul" { OPCODE(F64Mul); RETURN(BINARY); }
- <i> "f32.div" { OPCODE(F32Div); RETURN(BINARY); }
- <i> "f64.div" { OPCODE(F64Div); RETURN(BINARY); }
- <i> "f32.min" { OPCODE(F32Min); RETURN(BINARY); }
- <i> "f64.min" { OPCODE(F64Min); RETURN(BINARY); }
- <i> "f32.max" { OPCODE(F32Max); RETURN(BINARY); }
- <i> "f64.max" { OPCODE(F64Max); RETURN(BINARY); }
- <i> "f32.copysign" { OPCODE(F32Copysign); RETURN(BINARY); }
- <i> "f64.copysign" { OPCODE(F64Copysign); RETURN(BINARY); }
- <i> "i32.eq" { OPCODE(I32Eq); RETURN(COMPARE); }
- <i> "i64.eq" { OPCODE(I64Eq); RETURN(COMPARE); }
- <i> "i32.ne" { OPCODE(I32Ne); RETURN(COMPARE); }
- <i> "i64.ne" { OPCODE(I64Ne); RETURN(COMPARE); }
- <i> "i32.lt_s" { OPCODE(I32LtS); RETURN(COMPARE); }
- <i> "i64.lt_s" { OPCODE(I64LtS); RETURN(COMPARE); }
- <i> "i32.lt_u" { OPCODE(I32LtU); RETURN(COMPARE); }
- <i> "i64.lt_u" { OPCODE(I64LtU); RETURN(COMPARE); }
- <i> "i32.le_s" { OPCODE(I32LeS); RETURN(COMPARE); }
- <i> "i64.le_s" { OPCODE(I64LeS); RETURN(COMPARE); }
- <i> "i32.le_u" { OPCODE(I32LeU); RETURN(COMPARE); }
- <i> "i64.le_u" { OPCODE(I64LeU); RETURN(COMPARE); }
- <i> "i32.gt_s" { OPCODE(I32GtS); RETURN(COMPARE); }
- <i> "i64.gt_s" { OPCODE(I64GtS); RETURN(COMPARE); }
- <i> "i32.gt_u" { OPCODE(I32GtU); RETURN(COMPARE); }
- <i> "i64.gt_u" { OPCODE(I64GtU); RETURN(COMPARE); }
- <i> "i32.ge_s" { OPCODE(I32GeS); RETURN(COMPARE); }
- <i> "i64.ge_s" { OPCODE(I64GeS); RETURN(COMPARE); }
- <i> "i32.ge_u" { OPCODE(I32GeU); RETURN(COMPARE); }
- <i> "i64.ge_u" { OPCODE(I64GeU); RETURN(COMPARE); }
- <i> "f32.eq" { OPCODE(F32Eq); RETURN(COMPARE); }
- <i> "f64.eq" { OPCODE(F64Eq); RETURN(COMPARE); }
- <i> "f32.ne" { OPCODE(F32Ne); RETURN(COMPARE); }
- <i> "f64.ne" { OPCODE(F64Ne); RETURN(COMPARE); }
- <i> "f32.lt" { OPCODE(F32Lt); RETURN(COMPARE); }
- <i> "f64.lt" { OPCODE(F64Lt); RETURN(COMPARE); }
- <i> "f32.le" { OPCODE(F32Le); RETURN(COMPARE); }
- <i> "f64.le" { OPCODE(F64Le); RETURN(COMPARE); }
- <i> "f32.gt" { OPCODE(F32Gt); RETURN(COMPARE); }
- <i> "f64.gt" { OPCODE(F64Gt); RETURN(COMPARE); }
- <i> "f32.ge" { OPCODE(F32Ge); RETURN(COMPARE); }
- <i> "f64.ge" { OPCODE(F64Ge); RETURN(COMPARE); }
- <i> "i64.extend_s/i32" { OPCODE(I64ExtendSI32); RETURN(CONVERT); }
- <i> "i64.extend_u/i32" { OPCODE(I64ExtendUI32); RETURN(CONVERT); }
- <i> "i32.wrap/i64" { OPCODE(I32WrapI64); RETURN(CONVERT); }
- <i> "i32.trunc_s/f32" { OPCODE(I32TruncSF32); RETURN(CONVERT); }
- <i> "i64.trunc_s/f32" { OPCODE(I64TruncSF32); RETURN(CONVERT); }
- <i> "i32.trunc_s/f64" { OPCODE(I32TruncSF64); RETURN(CONVERT); }
- <i> "i64.trunc_s/f64" { OPCODE(I64TruncSF64); RETURN(CONVERT); }
- <i> "i32.trunc_u/f32" { OPCODE(I32TruncUF32); RETURN(CONVERT); }
- <i> "i64.trunc_u/f32" { OPCODE(I64TruncUF32); RETURN(CONVERT); }
- <i> "i32.trunc_u/f64" { OPCODE(I32TruncUF64); RETURN(CONVERT); }
- <i> "i64.trunc_u/f64" { OPCODE(I64TruncUF64); RETURN(CONVERT); }
- <i> "f32.convert_s/i32" { OPCODE(F32ConvertSI32); RETURN(CONVERT); }
- <i> "f64.convert_s/i32" { OPCODE(F64ConvertSI32); RETURN(CONVERT); }
- <i> "f32.convert_s/i64" { OPCODE(F32ConvertSI64); RETURN(CONVERT); }
- <i> "f64.convert_s/i64" { OPCODE(F64ConvertSI64); RETURN(CONVERT); }
- <i> "f32.convert_u/i32" { OPCODE(F32ConvertUI32); RETURN(CONVERT); }
- <i> "f64.convert_u/i32" { OPCODE(F64ConvertUI32); RETURN(CONVERT); }
- <i> "f32.convert_u/i64" { OPCODE(F32ConvertUI64); RETURN(CONVERT); }
- <i> "f64.convert_u/i64" { OPCODE(F64ConvertUI64); RETURN(CONVERT); }
- <i> "f64.promote/f32" { OPCODE(F64PromoteF32); RETURN(CONVERT); }
- <i> "f32.demote/f64" { OPCODE(F32DemoteF64); RETURN(CONVERT); }
- <i> "f32.reinterpret/i32" { OPCODE(F32ReinterpretI32); RETURN(CONVERT); }
- <i> "i32.reinterpret/f32" { OPCODE(I32ReinterpretF32); RETURN(CONVERT); }
- <i> "f64.reinterpret/i64" { OPCODE(F64ReinterpretI64); RETURN(CONVERT); }
- <i> "i64.reinterpret/f64" { OPCODE(I64ReinterpretF64); RETURN(CONVERT); }
- <i> "select" { RETURN(SELECT); }
- <i> "unreachable" { RETURN(UNREACHABLE); }
- <i> "current_memory" { RETURN(CURRENT_MEMORY); }
- <i> "grow_memory" { RETURN(GROW_MEMORY); }
- <i> "type" { RETURN(TYPE); }
- <i> "func" { RETURN(FUNC); }
- <i> "param" { RETURN(PARAM); }
- <i> "result" { RETURN(RESULT); }
- <i> "local" { RETURN(LOCAL); }
- <i> "global" { RETURN(GLOBAL); }
- <i> "module" { RETURN(MODULE); }
- <i> "binary" { RETURN(BIN); }
- <i> "quote" { RETURN(QUOTE); }
- <i> "table" { RETURN(TABLE); }
- <i> "memory" { RETURN(MEMORY); }
- <i> "start" { RETURN(START); }
- <i> "elem" { RETURN(ELEM); }
- <i> "data" { RETURN(DATA); }
- <i> "offset" { RETURN(OFFSET); }
- <i> "import" { RETURN(IMPORT); }
- <i> "export" { RETURN(EXPORT); }
- <i> "except" { RETURN(EXCEPT); }
- <i> "register" { RETURN(REGISTER); }
- <i> "invoke" { RETURN(INVOKE); }
- <i> "get" { RETURN(GET); }
- <i> "assert_malformed" { RETURN(ASSERT_MALFORMED); }
- <i> "assert_invalid" { RETURN(ASSERT_INVALID); }
- <i> "assert_unlinkable" { RETURN(ASSERT_UNLINKABLE); }
- <i> "assert_return" { RETURN(ASSERT_RETURN); }
- <i> "assert_return_canonical_nan" {
- RETURN(ASSERT_RETURN_CANONICAL_NAN); }
- <i> "assert_return_arithmetic_nan" {
- RETURN(ASSERT_RETURN_ARITHMETIC_NAN); }
- <i> "assert_trap" { RETURN(ASSERT_TRAP); }
- <i> "assert_exhaustion" { RETURN(ASSERT_EXHAUSTION); }
- <i> "try" { RETURN(TRY); }
- <i> "catch" { RETURN_LPAR(CATCH); }
- <i> "catch_all" { RETURN_LPAR(CATCH_ALL); }
- <i> "throw" { RETURN(THROW); }
- <i> "rethrow" { RETURN(RETHROW); }
- <i> name { SetText(); RETURN(VAR); }
+ <i> "i32" { RETURN_TYPE(ValueType, I32); }
+ <i> "i64" { RETURN_TYPE(ValueType, I64); }
+ <i> "f32" { RETURN_TYPE(ValueType, F32); }
+ <i> "f64" { RETURN_TYPE(ValueType, F64); }
+ <i> "anyfunc" { RETURN(Anyfunc); }
+ <i> "mut" { RETURN(Mut); }
+ <i> "nop" { RETURN(Nop); }
+ <i> "block" { RETURN(Block); }
+ <i> "if" { RETURN(If); }
+ <i> "then" { RETURN(Then); }
+ <i> "else" { RETURN(Else); }
+ <i> "loop" { RETURN(Loop); }
+ <i> "br" { RETURN(Br); }
+ <i> "br_if" { RETURN(BrIf); }
+ <i> "br_table" { RETURN(BrTable); }
+ <i> "call" { RETURN(Call); }
+ <i> "call_indirect" { RETURN(CallIndirect); }
+ <i> "drop" { RETURN(Drop); }
+ <i> "end" { RETURN(End); }
+ <i> "return" { RETURN(Return); }
+ <i> "get_local" { RETURN(GetLocal); }
+ <i> "set_local" { RETURN(SetLocal); }
+ <i> "tee_local" { RETURN(TeeLocal); }
+ <i> "get_global" { RETURN(GetGlobal); }
+ <i> "set_global" { RETURN(SetGlobal); }
+ <i> "i32.load" { RETURN_OPCODE(Load, I32Load); }
+ <i> "i64.load" { RETURN_OPCODE(Load, I64Load); }
+ <i> "f32.load" { RETURN_OPCODE(Load, F32Load); }
+ <i> "f64.load" { RETURN_OPCODE(Load, F64Load); }
+ <i> "i32.store" { RETURN_OPCODE(Store, I32Store); }
+ <i> "i64.store" { RETURN_OPCODE(Store, I64Store); }
+ <i> "f32.store" { RETURN_OPCODE(Store, F32Store); }
+ <i> "f64.store" { RETURN_OPCODE(Store, F64Store); }
+ <i> "i32.load8_s" { RETURN_OPCODE(Load, I32Load8S); }
+ <i> "i64.load8_s" { RETURN_OPCODE(Load, I64Load8S); }
+ <i> "i32.load8_u" { RETURN_OPCODE(Load, I32Load8U); }
+ <i> "i64.load8_u" { RETURN_OPCODE(Load, I64Load8U); }
+ <i> "i32.load16_s" { RETURN_OPCODE(Load, I32Load16S); }
+ <i> "i64.load16_s" { RETURN_OPCODE(Load, I64Load16S); }
+ <i> "i32.load16_u" { RETURN_OPCODE(Load, I32Load16U); }
+ <i> "i64.load16_u" { RETURN_OPCODE(Load, I64Load16U); }
+ <i> "i64.load32_s" { RETURN_OPCODE(Load, I64Load32S); }
+ <i> "i64.load32_u" { RETURN_OPCODE(Load, I64Load32U); }
+ <i> "i32.store8" { RETURN_OPCODE(Store, I32Store8); }
+ <i> "i64.store8" { RETURN_OPCODE(Store, I64Store8); }
+ <i> "i32.store16" { RETURN_OPCODE(Store, I32Store16); }
+ <i> "i64.store16" { RETURN_OPCODE(Store, I64Store16); }
+ <i> "i64.store32" { RETURN_OPCODE(Store, I64Store32); }
+ <i> "offset=" nat { RETURN_TEXT_AT(OffsetEqNat, 7); }
+ <i> "align=" nat { RETURN_TEXT_AT(AlignEqNat, 6); }
+ <i> "i32.const" { RETURN_OPCODE(Const, I32Const); }
+ <i> "i64.const" { RETURN_OPCODE(Const, I64Const); }
+ <i> "f32.const" { RETURN_OPCODE(Const, F32Const); }
+ <i> "f64.const" { RETURN_OPCODE(Const, F64Const); }
+ <i> "i32.eqz" { RETURN_OPCODE(Convert, I32Eqz); }
+ <i> "i64.eqz" { RETURN_OPCODE(Convert, I64Eqz); }
+ <i> "i32.clz" { RETURN_OPCODE(Unary, I32Clz); }
+ <i> "i64.clz" { RETURN_OPCODE(Unary, I64Clz); }
+ <i> "i32.ctz" { RETURN_OPCODE(Unary, I32Ctz); }
+ <i> "i64.ctz" { RETURN_OPCODE(Unary, I64Ctz); }
+ <i> "i32.popcnt" { RETURN_OPCODE(Unary, I32Popcnt); }
+ <i> "i64.popcnt" { RETURN_OPCODE(Unary, I64Popcnt); }
+ <i> "f32.neg" { RETURN_OPCODE(Unary, F32Neg); }
+ <i> "f64.neg" { RETURN_OPCODE(Unary, F64Neg); }
+ <i> "f32.abs" { RETURN_OPCODE(Unary, F32Abs); }
+ <i> "f64.abs" { RETURN_OPCODE(Unary, F64Abs); }
+ <i> "f32.sqrt" { RETURN_OPCODE(Unary, F32Sqrt); }
+ <i> "f64.sqrt" { RETURN_OPCODE(Unary, F64Sqrt); }
+ <i> "f32.ceil" { RETURN_OPCODE(Unary, F32Ceil); }
+ <i> "f64.ceil" { RETURN_OPCODE(Unary, F64Ceil); }
+ <i> "f32.floor" { RETURN_OPCODE(Unary, F32Floor); }
+ <i> "f64.floor" { RETURN_OPCODE(Unary, F64Floor); }
+ <i> "f32.trunc" { RETURN_OPCODE(Unary, F32Trunc); }
+ <i> "f64.trunc" { RETURN_OPCODE(Unary, F64Trunc); }
+ <i> "f32.nearest" { RETURN_OPCODE(Unary, F32Nearest); }
+ <i> "f64.nearest" { RETURN_OPCODE(Unary, F64Nearest); }
+ <i> "i32.add" { RETURN_OPCODE(Binary, I32Add); }
+ <i> "i64.add" { RETURN_OPCODE(Binary, I64Add); }
+ <i> "i32.sub" { RETURN_OPCODE(Binary, I32Sub); }
+ <i> "i64.sub" { RETURN_OPCODE(Binary, I64Sub); }
+ <i> "i32.mul" { RETURN_OPCODE(Binary, I32Mul); }
+ <i> "i64.mul" { RETURN_OPCODE(Binary, I64Mul); }
+ <i> "i32.div_s" { RETURN_OPCODE(Binary, I32DivS); }
+ <i> "i64.div_s" { RETURN_OPCODE(Binary, I64DivS); }
+ <i> "i32.div_u" { RETURN_OPCODE(Binary, I32DivU); }
+ <i> "i64.div_u" { RETURN_OPCODE(Binary, I64DivU); }
+ <i> "i32.rem_s" { RETURN_OPCODE(Binary, I32RemS); }
+ <i> "i64.rem_s" { RETURN_OPCODE(Binary, I64RemS); }
+ <i> "i32.rem_u" { RETURN_OPCODE(Binary, I32RemU); }
+ <i> "i64.rem_u" { RETURN_OPCODE(Binary, I64RemU); }
+ <i> "i32.and" { RETURN_OPCODE(Binary, I32And); }
+ <i> "i64.and" { RETURN_OPCODE(Binary, I64And); }
+ <i> "i32.or" { RETURN_OPCODE(Binary, I32Or); }
+ <i> "i64.or" { RETURN_OPCODE(Binary, I64Or); }
+ <i> "i32.xor" { RETURN_OPCODE(Binary, I32Xor); }
+ <i> "i64.xor" { RETURN_OPCODE(Binary, I64Xor); }
+ <i> "i32.shl" { RETURN_OPCODE(Binary, I32Shl); }
+ <i> "i64.shl" { RETURN_OPCODE(Binary, I64Shl); }
+ <i> "i32.shr_s" { RETURN_OPCODE(Binary, I32ShrS); }
+ <i> "i64.shr_s" { RETURN_OPCODE(Binary, I64ShrS); }
+ <i> "i32.shr_u" { RETURN_OPCODE(Binary, I32ShrU); }
+ <i> "i64.shr_u" { RETURN_OPCODE(Binary, I64ShrU); }
+ <i> "i32.rotl" { RETURN_OPCODE(Binary, I32Rotl); }
+ <i> "i64.rotl" { RETURN_OPCODE(Binary, I64Rotl); }
+ <i> "i32.rotr" { RETURN_OPCODE(Binary, I32Rotr); }
+ <i> "i64.rotr" { RETURN_OPCODE(Binary, I64Rotr); }
+ <i> "f32.add" { RETURN_OPCODE(Binary, F32Add); }
+ <i> "f64.add" { RETURN_OPCODE(Binary, F64Add); }
+ <i> "f32.sub" { RETURN_OPCODE(Binary, F32Sub); }
+ <i> "f64.sub" { RETURN_OPCODE(Binary, F64Sub); }
+ <i> "f32.mul" { RETURN_OPCODE(Binary, F32Mul); }
+ <i> "f64.mul" { RETURN_OPCODE(Binary, F64Mul); }
+ <i> "f32.div" { RETURN_OPCODE(Binary, F32Div); }
+ <i> "f64.div" { RETURN_OPCODE(Binary, F64Div); }
+ <i> "f32.min" { RETURN_OPCODE(Binary, F32Min); }
+ <i> "f64.min" { RETURN_OPCODE(Binary, F64Min); }
+ <i> "f32.max" { RETURN_OPCODE(Binary, F32Max); }
+ <i> "f64.max" { RETURN_OPCODE(Binary, F64Max); }
+ <i> "f32.copysign" { RETURN_OPCODE(Binary, F32Copysign); }
+ <i> "f64.copysign" { RETURN_OPCODE(Binary, F64Copysign); }
+ <i> "i32.eq" { RETURN_OPCODE(Compare, I32Eq); }
+ <i> "i64.eq" { RETURN_OPCODE(Compare, I64Eq); }
+ <i> "i32.ne" { RETURN_OPCODE(Compare, I32Ne); }
+ <i> "i64.ne" { RETURN_OPCODE(Compare, I64Ne); }
+ <i> "i32.lt_s" { RETURN_OPCODE(Compare, I32LtS); }
+ <i> "i64.lt_s" { RETURN_OPCODE(Compare, I64LtS); }
+ <i> "i32.lt_u" { RETURN_OPCODE(Compare, I32LtU); }
+ <i> "i64.lt_u" { RETURN_OPCODE(Compare, I64LtU); }
+ <i> "i32.le_s" { RETURN_OPCODE(Compare, I32LeS); }
+ <i> "i64.le_s" { RETURN_OPCODE(Compare, I64LeS); }
+ <i> "i32.le_u" { RETURN_OPCODE(Compare, I32LeU); }
+ <i> "i64.le_u" { RETURN_OPCODE(Compare, I64LeU); }
+ <i> "i32.gt_s" { RETURN_OPCODE(Compare, I32GtS); }
+ <i> "i64.gt_s" { RETURN_OPCODE(Compare, I64GtS); }
+ <i> "i32.gt_u" { RETURN_OPCODE(Compare, I32GtU); }
+ <i> "i64.gt_u" { RETURN_OPCODE(Compare, I64GtU); }
+ <i> "i32.ge_s" { RETURN_OPCODE(Compare, I32GeS); }
+ <i> "i64.ge_s" { RETURN_OPCODE(Compare, I64GeS); }
+ <i> "i32.ge_u" { RETURN_OPCODE(Compare, I32GeU); }
+ <i> "i64.ge_u" { RETURN_OPCODE(Compare, I64GeU); }
+ <i> "f32.eq" { RETURN_OPCODE(Compare, F32Eq); }
+ <i> "f64.eq" { RETURN_OPCODE(Compare, F64Eq); }
+ <i> "f32.ne" { RETURN_OPCODE(Compare, F32Ne); }
+ <i> "f64.ne" { RETURN_OPCODE(Compare, F64Ne); }
+ <i> "f32.lt" { RETURN_OPCODE(Compare, F32Lt); }
+ <i> "f64.lt" { RETURN_OPCODE(Compare, F64Lt); }
+ <i> "f32.le" { RETURN_OPCODE(Compare, F32Le); }
+ <i> "f64.le" { RETURN_OPCODE(Compare, F64Le); }
+ <i> "f32.gt" { RETURN_OPCODE(Compare, F32Gt); }
+ <i> "f64.gt" { RETURN_OPCODE(Compare, F64Gt); }
+ <i> "f32.ge" { RETURN_OPCODE(Compare, F32Ge); }
+ <i> "f64.ge" { RETURN_OPCODE(Compare, F64Ge); }
+ <i> "i64.extend_s/i32" { RETURN_OPCODE(Convert, I64ExtendSI32); }
+ <i> "i64.extend_u/i32" { RETURN_OPCODE(Convert, I64ExtendUI32); }
+ <i> "i32.wrap/i64" { RETURN_OPCODE(Convert, I32WrapI64); }
+ <i> "i32.trunc_s/f32" { RETURN_OPCODE(Convert, I32TruncSF32); }
+ <i> "i64.trunc_s/f32" { RETURN_OPCODE(Convert, I64TruncSF32); }
+ <i> "i32.trunc_s/f64" { RETURN_OPCODE(Convert, I32TruncSF64); }
+ <i> "i64.trunc_s/f64" { RETURN_OPCODE(Convert, I64TruncSF64); }
+ <i> "i32.trunc_u/f32" { RETURN_OPCODE(Convert, I32TruncUF32); }
+ <i> "i64.trunc_u/f32" { RETURN_OPCODE(Convert, I64TruncUF32); }
+ <i> "i32.trunc_u/f64" { RETURN_OPCODE(Convert, I32TruncUF64); }
+ <i> "i64.trunc_u/f64" { RETURN_OPCODE(Convert, I64TruncUF64); }
+ <i> "f32.convert_s/i32" { RETURN_OPCODE(Convert, F32ConvertSI32); }
+ <i> "f64.convert_s/i32" { RETURN_OPCODE(Convert, F64ConvertSI32); }
+ <i> "f32.convert_s/i64" { RETURN_OPCODE(Convert, F32ConvertSI64); }
+ <i> "f64.convert_s/i64" { RETURN_OPCODE(Convert, F64ConvertSI64); }
+ <i> "f32.convert_u/i32" { RETURN_OPCODE(Convert, F32ConvertUI32); }
+ <i> "f64.convert_u/i32" { RETURN_OPCODE(Convert, F64ConvertUI32); }
+ <i> "f32.convert_u/i64" { RETURN_OPCODE(Convert, F32ConvertUI64); }
+ <i> "f64.convert_u/i64" { RETURN_OPCODE(Convert, F64ConvertUI64); }
+ <i> "f64.promote/f32" { RETURN_OPCODE(Convert, F64PromoteF32); }
+ <i> "f32.demote/f64" { RETURN_OPCODE(Convert, F32DemoteF64); }
+ <i> "f32.reinterpret/i32" { RETURN_OPCODE(Convert, F32ReinterpretI32); }
+ <i> "i32.reinterpret/f32" { RETURN_OPCODE(Convert, I32ReinterpretF32); }
+ <i> "f64.reinterpret/i64" { RETURN_OPCODE(Convert, F64ReinterpretI64); }
+ <i> "i64.reinterpret/f64" { RETURN_OPCODE(Convert, I64ReinterpretF64); }
+ <i> "select" { RETURN(Select); }
+ <i> "unreachable" { RETURN(Unreachable); }
+ <i> "current_memory" { RETURN(CurrentMemory); }
+ <i> "grow_memory" { RETURN(GrowMemory); }
+ <i> "type" { RETURN(Type); }
+ <i> "func" { RETURN(Func); }
+ <i> "param" { RETURN(Param); }
+ <i> "result" { RETURN(Result); }
+ <i> "local" { RETURN(Local); }
+ <i> "global" { RETURN(Global); }
+ <i> "module" { RETURN(Module); }
+ <i> "binary" { RETURN(Bin); }
+ <i> "quote" { RETURN(Quote); }
+ <i> "table" { RETURN(Table); }
+ <i> "memory" { RETURN(Memory); }
+ <i> "start" { RETURN(Start); }
+ <i> "elem" { RETURN(Elem); }
+ <i> "data" { RETURN(Data); }
+ <i> "offset" { RETURN(Offset); }
+ <i> "import" { RETURN(Import); }
+ <i> "export" { RETURN(Export); }
+ <i> "except" { RETURN(Except); }
+ <i> "register" { RETURN(Register); }
+ <i> "invoke" { RETURN(Invoke); }
+ <i> "get" { RETURN(Get); }
+ <i> "assert_malformed" { RETURN(AssertMalformed); }
+ <i> "assert_invalid" { RETURN(AssertInvalid); }
+ <i> "assert_unlinkable" { RETURN(AssertUnlinkable); }
+ <i> "assert_return" { RETURN(AssertReturn); }
+ <i> "assert_return_canonical_nan" { RETURN(AssertReturnCanonicalNan); }
+ <i> "assert_return_arithmetic_nan" { RETURN(AssertReturnArithmeticNan); }
+ <i> "assert_trap" { RETURN(AssertTrap); }
+ <i> "assert_exhaustion" { RETURN(AssertExhaustion); }
+ <i> "try" { RETURN(Try); }
+ <i> "catch" { RETURN(Catch); }
+ <i> "catch_all" { RETURN(CatchAll); }
+ <i> "throw" { RETURN(Throw); }
+ <i> "rethrow" { RETURN(Rethrow); }
+ <i> name { RETURN_TEXT(Var); }
<i> ";;" => LINE_COMMENT { continue; }
<LINE_COMMENT> "\n" => i { NEWLINE; continue; }
@@ -562,9 +614,7 @@ int WastLexer::GetToken(Token* lval, Location* loc, WastParser* parser) {
<BLOCK_COMMENT> * { MAYBE_MALFORMED_UTF8(" in block comment"); }
<i> "\n" { NEWLINE; continue; }
<i> [ \t\r]+ { continue; }
- <i> reserved { ERROR("unexpected token \"%.*s\"",
- static_cast<int>(yyleng), yytext);
- continue; }
+ <i> reserved { RETURN_TEXT(Reserved); }
<i> [^] { ERROR("unexpected char"); continue; }
<*> * { MAYBE_MALFORMED_UTF8(""); }
*/
diff --git a/src/wast-lexer.h b/src/wast-lexer.h
index 032892ef..20ef2bb6 100644
--- a/src/wast-lexer.h
+++ b/src/wast-lexer.h
@@ -28,12 +28,143 @@
namespace wabt {
-union Token;
-struct WastParser;
+class ErrorHandler;
class LexerSource;
+class WastParser;
+
+struct StringTerminal {
+ StringTerminal() = default;
+ StringTerminal(const char* data, size_t size) : data(data), size(size) {}
+
+ const char* data;
+ size_t size;
+
+ // Helper functions.
+ std::string to_string() const { return std::string(data, size); }
+ string_view to_string_view() const { return string_view(data, size); }
+};
+
+struct LiteralTerminal {
+ LiteralTerminal() = default;
+ LiteralTerminal(LiteralType type, StringTerminal text)
+ : type(type), text(text) {}
+
+ LiteralType type;
+ StringTerminal text;
+};
+
+enum class TokenType {
+ Invalid,
+ Reserved,
+ Eof,
+ Lpar,
+ Rpar,
+ Nat,
+ Int,
+ Float,
+ Text,
+ Var,
+ ValueType,
+ Anyfunc,
+ Mut,
+ Nop,
+ Drop,
+ Block,
+ End,
+ If,
+ Then,
+ Else,
+ Loop,
+ Br,
+ BrIf,
+ BrTable,
+ Try,
+ Catch,
+ CatchAll,
+ Throw,
+ Rethrow,
+ Call,
+ CallIndirect,
+ Return,
+ GetLocal,
+ SetLocal,
+ TeeLocal,
+ GetGlobal,
+ SetGlobal,
+ Load,
+ Store,
+ OffsetEqNat,
+ AlignEqNat,
+ Const,
+ Unary,
+ Binary,
+ Compare,
+ Convert,
+ Select,
+ Unreachable,
+ CurrentMemory,
+ GrowMemory,
+ Func,
+ Start,
+ Type,
+ Param,
+ Result,
+ Local,
+ Global,
+ Table,
+ Elem,
+ Memory,
+ Data,
+ Offset,
+ Import,
+ Export,
+ Except,
+ Module,
+ Bin,
+ Quote,
+ Register,
+ Invoke,
+ Get,
+ AssertMalformed,
+ AssertInvalid,
+ AssertUnlinkable,
+ AssertReturn,
+ AssertReturnCanonicalNan,
+ AssertReturnArithmeticNan,
+ AssertTrap,
+ AssertExhaustion,
+
+ First = Invalid,
+ Last = AssertExhaustion,
+};
+
+const char* GetTokenTypeName(TokenType);
+
+struct Token {
+ Token() : token_type(TokenType::Invalid) {}
+ Token(Location, TokenType);
+ Token(Location, TokenType, Type);
+ Token(Location, TokenType, StringTerminal);
+ Token(Location, TokenType, Opcode);
+ Token(Location, TokenType, LiteralTerminal);
+
+ Location loc;
+ TokenType token_type;
+
+ union {
+ StringTerminal text;
+ Type type;
+ Opcode opcode;
+ LiteralTerminal literal;
+ };
+
+ std::string to_string() const;
+};
class WastLexer {
public:
+ WABT_DISALLOW_COPY_AND_ASSIGN(WastLexer);
+
WastLexer(std::unique_ptr<LexerSource> source, const char* filename);
~WastLexer();
@@ -43,14 +174,17 @@ class WastLexer {
const void* data,
size_t size);
- int GetToken(Token* lval, Location* loc, WastParser* parser);
- Result Fill(Location* loc, WastParser* parser, size_t need);
+ Token GetToken(WastParser* parser);
+ Result Fill(size_t need);
+ // TODO(binji): Move this out of the lexer.
LexerSourceLineFinder& line_finder() { return line_finder_; }
private:
- struct Lookahead;
- struct LexToken;
+ Location GetLocation();
+ LiteralTerminal MakeLiteral(LiteralType);
+ StringTerminal GetText(size_t at = 0);
+
std::unique_ptr<LexerSource> source_;
LexerSourceLineFinder line_finder_;
const char* filename_;
@@ -58,8 +192,6 @@ class WastLexer {
int comment_nesting_;
size_t buffer_file_offset_; // File offset of the start of the buffer.
size_t line_file_offset_; // File offset of the start of the current line.
- Lookahead* lookahead_;
- LexToken* token_;
// Lexing data needed by re2c.
bool eof_;
@@ -69,20 +201,6 @@ class WastLexer {
char* next_pos_;
char* cursor_;
char* limit_;
-
- bool IsLookaheadLpar();
- int PopLookaheadToken(Token* lval, Location* loc);
- void PushLookaheadToken();
- void SetLiteral(LiteralType typ);
- void SetLocation(Location* Loc);
- void SetLookaheadToken(int value);
- void SetOpcode(Opcode opc);
- void SetText();
- void SetTextAt(size_t offset);
- void SetToken(int value);
- void SetType(Type ty);
-
- WABT_DISALLOW_COPY_AND_ASSIGN(WastLexer);
};
} // namespace wabt
diff --git a/src/wast-parser-lexer-shared.cc b/src/wast-parser-lexer-shared.cc
index c9ad9b61..80a9b8bd 100644
--- a/src/wast-parser-lexer-shared.cc
+++ b/src/wast-parser-lexer-shared.cc
@@ -16,27 +16,14 @@
#include "wast-parser-lexer-shared.h"
-#include <cstdarg>
-#include <cstdio>
-#include <cstring>
-#include <string>
+#include "common.h"
+#include "error-handler.h"
+#include "wast-lexer.h"
namespace wabt {
-void WastParserError(Location* loc,
- WastLexer* lexer,
- WastParser* parser,
- const char* format,
- ...) {
- parser->errors++;
- va_list args;
- va_start(args, format);
- WastFormatError(parser->error_handler, loc, lexer, format, args);
- va_end(args);
-}
-
void WastFormatError(ErrorHandler* error_handler,
- const struct Location* loc,
+ const Location* loc,
WastLexer* lexer,
const char* format,
va_list args) {
diff --git a/src/wast-parser-lexer-shared.h b/src/wast-parser-lexer-shared.h
index b5774d58..f3b4607a 100644
--- a/src/wast-parser-lexer-shared.h
+++ b/src/wast-parser-lexer-shared.h
@@ -18,120 +18,16 @@
#define WABT_WAST_PARSER_LEXER_SHARED_H_
#include <cstdarg>
-#include <memory>
-
-#include "common.h"
-#include "error-handler.h"
-#include "ir.h"
-#include "literal.h"
-#include "wast-parser.h"
-
-#define WABT_WAST_PARSER_STYPE Token
-#define WABT_WAST_PARSER_LTYPE Location
-#define YYSTYPE WABT_WAST_PARSER_STYPE
-#define YYLTYPE WABT_WAST_PARSER_LTYPE
namespace wabt {
-// Terminal types are C-style structs so they don't need to be allocated. Any
-// string memory used by terminals is shared with the lexer and does not need
-// to be dellocated.
-
-struct StringTerminal {
- const char* data;
- size_t size;
-
- // Helper functions.
- std::string to_string() const { return std::string(data, size); }
- string_view to_string_view() const { return string_view(data, size); }
-};
-
-struct LiteralTerminal {
- LiteralType type;
- StringTerminal text;
-};
-
-struct Literal {
- explicit Literal(LiteralTerminal terminal)
- : type(terminal.type), text(terminal.text.to_string()) {}
-
- LiteralType type;
- std::string text;
-};
-
-typedef std::vector<std::string> TextVector;
-
-union Token {
- // Terminals
- StringTerminal t_text;
- Type t_type;
- Opcode t_opcode;
- LiteralTerminal t_literal;
-
- Token() {}
-
- // Non-terminals
- // Some of these use pointers to keep the size of Token down; copying the
- // tokens is a hotspot when parsing large files.
- Action* action;
- Block* block;
- Catch* catch_;
- Command* command;
- CommandPtrVector* commands;
- Const const_;
- ConstVector* consts;
- DataSegment* data_segment;
- ElemSegment* elem_segment;
- Exception* exception;
- Export* export_;
- Expr* expr;
- ExprList* expr_list;
- Func* func;
- FuncSignature* func_sig;
- FuncType* func_type;
- Global* global;
- Import* import;
- Limits limits;
- Literal* literal;
- Memory* memory;
- Module* module;
- ModuleField* module_field;
- ModuleFieldList* module_fields;
- ScriptModule* script_module;
- Script* script;
- std::string* string;
- Table* table;
- TextVector* texts;
- TryExpr* try_expr;
- TypeVector* types;
- uint32_t u32;
- uint64_t u64;
- Var* var;
- VarVector* vars;
-};
-
-struct WastParser {
- Script* script;
- ErrorHandler* error_handler;
- int errors;
- /* Cached pointers to reallocated parser buffers, so they don't leak. */
- int16_t* yyssa;
- YYSTYPE* yyvsa;
- YYLTYPE* yylsa;
- WastParseOptions* options;
-};
+class ErrorHandler;
+struct Location;
+class WastLexer;
-int WastLexerLex(union Token*,
- struct Location*,
- WastLexer*,
- struct WastParser*);
-void WABT_PRINTF_FORMAT(4, 5) WastParserError(struct Location*,
- WastLexer*,
- struct WastParser*,
- const char*,
- ...);
+// TODO(binji): Move this somewhere else.
void WastFormatError(ErrorHandler*,
- const struct Location*,
+ const Location*,
WastLexer*,
const char* format,
va_list);
diff --git a/src/wast-parser.cc b/src/wast-parser.cc
new file mode 100644
index 00000000..5174d4a4
--- /dev/null
+++ b/src/wast-parser.cc
@@ -0,0 +1,2010 @@
+/*
+ * Copyright 2017 WebAssembly Community Group participants
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "wast-parser.h"
+
+#include "binary-reader.h"
+#include "binary-reader-ir.h"
+#include "cast.h"
+#include "error-handler.h"
+#include "wast-parser-lexer-shared.h"
+
+#define WABT_TRACING 0
+#include "tracing.h"
+
+#define CHECK_RESULT(expr) \
+ do { \
+ if (Failed(expr)) \
+ return Result::Error; \
+ } while (0)
+
+#define EXPECT(token_type) CHECK_RESULT(Expect(TokenType::token_type))
+
+namespace wabt {
+
+namespace {
+
+bool IsPowerOfTwo(uint32_t x) {
+ return x && ((x & (x - 1)) == 0);
+}
+
+template <typename OutputIter>
+void RemoveEscapes(string_view text, OutputIter dest) {
+ // Remove surrounding quotes; if any. This may be empty if the string was
+ // invalid (e.g. if it contained a bad escape sequence).
+ if (text.size() <= 2)
+ return;
+
+ text = text.substr(1, text.size() - 2);
+
+ const char* src = text.data();
+ const char* end = text.data() + text.size();
+
+ while (src < end) {
+ if (*src == '\\') {
+ src++;
+ switch (*src) {
+ case 'n':
+ *dest++ = '\n';
+ break;
+ case 'r':
+ *dest++ = '\r';
+ break;
+ case 't':
+ *dest++ = '\t';
+ break;
+ case '\\':
+ *dest++ = '\\';
+ break;
+ case '\'':
+ *dest++ = '\'';
+ break;
+ case '\"':
+ *dest++ = '\"';
+ break;
+ default: {
+ // The string should be validated already, so we know this is a hex
+ // sequence.
+ uint32_t hi;
+ uint32_t lo;
+ if (Succeeded(ParseHexdigit(src[0], &hi)) &&
+ Succeeded(ParseHexdigit(src[1], &lo))) {
+ *dest++ = (hi << 4) | lo;
+ } else {
+ assert(0);
+ }
+ src++;
+ break;
+ }
+ }
+ src++;
+ } else {
+ *dest++ = *src++;
+ }
+ }
+}
+
+typedef std::vector<std::string> TextVector;
+
+template <typename OutputIter>
+void RemoveEscapes(const TextVector& texts, OutputIter out) {
+ for (const std::string& text: texts)
+ RemoveEscapes(text, out);
+}
+
+class BinaryErrorHandlerModule : public ErrorHandler {
+ public:
+ BinaryErrorHandlerModule(Location* loc, WastParser* parser);
+ bool OnError(const Location&,
+ const std::string& error,
+ const std::string& source_line,
+ size_t source_line_column_offset) override;
+
+ // Unused.
+ size_t source_line_max_length() const override { return 0; }
+
+ private:
+ Location* loc_;
+ WastParser* parser_;
+};
+
+BinaryErrorHandlerModule::BinaryErrorHandlerModule(Location* loc,
+ WastParser* parser)
+ : ErrorHandler(Location::Type::Binary), loc_(loc), parser_(parser) {}
+
+bool BinaryErrorHandlerModule::OnError(const Location& binary_loc,
+ const std::string& error,
+ const std::string& source_line,
+ size_t source_line_column_offset) {
+ if (binary_loc.offset == kInvalidOffset) {
+ parser_->Error(*loc_, "error in binary module: %s", error.c_str());
+ } else {
+ parser_->Error(*loc_, "error in binary module: @0x%08" PRIzx ": %s",
+ binary_loc.offset, error.c_str());
+ }
+ return true;
+}
+
+bool IsPlainInstr(TokenType token_type) {
+ switch (token_type) {
+ case TokenType::Unreachable:
+ case TokenType::Nop:
+ case TokenType::Drop:
+ case TokenType::Select:
+ case TokenType::Br:
+ case TokenType::BrIf:
+ case TokenType::BrTable:
+ case TokenType::Return:
+ case TokenType::Call:
+ case TokenType::CallIndirect:
+ case TokenType::GetLocal:
+ case TokenType::SetLocal:
+ case TokenType::TeeLocal:
+ case TokenType::GetGlobal:
+ case TokenType::SetGlobal:
+ case TokenType::Load:
+ case TokenType::Store:
+ case TokenType::Const:
+ case TokenType::Unary:
+ case TokenType::Binary:
+ case TokenType::Compare:
+ case TokenType::Convert:
+ case TokenType::CurrentMemory:
+ case TokenType::GrowMemory:
+ case TokenType::Throw:
+ case TokenType::Rethrow:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool IsBlockInstr(TokenType token_type) {
+ switch (token_type) {
+ case TokenType::Block:
+ case TokenType::Loop:
+ case TokenType::If:
+ case TokenType::Try:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool IsPlainOrBlockInstr(TokenType token_type) {
+ return IsPlainInstr(token_type) || IsBlockInstr(token_type);
+}
+
+bool IsExpr(TokenTypePair pair) {
+ return pair[0] == TokenType::Lpar && IsPlainOrBlockInstr(pair[1]);
+}
+
+bool IsInstr(TokenTypePair pair) {
+ return IsPlainOrBlockInstr(pair[0]) || IsExpr(pair);
+}
+
+bool IsCatch(TokenType token_type) {
+ return token_type == TokenType::Catch || token_type == TokenType::CatchAll;
+}
+
+bool IsModuleField(TokenTypePair pair) {
+ if (pair[0] != TokenType::Lpar)
+ return false;
+
+ switch (pair[1]) {
+ case TokenType::Data:
+ case TokenType::Elem:
+ case TokenType::Except:
+ case TokenType::Export:
+ case TokenType::Func:
+ case TokenType::Type:
+ case TokenType::Global:
+ case TokenType::Import:
+ case TokenType::Memory:
+ case TokenType::Start:
+ case TokenType::Table:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool IsCommand(TokenTypePair pair) {
+ if (pair[0] != TokenType::Lpar)
+ return false;
+
+ switch (pair[1]) {
+ case TokenType::AssertExhaustion:
+ case TokenType::AssertInvalid:
+ case TokenType::AssertMalformed:
+ case TokenType::AssertReturn:
+ case TokenType::AssertReturnArithmeticNan:
+ case TokenType::AssertReturnCanonicalNan:
+ case TokenType::AssertTrap:
+ case TokenType::AssertUnlinkable:
+ case TokenType::Get:
+ case TokenType::Invoke:
+ case TokenType::Module:
+ case TokenType::Register:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool IsEmptySignature(const FuncSignature* sig) {
+ return sig->result_types.empty() && sig->param_types.empty();
+}
+
+void ResolveFuncTypes(Module* module) {
+ for (ModuleField& field : module->fields) {
+ Func* func = nullptr;
+ if (field.type == ModuleFieldType::Func) {
+ func = dyn_cast<FuncModuleField>(&field)->func;
+ } else if (field.type == ModuleFieldType::Import) {
+ Import* import = dyn_cast<ImportModuleField>(&field)->import;
+ if (import->kind == ExternalKind::Func) {
+ func = import->func;
+ } else {
+ continue;
+ }
+ } else {
+ continue;
+ }
+
+ // Resolve func type variables where the signature was not specified
+ // explicitly, e.g.: (func (type 1) ...)
+ if (func->decl.has_func_type && IsEmptySignature(&func->decl.sig)) {
+ FuncType* func_type = module->GetFuncType(func->decl.type_var);
+ if (func_type) {
+ func->decl.sig = func_type->sig;
+ }
+ }
+
+ // Resolve implicitly defined function types, e.g.: (func (param i32) ...)
+ if (!func->decl.has_func_type) {
+ Index func_type_index = module->GetFuncTypeIndex(func->decl.sig);
+ if (func_type_index == kInvalidIndex) {
+ auto func_type = new FuncType();
+ func_type->sig = func->decl.sig;
+ module->AppendField(new FuncTypeModuleField(func_type, field.loc));
+ }
+ }
+ }
+}
+
+void AppendInlineExportFields(Module* module,
+ ModuleFieldList* fields,
+ Index index) {
+ Location last_field_loc = module->fields.back().loc;
+
+ for (const ModuleField& field: *fields) {
+ auto* export_field = cast<ExportModuleField>(&field);
+ export_field->export_->var = Var(index, last_field_loc);
+ }
+
+ module->AppendFields(fields);
+}
+
+} // End of anonymous namespace
+
+WastParser::WastParser(WastLexer* lexer,
+ ErrorHandler* error_handler,
+ WastParseOptions* options)
+ : lexer_(lexer), error_handler_(error_handler), options_(options) {}
+
+void WastParser::Error(Location loc, const char* format, ...) {
+ errors_++;
+ va_list args;
+ va_start(args, format);
+ WastFormatError(error_handler_, &loc, lexer_, format, args);
+ va_end(args);
+}
+
+Token WastParser::GetToken() {
+ if (tokens_.empty())
+ tokens_.push_back(lexer_->GetToken(this));
+ return tokens_.front();
+}
+
+Location WastParser::GetLocation() {
+ return GetToken().loc;
+}
+
+TokenType WastParser::Peek(size_t n) {
+ while (tokens_.size() <= n)
+ tokens_.push_back(lexer_->GetToken(this));
+ return tokens_.at(n).token_type;
+}
+
+TokenTypePair WastParser::PeekPair() {
+ return TokenTypePair{{Peek(), Peek(1)}};
+}
+
+bool WastParser::PeekMatch(TokenType type) {
+ return Peek() == type;
+}
+
+bool WastParser::PeekMatchLpar(TokenType type) {
+ return Peek() == TokenType::Lpar && Peek(1) == type;
+}
+
+bool WastParser::PeekMatchExpr() {
+ return IsExpr(PeekPair());
+}
+
+bool WastParser::Match(TokenType type) {
+ if (PeekMatch(type)) {
+ Consume();
+ return true;
+ }
+ return false;
+}
+
+bool WastParser::MatchLpar(TokenType type) {
+ if (PeekMatchLpar(type)) {
+ Consume();
+ Consume();
+ return true;
+ }
+ return false;
+}
+
+Result WastParser::Expect(TokenType type) {
+ if (!Match(type)) {
+ auto token = Consume();
+ Error(token.loc, "unexpected token %s, expected %s.",
+ token.to_string().c_str(), GetTokenTypeName(type));
+ return Result::Error;
+ }
+
+ return Result::Ok;
+}
+
+Token WastParser::Consume() {
+ assert(!tokens_.empty());
+ auto token = tokens_.front();
+ tokens_.pop_front();
+ return token;
+}
+
+Result WastParser::Synchronize(SynchronizeFunc func) {
+ static const int kMaxConsumed = 10;
+ for (int i = 0; i < kMaxConsumed; ++i) {
+ if (func(PeekPair()))
+ return Result::Ok;
+
+ auto token = Consume();
+ if (token.token_type == TokenType::Reserved) {
+ Error(token.loc, "unexpected token %s.", token.to_string().c_str());
+ }
+ }
+
+ return Result::Error;
+}
+
+void WastParser::ErrorUnlessExceptionsAllowed() {
+ if (!options_->allow_future_exceptions) {
+ Error(GetLocation(), "opcode not allowed: %s",
+ GetToken().to_string().c_str());
+ }
+}
+
+Result WastParser::ErrorExpected(const std::vector<std::string>& expected,
+ const char* example) {
+ auto token = Consume();
+ std::string expected_str;
+ if (!expected.empty()) {
+ expected_str = ", expected ";
+ for (size_t i = 0; i < expected.size(); ++i) {
+ if (i != 0) {
+ if (i == expected.size() - 1)
+ expected_str += " or ";
+ else
+ expected_str += ", ";
+ }
+
+ expected_str += expected[i];
+ }
+
+ if (example) {
+ expected_str += " (e.g. ";
+ expected_str += example;
+ expected_str += ")";
+ }
+ }
+
+ Error(token.loc, "unexpected token \"%s\"%s.", token.to_string().c_str(),
+ expected_str.c_str());
+ return Result::Error;
+}
+
+Result WastParser::ErrorIfLpar(const std::vector<std::string>& expected,
+ const char* example) {
+ if (Match(TokenType::Lpar))
+ return ErrorExpected(expected, example);
+ return Result::Ok;
+}
+
+void WastParser::ParseBindVarOpt(std::string* name) {
+ WABT_TRACE(ParseBindVarOpt);
+ if (PeekMatch(TokenType::Var)) {
+ auto token = Consume();
+ *name = token.text.to_string();
+ }
+}
+
+Result WastParser::ParseVar(Var* out_var) {
+ WABT_TRACE(ParseVar);
+ if (PeekMatch(TokenType::Nat)) {
+ auto token = Consume();
+ string_view sv = token.literal.text.to_string_view();
+ uint64_t index = kInvalidIndex;
+ if (Failed(ParseUint64(sv.begin(), sv.end(), &index))) {
+ // Print an error, but don't fail parsing.
+ Error(token.loc, "invalid int \"" PRIstringview "\"",
+ WABT_PRINTF_STRING_VIEW_ARG(sv));
+ }
+
+ *out_var = Var(index, token.loc);
+ return Result::Ok;
+ } else if (PeekMatch(TokenType::Var)) {
+ auto token = Consume();
+ *out_var = Var(token.text.to_string_view(), token.loc);
+ return Result::Ok;
+ } else {
+ return ErrorExpected({"a numeric index", "a name"}, "12 or $foo");
+ }
+}
+
+bool WastParser::ParseVarOpt(Var* out_var, Var default_var) {
+ WABT_TRACE(ParseVarOpt);
+ if (PeekMatch(TokenType::Nat) || PeekMatch(TokenType::Var)) {
+ Result result = ParseVar(out_var);
+ // Should always succeed, the only way it could fail is if the token
+ // doesn't match.
+ assert(Succeeded(result));
+ WABT_USE(result);
+ return true;
+ } else {
+ *out_var = default_var;
+ return false;
+ }
+}
+
+Result WastParser::ParseOffsetExpr(ExprList* out_expr_list) {
+ WABT_TRACE(ParseOffsetExpr);
+ if (MatchLpar(TokenType::Offset)) {
+ CHECK_RESULT(ParseTerminatingInstrList(out_expr_list));
+ EXPECT(Rpar);
+ } else if (PeekMatchExpr()) {
+ CHECK_RESULT(ParseExpr(out_expr_list));
+ } else {
+ return ErrorExpected({"an offset expr"}, "(i32.const 123)");
+ }
+ return Result::Ok;
+}
+
+Result WastParser::ParseTextList(std::vector<uint8_t>* out_data) {
+ WABT_TRACE(ParseTextList);
+ if (!ParseTextListOpt(out_data)) {
+ return Result::Error;
+ }
+
+ return Result::Ok;
+}
+
+bool WastParser::ParseTextListOpt(std::vector<uint8_t>* out_data) {
+ WABT_TRACE(ParseTextListOpt);
+ TextVector texts;
+ while (PeekMatch(TokenType::Text))
+ texts.push_back(Consume().text.to_string());
+
+ RemoveEscapes(texts, std::back_inserter(*out_data));
+ return !texts.empty();
+}
+
+Result WastParser::ParseVarList(VarVector* out_var_list) {
+ WABT_TRACE(ParseVarList);
+ if (!ParseVarListOpt(out_var_list)) {
+ return Result::Error;
+ }
+
+ return Result::Ok;
+}
+
+bool WastParser::ParseVarListOpt(VarVector* out_var_list) {
+ WABT_TRACE(ParseVarListOpt);
+ Var var;
+ while (ParseVarOpt(&var))
+ out_var_list->push_back(var);
+
+ return !out_var_list->empty();
+}
+
+Result WastParser::ParseValueType(Type* out_type) {
+ WABT_TRACE(ParseValueType);
+ if (!PeekMatch(TokenType::ValueType))
+ return ErrorExpected({"i32", "i64", "f32", "f64"});
+
+ *out_type = Consume().type;
+ return Result::Ok;
+}
+
+Result WastParser::ParseValueTypeList(TypeVector* out_type_list) {
+ WABT_TRACE(ParseValueTypeList);
+ while (PeekMatch(TokenType::ValueType))
+ out_type_list->push_back(Consume().type);
+
+ CHECK_RESULT(ErrorIfLpar({"i32", "i64", "f32", "f64"}));
+ return Result::Ok;
+}
+
+Result WastParser::ParseQuotedText(std::string* text) {
+ WABT_TRACE(ParseQuotedText);
+ if (!PeekMatch(TokenType::Text))
+ return ErrorExpected({"a quoted string"}, "\"foo\"");
+
+ RemoveEscapes(Consume().text.to_string_view(), std::back_inserter(*text));
+ return Result::Ok;
+}
+
+bool WastParser::ParseOffsetOpt(uint32_t* out_offset) {
+ WABT_TRACE(ParseOffsetOpt);
+ if (PeekMatch(TokenType::OffsetEqNat)) {
+ auto token = Consume();
+ uint64_t offset64;
+ string_view sv = token.text.to_string_view();
+ if (Failed(ParseInt64(sv.begin(), sv.end(), &offset64,
+ ParseIntType::SignedAndUnsigned))) {
+ Error(token.loc, "invalid offset \"" PRIstringview "\"",
+ WABT_PRINTF_STRING_VIEW_ARG(sv));
+ }
+ if (offset64 > UINT32_MAX) {
+ Error(token.loc, "offset must be less than or equal to 0xffffffff");
+ }
+
+ *out_offset = static_cast<uint32_t>(offset64);
+ return true;
+ } else {
+ *out_offset = 0;
+ return false;
+ }
+}
+
+bool WastParser::ParseAlignOpt(uint32_t* out_align) {
+ WABT_TRACE(ParseAlignOpt);
+ if (PeekMatch(TokenType::AlignEqNat)) {
+ auto token = Consume();
+ string_view sv = token.text.to_string_view();
+ if (Failed(ParseInt32(sv.begin(), sv.end(), out_align,
+ ParseIntType::UnsignedOnly))) {
+ Error(token.loc, "invalid alignment \"" PRIstringview "\"",
+ WABT_PRINTF_STRING_VIEW_ARG(sv));
+ }
+
+ if (!IsPowerOfTwo(*out_align)) {
+ Error(token.loc, "alignment must be power-of-two");
+ }
+
+ return true;
+ } else {
+ *out_align = WABT_USE_NATURAL_ALIGNMENT;
+ return false;
+ }
+}
+
+Result WastParser::ParseLimits(Limits* out_limits) {
+ WABT_TRACE(ParseLimits);
+ CHECK_RESULT(ParseNat(&out_limits->initial));
+
+ if (PeekMatch(TokenType::Nat)) {
+ CHECK_RESULT(ParseNat(&out_limits->max));
+ out_limits->has_max = true;
+ } else {
+ out_limits->has_max = false;
+ }
+
+ return Result::Ok;
+}
+
+Result WastParser::ParseNat(uint64_t* out_nat) {
+ WABT_TRACE(ParseNat);
+ if (!PeekMatch(TokenType::Nat))
+ return ErrorExpected({"a natural number"}, "123");
+
+ auto token = Consume();
+ string_view sv = token.literal.text.to_string_view();
+ if (Failed(ParseUint64(sv.begin(), sv.end(), out_nat))) {
+ Error(token.loc, "invalid int \"" PRIstringview "\"",
+ WABT_PRINTF_STRING_VIEW_ARG(sv));
+ }
+
+ return Result::Ok;
+}
+
+Result WastParser::ParseScript(Script* script) {
+ WABT_TRACE(ParseScript);
+ script_ = script;
+
+ // Don't consume the Lpar yet, even though it is required. This way the
+ // sub-parser functions (e.g. ParseFuncModuleField) can consume it and keep
+ // the parsing structure more regular.
+ if (IsModuleField(PeekPair())) {
+ // Parse an inline module (i.e. one with no surrounding (module)).
+ auto module = make_unique<Module>();
+ module->loc = GetLocation();
+ CHECK_RESULT(ParseModuleFieldList(module.get()));
+ script->commands.emplace_back(make_unique<ModuleCommand>(module.release()));
+ } else if (IsCommand(PeekPair())) {
+ CHECK_RESULT(ParseCommandList(&script->commands));
+ } else {
+ ConsumeIfLpar();
+ ErrorExpected({"a module field", "a command"});
+ }
+
+ EXPECT(Eof);
+ return errors_ == 0 ? Result::Ok : Result::Error;
+}
+
+Result WastParser::ParseModuleFieldList(Module* module) {
+ WABT_TRACE(ParseModuleFieldList);
+ while (PeekMatch(TokenType::Lpar)) {
+ if (Failed(ParseModuleField(module))) {
+ CHECK_RESULT(Synchronize(IsModuleField));
+ }
+ }
+ ResolveFuncTypes(module);
+ return Result::Ok;
+}
+
+Result WastParser::ParseModuleField(Module* module) {
+ WABT_TRACE(ParseModuleField);
+ switch (Peek(1)) {
+ case TokenType::Data: return ParseDataModuleField(module);
+ case TokenType::Elem: return ParseElemModuleField(module);
+ case TokenType::Except: return ParseExceptModuleField(module);
+ case TokenType::Export: return ParseExportModuleField(module);
+ case TokenType::Func: return ParseFuncModuleField(module);
+ case TokenType::Type: return ParseTypeModuleField(module);
+ case TokenType::Global: return ParseGlobalModuleField(module);
+ case TokenType::Import: return ParseImportModuleField(module);
+ case TokenType::Memory: return ParseMemoryModuleField(module);
+ case TokenType::Start: return ParseStartModuleField(module);
+ case TokenType::Table: return ParseTableModuleField(module);
+ default:
+ assert(
+ !"ParseModuleField should only be called if IsModuleField() is true");
+ return Result::Error;
+ }
+}
+
+Result WastParser::ParseDataModuleField(Module* module) {
+ WABT_TRACE(ParseDataModuleField);
+ EXPECT(Lpar);
+ auto loc = GetLocation();
+ EXPECT(Data);
+ auto data_segment = make_unique<DataSegment>();
+ ParseVarOpt(&data_segment->memory_var, Var(0, loc));
+ CHECK_RESULT(ParseOffsetExpr(&data_segment->offset));
+ ParseTextListOpt(&data_segment->data);
+ EXPECT(Rpar);
+ module->AppendField(new DataSegmentModuleField(data_segment.release(), loc));
+ return Result::Ok;
+}
+
+Result WastParser::ParseElemModuleField(Module* module) {
+ WABT_TRACE(ParseElemModuleField);
+ EXPECT(Lpar);
+ auto loc = GetLocation();
+ EXPECT(Elem);
+ auto elem_segment = make_unique<ElemSegment>();
+ ParseVarOpt(&elem_segment->table_var, Var(0, loc));
+ CHECK_RESULT(ParseOffsetExpr(&elem_segment->offset));
+ ParseVarListOpt(&elem_segment->vars);
+ EXPECT(Rpar);
+ module->AppendField(new ElemSegmentModuleField(elem_segment.release(), loc));
+ return Result::Ok;
+}
+
+Result WastParser::ParseExceptModuleField(Module* module) {
+ WABT_TRACE(ParseExceptModuleField);
+ EXPECT(Lpar);
+ auto loc = GetLocation();
+ EXPECT(Except);
+ auto exception = make_unique<Exception>();
+ ParseBindVarOpt(&exception->name);
+ ParseValueTypeList(&exception->sig);
+ EXPECT(Rpar);
+ module->AppendField(new ExceptionModuleField(exception.release(), loc));
+ return Result::Ok;
+}
+
+Result WastParser::ParseExportModuleField(Module* module) {
+ WABT_TRACE(ParseExportModuleField);
+ EXPECT(Lpar);
+ auto loc = GetLocation();
+ EXPECT(Export);
+ auto export_ = make_unique<Export>();
+ CHECK_RESULT(ParseQuotedText(&export_->name));
+ CHECK_RESULT(ParseExportDesc(export_.get()));
+ EXPECT(Rpar);
+ module->AppendField(new ExportModuleField(export_.release(), loc));
+ return Result::Ok;
+}
+
+Result WastParser::ParseFuncModuleField(Module* module) {
+ WABT_TRACE(ParseFuncModuleField);
+ EXPECT(Lpar);
+ auto loc = GetLocation();
+ EXPECT(Func);
+ auto func = make_unique<Func>();
+ ParseBindVarOpt(&func->name);
+
+ ModuleFieldList export_fields;
+ CHECK_RESULT(ParseInlineExports(&export_fields, ExternalKind::Func));
+
+ if (PeekMatchLpar(TokenType::Import)) {
+ CheckImportOrdering(module);
+ auto import_loc = GetLocation();
+ auto import = make_unique<Import>();
+ import->kind = ExternalKind::Func;
+ import->func = func.release();
+ CHECK_RESULT(ParseInlineImport(import.get()));
+ CHECK_RESULT(ParseTypeUseOpt(&import->func->decl));
+ CHECK_RESULT(ParseFuncSignature(&import->func->decl.sig,
+ &import->func->param_bindings));
+ CHECK_RESULT(ErrorIfLpar({"type", "param", "result"}));
+ module->AppendField(new ImportModuleField(import.release(), import_loc));
+ } else {
+ CHECK_RESULT(ParseTypeUseOpt(&func->decl));
+ CHECK_RESULT(ParseFuncSignature(&func->decl.sig, &func->param_bindings));
+ CHECK_RESULT(ParseBoundValueTypeList(TokenType::Local, &func->local_types,
+ &func->local_bindings));
+ CHECK_RESULT(ParseTerminatingInstrList(&func->exprs));
+ module->AppendField(new FuncModuleField(func.release(), loc));
+ }
+
+ AppendInlineExportFields(module, &export_fields, module->funcs.size() - 1);
+
+ EXPECT(Rpar);
+ return Result::Ok;
+}
+
+Result WastParser::ParseTypeModuleField(Module* module) {
+ WABT_TRACE(ParseTypeModuleField);
+ EXPECT(Lpar);
+ auto loc = GetLocation();
+ EXPECT(Type);
+ auto func_type = make_unique<FuncType>();
+ ParseBindVarOpt(&func_type->name);
+ EXPECT(Lpar);
+ EXPECT(Func);
+ BindingHash bindings;
+ CHECK_RESULT(ParseFuncSignature(&func_type->sig, &bindings));
+ CHECK_RESULT(ErrorIfLpar({"param", "result"}));
+ EXPECT(Rpar);
+ EXPECT(Rpar);
+ module->AppendField(new FuncTypeModuleField(func_type.release(), loc));
+ return Result::Ok;
+}
+
+Result WastParser::ParseGlobalModuleField(Module* module) {
+ WABT_TRACE(ParseGlobalModuleField);
+ EXPECT(Lpar);
+ auto loc = GetLocation();
+ EXPECT(Global);
+ auto global = make_unique<Global>();
+ ParseBindVarOpt(&global->name);
+
+ ModuleFieldList export_fields;
+ CHECK_RESULT(ParseInlineExports(&export_fields, ExternalKind::Global));
+
+ if (PeekMatchLpar(TokenType::Import)) {
+ CheckImportOrdering(module);
+ auto import_loc = GetLocation();
+ auto import = make_unique<Import>();
+ import->kind = ExternalKind::Global;
+ import->global = global.release();
+ CHECK_RESULT(ParseInlineImport(import.get()));
+ CHECK_RESULT(ParseGlobalType(import->global));
+ module->AppendField(new ImportModuleField(import.release(), import_loc));
+ } else {
+ CHECK_RESULT(ParseGlobalType(global.get()));
+ CHECK_RESULT(ParseTerminatingInstrList(&global->init_expr));
+ module->AppendField(new GlobalModuleField(global.release(), loc));
+ }
+
+ AppendInlineExportFields(module, &export_fields, module->globals.size() - 1);
+
+ EXPECT(Rpar);
+ return Result::Ok;
+}
+
+Result WastParser::ParseImportModuleField(Module* module) {
+ WABT_TRACE(ParseImportModuleField);
+ EXPECT(Lpar);
+ auto loc = GetLocation();
+ CheckImportOrdering(module);
+ EXPECT(Import);
+ auto import = make_unique<Import>();
+ CHECK_RESULT(ParseQuotedText(&import->module_name));
+ CHECK_RESULT(ParseQuotedText(&import->field_name));
+ EXPECT(Lpar);
+ switch (Peek()) {
+ case TokenType::Func:
+ Consume();
+ import->kind = ExternalKind::Func;
+ import->func = new Func();
+ ParseBindVarOpt(&import->func->name);
+ if (PeekMatchLpar(TokenType::Type)) {
+ import->func->decl.has_func_type = true;
+ CHECK_RESULT(ParseTypeUseOpt(&import->func->decl));
+ EXPECT(Rpar);
+ } else {
+ CHECK_RESULT(ParseFuncSignature(&import->func->decl.sig,
+ &import->func->param_bindings));
+ CHECK_RESULT(ErrorIfLpar({"param", "result"}));
+ EXPECT(Rpar);
+ }
+ break;
+
+ case TokenType::Table:
+ Consume();
+ import->kind = ExternalKind::Table;
+ import->table = new Table();
+ ParseBindVarOpt(&import->table->name);
+ CHECK_RESULT(ParseLimits(&import->table->elem_limits));
+ EXPECT(Anyfunc);
+ EXPECT(Rpar);
+ break;
+
+ case TokenType::Memory:
+ Consume();
+ import->kind = ExternalKind::Memory;
+ import->memory = new Memory();
+ ParseBindVarOpt(&import->memory->name);
+ CHECK_RESULT(ParseLimits(&import->memory->page_limits));
+ EXPECT(Rpar);
+ break;
+
+ case TokenType::Global:
+ Consume();
+ import->kind = ExternalKind::Global;
+ import->global = new Global();
+ ParseBindVarOpt(&import->global->name);
+ CHECK_RESULT(ParseGlobalType(import->global));
+ EXPECT(Rpar);
+ break;
+
+ case TokenType::Except:
+ Consume();
+ import->kind = ExternalKind::Except;
+ import->except = new Exception();
+ ParseBindVarOpt(&import->except->name);
+ ParseValueTypeList(&import->except->sig);
+ EXPECT(Rpar);
+ break;
+
+ default:
+ return ErrorExpected({"an external kind"});
+ }
+
+ module->AppendField(new ImportModuleField(import.release(), loc));
+ EXPECT(Rpar);
+ return Result::Ok;
+}
+
+Result WastParser::ParseMemoryModuleField(Module* module) {
+ WABT_TRACE(ParseMemoryModuleField);
+ EXPECT(Lpar);
+ auto loc = GetLocation();
+ EXPECT(Memory);
+ auto memory = make_unique<Memory>();
+ ParseBindVarOpt(&memory->name);
+
+ ModuleFieldList export_fields;
+ CHECK_RESULT(ParseInlineExports(&export_fields, ExternalKind::Memory));
+
+ if (PeekMatchLpar(TokenType::Import)) {
+ CheckImportOrdering(module);
+ auto import_loc = GetLocation();
+ auto import = make_unique<Import>();
+ import->kind = ExternalKind::Memory;
+ import->memory = memory.release();
+ CHECK_RESULT(ParseInlineImport(import.get()));
+ CHECK_RESULT(ParseLimits(&import->memory->page_limits));
+ module->AppendField(new ImportModuleField(import.release(), import_loc));
+ } else if (MatchLpar(TokenType::Data)) {
+ auto data_segment = make_unique<DataSegment>();
+ data_segment->memory_var = Var(module->memories.size());
+ data_segment->offset.push_back(new ConstExpr(Const(Const::I32(), 0)));
+ data_segment->offset.back().loc = loc;
+ ParseTextListOpt(&data_segment->data);
+ EXPECT(Rpar);
+
+ uint32_t byte_size = WABT_ALIGN_UP_TO_PAGE(data_segment->data.size());
+ uint32_t page_size = WABT_BYTES_TO_PAGES(byte_size);
+ memory->page_limits.initial = page_size;
+ memory->page_limits.max = page_size;
+ memory->page_limits.has_max = true;
+
+ module->AppendField(new MemoryModuleField(memory.release(), loc));
+ module->AppendField(
+ new DataSegmentModuleField(data_segment.release(), loc));
+ } else {
+ CHECK_RESULT(ParseLimits(&memory->page_limits));
+ module->AppendField(new MemoryModuleField(memory.release(), loc));
+ }
+
+ AppendInlineExportFields(module, &export_fields, module->memories.size() - 1);
+
+ EXPECT(Rpar);
+ return Result::Ok;
+}
+
+Result WastParser::ParseStartModuleField(Module* module) {
+ WABT_TRACE(ParseStartModuleField);
+ EXPECT(Lpar);
+ auto loc = GetLocation();
+ EXPECT(Start);
+ Var var;
+ CHECK_RESULT(ParseVar(&var));
+ EXPECT(Rpar);
+ module->AppendField(new StartModuleField(var, loc));
+ return Result::Ok;
+}
+
+Result WastParser::ParseTableModuleField(Module* module) {
+ WABT_TRACE(ParseTableModuleField);
+ EXPECT(Lpar);
+ auto loc = GetLocation();
+ EXPECT(Table);
+ auto table = make_unique<Table>();
+ ParseBindVarOpt(&table->name);
+
+ ModuleFieldList export_fields;
+ CHECK_RESULT(ParseInlineExports(&export_fields, ExternalKind::Table));
+
+ if (PeekMatchLpar(TokenType::Import)) {
+ CheckImportOrdering(module);
+ auto import_loc = GetLocation();
+ auto import = make_unique<Import>();
+ import->kind = ExternalKind::Table;
+ import->table = table.release();
+ CHECK_RESULT(ParseInlineImport(import.get()));
+ CHECK_RESULT(ParseLimits(&import->table->elem_limits));
+ EXPECT(Anyfunc);
+ module->AppendField(new ImportModuleField(import.release(), import_loc));
+ } else if (Match(TokenType::Anyfunc)) {
+ EXPECT(Lpar);
+ EXPECT(Elem);
+
+ auto elem_segment = make_unique<ElemSegment>();
+ elem_segment->table_var = Var(module->tables.size());
+ elem_segment->offset.push_back(new ConstExpr(Const(Const::I32(), 0)));
+ elem_segment->offset.back().loc = loc;
+ CHECK_RESULT(ParseVarList(&elem_segment->vars));
+ EXPECT(Rpar);
+
+ table->elem_limits.initial = elem_segment->vars.size();
+ table->elem_limits.max = elem_segment->vars.size();
+ table->elem_limits.has_max = true;
+ module->AppendField(new TableModuleField(table.release(), loc));
+ module->AppendField(
+ new ElemSegmentModuleField(elem_segment.release(), loc));
+ } else {
+ CHECK_RESULT(ParseLimits(&table->elem_limits));
+ EXPECT(Anyfunc);
+ module->AppendField(new TableModuleField(table.release(), loc));
+ }
+
+ AppendInlineExportFields(module, &export_fields, module->tables.size() - 1);
+
+ EXPECT(Rpar);
+ return Result::Ok;
+}
+
+Result WastParser::ParseExportDesc(Export* export_) {
+ WABT_TRACE(ParseExportDesc);
+ EXPECT(Lpar);
+ switch (Peek()) {
+ case TokenType::Func: export_->kind = ExternalKind::Func; break;
+ case TokenType::Table: export_->kind = ExternalKind::Table; break;
+ case TokenType::Memory: export_->kind = ExternalKind::Memory; break;
+ case TokenType::Global: export_->kind = ExternalKind::Global; break;
+ case TokenType::Except: export_->kind = ExternalKind::Except; break;
+ default:
+ return ErrorExpected({"an external kind"});
+ }
+ Consume();
+ CHECK_RESULT(ParseVar(&export_->var));
+ EXPECT(Rpar);
+ return Result::Ok;
+}
+
+Result WastParser::ParseInlineExports(ModuleFieldList* fields,
+ ExternalKind kind) {
+ WABT_TRACE(ParseInlineExports);
+ while (PeekMatchLpar(TokenType::Export)) {
+ EXPECT(Lpar);
+ auto loc = GetLocation();
+ EXPECT(Export);
+ auto export_ = make_unique<Export>();
+ export_->kind = kind;
+ CHECK_RESULT(ParseQuotedText(&export_->name));
+ EXPECT(Rpar);
+ fields->push_back(new ExportModuleField(export_.release(), loc));
+ }
+ return Result::Ok;
+}
+
+Result WastParser::ParseInlineImport(Import* import) {
+ WABT_TRACE(ParseInlineImport);
+ EXPECT(Lpar);
+ EXPECT(Import);
+ CHECK_RESULT(ParseQuotedText(&import->module_name));
+ CHECK_RESULT(ParseQuotedText(&import->field_name));
+ EXPECT(Rpar);
+ return Result::Ok;
+}
+
+Result WastParser::ParseTypeUseOpt(FuncDeclaration* decl) {
+ WABT_TRACE(ParseTypeUseOpt);
+ if (MatchLpar(TokenType::Type)) {
+ decl->has_func_type = true;;
+ CHECK_RESULT(ParseVar(&decl->type_var));
+ EXPECT(Rpar);
+ } else {
+ decl->has_func_type = false;
+ }
+ return Result::Ok;
+}
+
+Result WastParser::ParseFuncSignature(FuncSignature* sig,
+ BindingHash* param_bindings) {
+ WABT_TRACE(ParseFuncSignature);
+ CHECK_RESULT(ParseBoundValueTypeList(TokenType::Param, &sig->param_types,
+ param_bindings));
+ CHECK_RESULT(ParseResultList(&sig->result_types));
+ return Result::Ok;
+}
+
+Result WastParser::ParseBoundValueTypeList(TokenType token,
+ TypeVector* types,
+ BindingHash* bindings) {
+ WABT_TRACE(ParseBoundValueTypeList);
+ while (MatchLpar(token)) {
+ if (PeekMatch(TokenType::Var)) {
+ std::string name;
+ Type type;
+ auto loc = GetLocation();
+ ParseBindVarOpt(&name);
+ CHECK_RESULT(ParseValueType(&type));
+ bindings->emplace(name, Binding(loc, types->size()));
+ types->push_back(type);
+ } else {
+ ParseValueTypeList(types);
+ }
+ EXPECT(Rpar);
+ }
+ return Result::Ok;
+}
+
+Result WastParser::ParseResultList(TypeVector* result_types) {
+ WABT_TRACE(ParseResultList);
+ while (MatchLpar(TokenType::Result)) {
+ ParseValueTypeList(result_types);
+ EXPECT(Rpar);
+ }
+ return Result::Ok;
+}
+
+Result WastParser::ParseInstrList(ExprList* exprs) {
+ WABT_TRACE(ParseInstrList);
+ ExprList new_exprs;
+ while (IsInstr(PeekPair())) {
+ if (Succeeded(ParseInstr(&new_exprs))) {
+ exprs->splice(exprs->end(), new_exprs);
+ } else {
+ CHECK_RESULT(Synchronize(IsInstr));
+ }
+ }
+ return Result::Ok;
+}
+
+Result WastParser::ParseTerminatingInstrList(ExprList* exprs) {
+ WABT_TRACE(ParseTerminatingInstrList);
+ Result result = ParseInstrList(exprs);
+ // An InstrList often has no further Lpar following it, because it would have
+ // gobbled it up. So if there is a following Lpar it is an error. If we
+ // handle it here we can produce a nicer error message.
+ CHECK_RESULT(ErrorIfLpar({"an instr"}));
+ return result;
+}
+
+Result WastParser::ParseInstr(ExprList* exprs) {
+ WABT_TRACE(ParseInstr);
+ if (IsPlainInstr(Peek())) {
+ std::unique_ptr<Expr> expr;
+ CHECK_RESULT(ParsePlainInstr(&expr));
+ exprs->push_back(expr.release());
+ return Result::Ok;
+ } else if (IsBlockInstr(Peek())) {
+ std::unique_ptr<Expr> expr;
+ CHECK_RESULT(ParseBlockInstr(&expr));
+ exprs->push_back(expr.release());
+ return Result::Ok;
+ } else if (PeekMatchExpr()) {
+ return ParseExpr(exprs);
+ } else {
+ assert(!"ParseInstr should only be called when IsInstr() is true");
+ return Result::Error;
+ }
+}
+
+template <typename T>
+Result WastParser::ParsePlainInstrVar(Location loc,
+ std::unique_ptr<Expr>* out_expr) {
+ Var var;
+ CHECK_RESULT(ParseVar(&var));
+ out_expr->reset(new T(var, loc));
+ return Result::Ok;
+}
+
+Result WastParser::ParsePlainInstr(std::unique_ptr<Expr>* out_expr) {
+ WABT_TRACE(ParsePlainInstr);
+ auto loc = GetLocation();
+ switch (Peek()) {
+ case TokenType::Unreachable:
+ Consume();
+ out_expr->reset(new UnreachableExpr(loc));
+ break;
+
+ case TokenType::Nop:
+ Consume();
+ out_expr->reset(new NopExpr(loc));
+ break;
+
+ case TokenType::Drop:
+ Consume();
+ out_expr->reset(new DropExpr(loc));
+ break;
+
+ case TokenType::Select:
+ Consume();
+ out_expr->reset(new SelectExpr(loc));
+ break;
+
+ case TokenType::Br:
+ Consume();
+ CHECK_RESULT(ParsePlainInstrVar<BrExpr>(loc, out_expr));
+ break;
+
+ case TokenType::BrIf:
+ Consume();
+ CHECK_RESULT(ParsePlainInstrVar<BrIfExpr>(loc, out_expr));
+ break;
+
+ case TokenType::BrTable: {
+ Consume();
+ auto var_list = make_unique<VarVector>();
+ CHECK_RESULT(ParseVarList(var_list.get()));
+ Var var = var_list->back();
+ var_list->pop_back();
+ out_expr->reset(new BrTableExpr(var_list.release(), var, loc));
+ break;
+ }
+
+ case TokenType::Return:
+ Consume();
+ out_expr->reset(new ReturnExpr(loc));
+ break;
+
+ case TokenType::Call:
+ Consume();
+ CHECK_RESULT(ParsePlainInstrVar<CallExpr>(loc, out_expr));
+ break;
+
+ case TokenType::CallIndirect:
+ Consume();
+ CHECK_RESULT(ParsePlainInstrVar<CallIndirectExpr>(loc, out_expr));
+ break;
+
+ case TokenType::GetLocal:
+ Consume();
+ CHECK_RESULT(ParsePlainInstrVar<GetLocalExpr>(loc, out_expr));
+ break;
+
+ case TokenType::SetLocal:
+ Consume();
+ CHECK_RESULT(ParsePlainInstrVar<SetLocalExpr>(loc, out_expr));
+ break;
+
+ case TokenType::TeeLocal:
+ Consume();
+ CHECK_RESULT(ParsePlainInstrVar<TeeLocalExpr>(loc, out_expr));
+ break;
+
+ case TokenType::GetGlobal:
+ Consume();
+ CHECK_RESULT(ParsePlainInstrVar<GetGlobalExpr>(loc, out_expr));
+ break;
+
+ case TokenType::SetGlobal:
+ Consume();
+ CHECK_RESULT(ParsePlainInstrVar<SetGlobalExpr>(loc, out_expr));
+ break;
+
+ case TokenType::Load: {
+ Opcode opcode = Consume().opcode;
+ uint32_t offset;
+ uint32_t align;
+ ParseOffsetOpt(&offset);
+ ParseAlignOpt(&align);
+ out_expr->reset(new LoadExpr(opcode, align, offset, loc));
+ break;
+ }
+
+ case TokenType::Store: {
+ Opcode opcode = Consume().opcode;
+ uint32_t offset;
+ uint32_t align;
+ ParseOffsetOpt(&offset);
+ ParseAlignOpt(&align);
+ out_expr->reset(new StoreExpr(opcode, align, offset, loc));
+ break;
+ }
+
+ case TokenType::Const: {
+ Const const_;
+ CHECK_RESULT(ParseConst(&const_));
+ out_expr->reset(new ConstExpr(const_, loc));
+ break;
+ }
+
+ case TokenType::Unary:
+ out_expr->reset(new UnaryExpr(Consume().opcode, loc));
+ break;
+
+ case TokenType::Binary:
+ out_expr->reset(new BinaryExpr(Consume().opcode, loc));
+ break;
+
+ case TokenType::Compare:
+ out_expr->reset(new CompareExpr(Consume().opcode, loc));
+ break;
+
+ case TokenType::Convert:
+ out_expr->reset(new ConvertExpr(Consume().opcode, loc));
+ break;
+
+ case TokenType::CurrentMemory:
+ Consume();
+ out_expr->reset(new CurrentMemoryExpr(loc));
+ break;
+
+ case TokenType::GrowMemory:
+ Consume();
+ out_expr->reset(new GrowMemoryExpr(loc));
+ break;
+
+ case TokenType::Throw:
+ ErrorUnlessExceptionsAllowed();
+ Consume();
+ CHECK_RESULT(ParsePlainInstrVar<ThrowExpr>(loc, out_expr));
+ break;
+
+ case TokenType::Rethrow:
+ ErrorUnlessExceptionsAllowed();
+ Consume();
+ CHECK_RESULT(ParsePlainInstrVar<RethrowExpr>(loc, out_expr));
+ break;
+
+ default:
+ assert(
+ !"ParsePlainInstr should only be called when IsPlainInstr() is true");
+ return Result::Error;
+ }
+
+ return Result::Ok;
+}
+
+Result WastParser::ParseConst(Const* const_) {
+ WABT_TRACE(ParseConst);
+ auto opcode = Consume().opcode;
+ LiteralTerminal literal;
+
+ auto loc = GetLocation();
+
+ switch (Peek()) {
+ case TokenType::Nat:
+ case TokenType::Int:
+ case TokenType::Float:
+ literal = Consume().literal;
+ break;
+
+ default:
+ return ErrorExpected({"a numeric literal"}, "123, -45, 6.7e8");
+ }
+
+ string_view sv = literal.text.to_string_view();
+ const char* s = sv.begin();
+ const char* end = sv.end();
+
+ Result result;
+ switch (opcode) {
+ case Opcode::I32Const:
+ const_->type = Type::I32;
+ result =
+ ParseInt32(s, end, &const_->u32, ParseIntType::SignedAndUnsigned);
+ break;
+
+ case Opcode::I64Const:
+ const_->type = Type::I64;
+ result =
+ ParseInt64(s, end, &const_->u64, ParseIntType::SignedAndUnsigned);
+ break;
+
+ case Opcode::F32Const:
+ const_->type = Type::F32;
+ result = ParseFloat(literal.type, s, end, &const_->f32_bits);
+ break;
+
+ case Opcode::F64Const:
+ const_->type = Type::F64;
+ result = ParseDouble(literal.type, s, end, &const_->f64_bits);
+ break;
+
+ default:
+ assert(!"ParseConst called with invalid opcode");
+ return Result::Error;
+ }
+
+ if (Failed(result)) {
+ Error(loc, "invalid literal \"%s\"", literal.text.to_string().c_str());
+ }
+
+ return Result::Ok;
+}
+
+Result WastParser::ParseConstList(ConstVector* consts) {
+ WABT_TRACE(ParseConstList);
+ while (PeekMatchLpar(TokenType::Const)) {
+ Consume();
+ Const const_;
+ CHECK_RESULT(ParseConst(&const_));
+ EXPECT(Rpar);
+ consts->push_back(const_);
+ }
+
+ return Result::Ok;
+}
+
+Result WastParser::ParseBlockInstr(std::unique_ptr<Expr>* out_expr) {
+ WABT_TRACE(ParseBlockInstr);
+ auto loc = GetLocation();
+
+ switch (Peek()) {
+ case TokenType::Block: {
+ Consume();
+ auto block = make_unique<Block>();
+ CHECK_RESULT(ParseLabelOpt(&block->label));
+ CHECK_RESULT(ParseBlock(block.get()));
+ EXPECT(End);
+ CHECK_RESULT(ParseEndLabelOpt(block->label));
+ out_expr->reset(new BlockExpr(block.release(), loc));
+ break;
+ }
+
+ case TokenType::Loop: {
+ Consume();
+ auto block = make_unique<Block>();
+ CHECK_RESULT(ParseLabelOpt(&block->label));
+ CHECK_RESULT(ParseBlock(block.get()));
+ EXPECT(End);
+ CHECK_RESULT(ParseEndLabelOpt(block->label));
+ out_expr->reset(new LoopExpr(block.release(), loc));
+ break;
+ }
+
+ case TokenType::If: {
+ Consume();
+ auto true_ = make_unique<Block>();
+ ExprList false_;
+ CHECK_RESULT(ParseLabelOpt(&true_->label));
+ CHECK_RESULT(ParseBlock(true_.get()));
+ if (Match(TokenType::Else)) {
+ CHECK_RESULT(ParseEndLabelOpt(true_->label));
+ CHECK_RESULT(ParseTerminatingInstrList(&false_));
+ }
+ EXPECT(End);
+ CHECK_RESULT(ParseEndLabelOpt(true_->label));
+ out_expr->reset(new IfExpr(true_.release(), std::move(false_), loc));
+ break;
+ }
+
+ case TokenType::Try: {
+ ErrorUnlessExceptionsAllowed();
+ Consume();
+ auto expr = make_unique<TryExpr>(loc);
+ expr->block = new Block();
+ CatchVector catches;
+ CHECK_RESULT(ParseLabelOpt(&expr->block->label));
+ CHECK_RESULT(ParseBlock(expr->block));
+ CHECK_RESULT(ParseCatchInstrList(&expr->catches));
+ CHECK_RESULT(ErrorIfLpar({"a catch expr"}));
+ EXPECT(End);
+ CHECK_RESULT(ParseEndLabelOpt(expr->block->label));
+ *out_expr = std::move(expr);
+ break;
+ }
+
+ default:
+ assert(
+ !"ParseBlockInstr should only be called when IsBlockInstr() is true");
+ return Result::Error;
+ }
+
+ return Result::Ok;
+}
+
+Result WastParser::ParseLabelOpt(std::string* out_label) {
+ WABT_TRACE(ParseLabelOpt);
+ if (PeekMatch(TokenType::Var)) {
+ *out_label = Consume().text.to_string();
+ } else {
+ out_label->clear();
+ }
+ return Result::Ok;
+}
+
+Result WastParser::ParseEndLabelOpt(const std::string& begin_label) {
+ WABT_TRACE(ParseEndLabelOpt);
+ auto loc = GetLocation();
+ std::string end_label;
+ CHECK_RESULT(ParseLabelOpt(&end_label));
+ if (!end_label.empty()) {
+ if (begin_label.empty()) {
+ Error(loc, "unexpected label \"%s\"", end_label.c_str());
+ } else if (begin_label != end_label) {
+ Error(loc, "mismatching label \"%s\" != \"%s\"", begin_label.c_str(),
+ end_label.c_str());
+ }
+ }
+ return Result::Ok;
+}
+
+Result WastParser::ParseBlock(Block* block) {
+ WABT_TRACE(ParseBlock);
+ CHECK_RESULT(ParseResultList(&block->sig));
+ CHECK_RESULT(ParseInstrList(&block->exprs));
+ return Result::Ok;
+}
+
+Result WastParser::ParseExprList(ExprList* exprs) {
+ WABT_TRACE(ParseExprList);
+ ExprList new_exprs;
+ while (PeekMatchExpr()) {
+ if (Succeeded(ParseExpr(&new_exprs))) {
+ exprs->splice(exprs->end(), new_exprs);
+ } else {
+ CHECK_RESULT(Synchronize(IsExpr));
+ }
+ }
+ return Result::Ok;
+}
+
+Result WastParser::ParseExpr(ExprList* exprs) {
+ WABT_TRACE(ParseExpr);
+ if (!PeekMatch(TokenType::Lpar))
+ return Result::Error;
+
+ if (IsPlainInstr(Peek(1))) {
+ Consume();
+ std::unique_ptr<Expr> expr;
+ CHECK_RESULT(ParsePlainInstr(&expr));
+ CHECK_RESULT(ParseExprList(exprs));
+ CHECK_RESULT(ErrorIfLpar({"an expr"}));
+ exprs->push_back(expr.release());
+ } else {
+ auto loc = GetLocation();
+
+ switch (Peek(1)) {
+ case TokenType::Block: {
+ Consume();
+ Consume();
+ auto block = make_unique<Block>();
+ CHECK_RESULT(ParseLabelOpt(&block->label));
+ CHECK_RESULT(ParseBlock(block.get()));
+ exprs->push_back(new BlockExpr(block.release(), loc));
+ break;
+ }
+
+ case TokenType::Loop: {
+ Consume();
+ Consume();
+ auto block = make_unique<Block>();
+ CHECK_RESULT(ParseLabelOpt(&block->label));
+ CHECK_RESULT(ParseBlock(block.get()));
+ exprs->push_back(new LoopExpr(block.release(), loc));
+ break;
+ }
+
+ case TokenType::If: {
+ Consume();
+ Consume();
+ auto true_ = make_unique<Block>();
+ ExprList false_;
+
+ CHECK_RESULT(ParseLabelOpt(&true_->label));
+ CHECK_RESULT(ParseResultList(&true_->sig));
+
+ if (PeekMatchExpr()) {
+ ExprList cond;
+ CHECK_RESULT(ParseExpr(&cond));
+ exprs->splice(exprs->end(), cond);
+ }
+
+ if (MatchLpar(TokenType::Then)) {
+ CHECK_RESULT(ParseTerminatingInstrList(&true_->exprs));
+ EXPECT(Rpar);
+
+ if (MatchLpar(TokenType::Else)) {
+ CHECK_RESULT(ParseTerminatingInstrList(&false_));
+ EXPECT(Rpar);
+ } else if (PeekMatchExpr()) {
+ CHECK_RESULT(ParseExpr(&false_));
+ }
+ } else if (PeekMatchExpr()) {
+ CHECK_RESULT(ParseExpr(&true_->exprs));
+ if (PeekMatchExpr()) {
+ CHECK_RESULT(ParseExpr(&false_));
+ }
+ } else {
+ ConsumeIfLpar();
+ return ErrorExpected({"then block"}, "(then ...)");
+ }
+
+ exprs->push_back(new IfExpr(true_.release(), std::move(false_), loc));
+ break;
+ }
+
+ case TokenType::Try: {
+ Consume();
+ ErrorUnlessExceptionsAllowed();
+ Consume();
+
+ auto block = make_unique<Block>();
+ CHECK_RESULT(ParseLabelOpt(&block->label));
+ CHECK_RESULT(ParseResultList(&block->sig));
+ CHECK_RESULT(ParseInstrList(&block->exprs));
+ auto try_ = make_unique<TryExpr>(loc);
+ try_->block = block.release();
+ CHECK_RESULT(ParseCatchExprList(&try_->catches));
+ CHECK_RESULT(ErrorIfLpar({"a catch expr"}));
+
+ exprs->push_back(try_.release());
+ break;
+ }
+
+ default:
+ assert(!"ParseExpr should only be called when IsExpr() is true");
+ return Result::Error;
+ }
+ }
+
+ EXPECT(Rpar);
+ return Result::Ok;
+}
+
+Result WastParser::ParseCatchInstrList(CatchVector* catches) {
+ WABT_TRACE(ParseCatchInstrList);
+ while (IsCatch(Peek())) {
+ auto catch_ = make_unique<Catch>();
+ catch_->loc = GetLocation();
+
+ if (Consume().token_type == TokenType::Catch)
+ CHECK_RESULT(ParseVar(&catch_->var));
+
+ CHECK_RESULT(ParseInstrList(&catch_->exprs));
+ catches->push_back(catch_.release());
+ }
+
+ return Result::Ok;
+}
+
+Result WastParser::ParseCatchExprList(CatchVector* catches) {
+ WABT_TRACE(ParseCatchExprList);
+ while (PeekMatch(TokenType::Lpar) && IsCatch(Peek(1))) {
+ Consume();
+ auto catch_ = make_unique<Catch>();
+ catch_->loc = GetLocation();
+
+ if (Consume().token_type == TokenType::Catch)
+ CHECK_RESULT(ParseVar(&catch_->var));
+
+ CHECK_RESULT(ParseTerminatingInstrList(&catch_->exprs));
+ EXPECT(Rpar);
+ catches->push_back(catch_.release());
+ }
+
+ return Result::Ok;
+}
+
+Result WastParser::ParseGlobalType(Global* global) {
+ WABT_TRACE(ParseGlobalType);
+ if (MatchLpar(TokenType::Mut)) {
+ global->mutable_ = true;
+ CHECK_RESULT(ParseValueType(&global->type));
+ CHECK_RESULT(ErrorIfLpar({"i32", "i64", "f32", "f64"}));
+ EXPECT(Rpar);
+ } else {
+ CHECK_RESULT(ParseValueType(&global->type));
+ }
+
+ return Result::Ok;
+}
+
+Result WastParser::ParseCommandList(CommandPtrVector* commands) {
+ WABT_TRACE(ParseCommandList);
+ while (PeekMatch(TokenType::Lpar)) {
+ CommandPtr command;
+ if (Succeeded(ParseCommand(&command))) {
+ commands->push_back(std::move(command));
+ } else {
+ CHECK_RESULT(Synchronize(IsCommand));
+ }
+ }
+ return Result::Ok;
+}
+
+Result WastParser::ParseCommand(CommandPtr* out_command) {
+ WABT_TRACE(ParseCommand);
+ switch (Peek(1)) {
+ case TokenType::AssertExhaustion:
+ return ParseAssertExhaustionCommand(out_command);
+
+ case TokenType::AssertInvalid:
+ return ParseAssertInvalidCommand(out_command);
+
+ case TokenType::AssertMalformed:
+ return ParseAssertMalformedCommand(out_command);
+
+ case TokenType::AssertReturn:
+ return ParseAssertReturnCommand(out_command);
+
+ case TokenType::AssertReturnArithmeticNan:
+ return ParseAssertReturnArithmeticNanCommand(out_command);
+
+ case TokenType::AssertReturnCanonicalNan:
+ return ParseAssertReturnCanonicalNanCommand(out_command);
+
+ case TokenType::AssertTrap:
+ return ParseAssertTrapCommand(out_command);
+
+ case TokenType::AssertUnlinkable:
+ return ParseAssertUnlinkableCommand(out_command);
+
+ case TokenType::Get:
+ case TokenType::Invoke:
+ return ParseActionCommand(out_command);
+
+ case TokenType::Module:
+ return ParseModuleCommand(out_command);
+
+ case TokenType::Register:
+ return ParseRegisterCommand(out_command);
+
+ default:
+ assert(!"ParseCommand should only be called when IsCommand() is true");
+ return Result::Error;
+ }
+}
+
+Result WastParser::ParseAssertExhaustionCommand(CommandPtr* out_command) {
+ WABT_TRACE(ParseAssertExhaustionCommand);
+ return ParseAssertActionTextCommand<AssertExhaustionCommand>(
+ TokenType::AssertExhaustion, out_command);
+}
+
+Result WastParser::ParseAssertInvalidCommand(CommandPtr* out_command) {
+ WABT_TRACE(ParseAssertInvalidCommand);
+ return ParseAssertScriptModuleCommand<AssertInvalidCommand>(
+ TokenType::AssertInvalid, out_command);
+}
+
+Result WastParser::ParseAssertMalformedCommand(CommandPtr* out_command) {
+ WABT_TRACE(ParseAssertMalformedCommand);
+ return ParseAssertScriptModuleCommand<AssertMalformedCommand>(
+ TokenType::AssertMalformed, out_command);
+}
+
+Result WastParser::ParseAssertReturnCommand(CommandPtr* out_command) {
+ WABT_TRACE(ParseAssertReturnCommand);
+ EXPECT(Lpar);
+ EXPECT(AssertReturn);
+ auto action = make_unique<Action>();
+ auto consts = make_unique<ConstVector>();
+ CHECK_RESULT(ParseAction(action.get()));
+ CHECK_RESULT(ParseConstList(consts.get()));
+ EXPECT(Rpar);
+ out_command->reset(
+ new AssertReturnCommand(action.release(), consts.release()));
+ return Result::Ok;
+}
+
+Result WastParser::ParseAssertReturnArithmeticNanCommand(
+ CommandPtr* out_command) {
+ WABT_TRACE(ParseAssertReturnArithmeticNanCommand);
+ return ParseAssertActionCommand<AssertReturnArithmeticNanCommand>(
+ TokenType::AssertReturnArithmeticNan, out_command);
+}
+
+Result WastParser::ParseAssertReturnCanonicalNanCommand(
+ CommandPtr* out_command) {
+ WABT_TRACE(ParseAssertReturnCanonicalNanCommand);
+ return ParseAssertActionCommand<AssertReturnCanonicalNanCommand>(
+ TokenType::AssertReturnCanonicalNan, out_command);
+}
+
+Result WastParser::ParseAssertTrapCommand(CommandPtr* out_command) {
+ WABT_TRACE(ParseAssertTrapCommand);
+ EXPECT(Lpar);
+ EXPECT(AssertTrap);
+ if (PeekMatchLpar(TokenType::Module)) {
+ std::unique_ptr<ScriptModule> module;
+ std::string text;
+ CHECK_RESULT(ParseScriptModule(&module));
+ CHECK_RESULT(ParseQuotedText(&text));
+ out_command->reset(new AssertUninstantiableCommand(module.release(), text));
+ } else {
+ auto action = make_unique<Action>();
+ std::string text;
+ CHECK_RESULT(ParseAction(action.get()));
+ CHECK_RESULT(ParseQuotedText(&text));
+ out_command->reset(new AssertTrapCommand(action.release(), text));
+ }
+ EXPECT(Rpar);
+ return Result::Ok;
+}
+
+Result WastParser::ParseAssertUnlinkableCommand(CommandPtr* out_command) {
+ WABT_TRACE(ParseAssertUnlinkableCommand);
+ return ParseAssertScriptModuleCommand<AssertUnlinkableCommand>(
+ TokenType::AssertUnlinkable, out_command);
+}
+
+Result WastParser::ParseActionCommand(CommandPtr* out_command) {
+ WABT_TRACE(ParseActionCommand);
+ auto action = make_unique<Action>();
+ CHECK_RESULT(ParseAction(action.get()));
+ out_command->reset(new ActionCommand(action.release()));
+ return Result::Ok;
+}
+
+Result WastParser::ParseModuleCommand(CommandPtr* out_command) {
+ WABT_TRACE(ParseModuleCommand);
+ std::unique_ptr<ScriptModule> script_module;
+ CHECK_RESULT(ParseScriptModule(&script_module));
+
+ std::unique_ptr<Module> module;
+
+ switch (script_module->type) {
+ case ScriptModule::Type::Text:
+ module.reset(script_module->text);
+ script_module->text = nullptr;
+ break;
+
+ case ScriptModule::Type::Binary: {
+ module.reset(new Module());
+ ReadBinaryOptions options;
+ BinaryErrorHandlerModule error_handler(&script_module->binary.loc, this);
+ const char* filename = "<text>";
+ ReadBinaryIr(filename, script_module->binary.data.data(),
+ script_module->binary.data.size(), &options, &error_handler,
+ module.get());
+ module->name = script_module->binary.name;
+ module->loc = script_module->binary.loc;
+ break;
+ }
+
+ case ScriptModule::Type::Quoted:
+ return ErrorExpected({"a binary module", "a text module"});
+ }
+
+ Index command_index = script_->commands.size();
+
+ if (!module->name.empty()) {
+ script_->module_bindings.emplace(module->name,
+ Binding(module->loc, command_index));
+ }
+
+ last_module_index_ = command_index;
+
+ out_command->reset(new ModuleCommand(module.release()));
+ return Result::Ok;
+}
+
+Result WastParser::ParseRegisterCommand(CommandPtr* out_command) {
+ WABT_TRACE(ParseRegisterCommand);
+ EXPECT(Lpar);
+ auto loc = GetLocation();
+ EXPECT(Register);
+ std::string text;
+ Var var;
+ CHECK_RESULT(ParseQuotedText(&text));
+ ParseVarOpt(&var, Var(last_module_index_, loc));
+ EXPECT(Rpar);
+ out_command->reset(new RegisterCommand(text, var));
+ return Result::Ok;
+}
+
+Result WastParser::ParseAction(Action* out_action) {
+ WABT_TRACE(ParseAction);
+ EXPECT(Lpar);
+ auto loc = GetLocation();
+
+ switch (Peek()) {
+ case TokenType::Invoke:
+ out_action->loc = loc;
+ out_action->type = ActionType::Invoke;
+ out_action->invoke = new ActionInvoke();
+
+ Consume();
+ ParseVarOpt(&out_action->module_var, Var(last_module_index_, loc));
+ CHECK_RESULT(ParseQuotedText(&out_action->name));
+ CHECK_RESULT(ParseConstList(&out_action->invoke->args));
+ break;
+
+ case TokenType::Get:
+ out_action->loc = loc;
+ out_action->type = ActionType::Get;
+
+ Consume();
+ ParseVarOpt(&out_action->module_var, Var(last_module_index_, loc));
+ CHECK_RESULT(ParseQuotedText(&out_action->name));
+ break;
+
+ default:
+ return ErrorExpected({"invoke", "get"});
+ }
+ EXPECT(Rpar);
+ return Result::Ok;
+}
+
+Result WastParser::ParseScriptModule(
+ std::unique_ptr<ScriptModule>* out_module) {
+ WABT_TRACE(ParseScriptModule);
+ EXPECT(Lpar);
+ auto loc = GetLocation();
+ EXPECT(Module);
+ std::string name;
+ ParseBindVarOpt(&name);
+
+ std::unique_ptr<ScriptModule> script_module;
+
+ switch (Peek()) {
+ case TokenType::Bin: {
+ Consume();
+ std::vector<uint8_t> data;
+ CHECK_RESULT(ParseTextList(&data));
+
+ script_module = make_unique<ScriptModule>(ScriptModule::Type::Binary);
+ script_module->binary.name = name;
+ script_module->binary.loc = loc;
+ script_module->binary.data = std::move(data);
+ break;
+ }
+
+ case TokenType::Quote: {
+ Consume();
+ std::vector<uint8_t> data;
+ CHECK_RESULT(ParseTextList(&data));
+
+ script_module = make_unique<ScriptModule>(ScriptModule::Type::Quoted);
+ script_module->quoted.name = name;
+ script_module->quoted.loc = loc;
+ script_module->quoted.data = std::move(data);
+ break;
+ }
+
+ default: {
+ script_module = make_unique<ScriptModule>(ScriptModule::Type::Text);
+ auto module = make_unique<Module>();
+ module->loc = loc;
+ module->name = name;
+ CHECK_RESULT(ParseModuleFieldList(module.get()));
+ script_module->text = module.release();
+ break;
+ }
+ }
+
+ *out_module = std::move(script_module);
+
+ EXPECT(Rpar);
+ return Result::Ok;
+}
+
+template <typename T>
+Result WastParser::ParseAssertActionCommand(TokenType token_type,
+ CommandPtr* out_command) {
+ WABT_TRACE(ParseAssertActionCommand);
+ EXPECT(Lpar);
+ CHECK_RESULT(Expect(token_type));
+ auto action = make_unique<Action>();
+ CHECK_RESULT(ParseAction(action.get()));
+ EXPECT(Rpar);
+ out_command->reset(new T(action.release()));
+ return Result::Ok;
+}
+
+template <typename T>
+Result WastParser::ParseAssertActionTextCommand(TokenType token_type,
+ CommandPtr* out_command) {
+ WABT_TRACE(ParseAssertActionTextCommand);
+ EXPECT(Lpar);
+ CHECK_RESULT(Expect(token_type));
+ auto action = make_unique<Action>();
+ std::string text;
+ CHECK_RESULT(ParseAction(action.get()));
+ CHECK_RESULT(ParseQuotedText(&text));
+ EXPECT(Rpar);
+ out_command->reset(new T(action.release(), text));
+ return Result::Ok;
+}
+
+template <typename T>
+Result WastParser::ParseAssertScriptModuleCommand(TokenType token_type,
+ CommandPtr* out_command) {
+ WABT_TRACE(ParseAssertScriptModuleCommand);
+ EXPECT(Lpar);
+ CHECK_RESULT(Expect(token_type));
+ std::unique_ptr<ScriptModule> module;
+ std::string text;
+ CHECK_RESULT(ParseScriptModule(&module));
+ CHECK_RESULT(ParseQuotedText(&text));
+ EXPECT(Rpar);
+ out_command->reset(new T(module.release(), text));
+ return Result::Ok;
+}
+
+void WastParser::CheckImportOrdering(Module* module) {
+ if (module->funcs.size() != module->num_func_imports ||
+ module->tables.size() != module->num_table_imports ||
+ module->memories.size() != module->num_memory_imports ||
+ module->globals.size() != module->num_global_imports ||
+ module->excepts.size() != module->num_except_imports) {
+ Error(GetLocation(),
+ "imports must occur before all non-import definitions");
+ }
+}
+
+Result ParseWast(WastLexer* lexer,
+ Script** out_script,
+ ErrorHandler* error_handler,
+ WastParseOptions* options) {
+ auto script = make_unique<Script>();
+ WastParser parser(lexer, error_handler, options);
+ Result result = parser.ParseScript(script.get());
+
+ if (out_script)
+ *out_script = script.release();
+
+ return result;
+}
+
+} // namespace wabt
diff --git a/src/wast-parser.h b/src/wast-parser.h
index a2c06e34..8251df9d 100644
--- a/src/wast-parser.h
+++ b/src/wast-parser.h
@@ -17,11 +17,15 @@
#ifndef WABT_WAST_PARSER_H_
#define WABT_WAST_PARSER_H_
+#include <array>
+
+#include "circular-array.h"
+#include "ir.h"
+#include "intrusive-list.h"
#include "wast-lexer.h"
namespace wabt {
-struct Script;
class ErrorHandler;
struct WastParseOptions {
@@ -29,6 +33,175 @@ struct WastParseOptions {
bool debug_parsing = false;
};
+typedef std::array<TokenType, 2> TokenTypePair;
+
+class WastParser {
+ public:
+ WastParser(WastLexer*, ErrorHandler*, WastParseOptions*);
+
+ void WABT_PRINTF_FORMAT(3, 4) Error(Location, const char* format, ...);
+ Result ParseScript(Script*);
+
+ private:
+ void ErrorUnlessExceptionsAllowed();
+
+ // Print an error message listing the expected tokens, as well as an example
+ // of expected input.
+ Result ErrorExpected(const std::vector<std::string>& expected,
+ const char* example = nullptr);
+
+ // Print an error message, and and return Result::Error if the next token is
+ // '('. This is commonly used after parsing a sequence of s-expressions -- if
+ // no more can be parsed, we know that a following '(' is invalid. This
+ // function consumes the '(' so a better error message can be provided
+ // (assuming the following token was unexpected).
+ Result ErrorIfLpar(const std::vector<std::string>& expected,
+ const char* example = nullptr);
+
+ // Returns the next token without consuming it.
+ Token GetToken();
+
+ // Returns the location of the next token.
+ Location GetLocation();
+
+ // Returns the type of the next token.
+ TokenType Peek(size_t n = 0);
+
+ // Returns the types of the next two tokens.
+ TokenTypePair PeekPair();
+
+ // Returns true if the next token's type is equal to the parameter.
+ bool PeekMatch(TokenType);
+
+ // Returns true if the next token's type is '(' and the following token is
+ // equal to the parameter.
+ bool PeekMatchLpar(TokenType);
+
+ // Returns true if the next two tokens can start an Expr. This allows for
+ // folded expressions, plain instructions and block instructions.
+ bool PeekMatchExpr();
+
+ // Returns true if the next token's type is equal to the parameter. If so,
+ // then the token is consumed.
+ bool Match(TokenType);
+
+ // Returns true if the next token's type is equal to '(' and the following
+ // token is equal to the parameter. If so, then the token is consumed.
+ bool MatchLpar(TokenType);
+
+ // Like Match(), but prints an error message if the token doesn't match, and
+ // returns Result::Error.
+ Result Expect(TokenType);
+
+ // Consume one token and return it.
+ Token Consume();
+
+ // Give the Match() function a clearer name when used to optionally consume a
+ // token (used for printing better error messages).
+ void ConsumeIfLpar() { Match(TokenType::Lpar); }
+
+ typedef bool SynchronizeFunc(TokenTypePair pair);
+
+ // Attempt to synchronize the token stream by dropping tokens until the
+ // SynchronizeFunc returns true, or until a token limit is reached. This
+ // function returns Result::Error if the stream was not able to be
+ // synchronized.
+ Result Synchronize(SynchronizeFunc);
+
+ void ParseBindVarOpt(std::string* name);
+ Result ParseVar(Var* out_var);
+ bool ParseVarOpt(Var* out_var, Var default_var = Var());
+ Result ParseOffsetExpr(ExprList* out_expr_list);
+ Result ParseTextList(std::vector<uint8_t>* out_data);
+ bool ParseTextListOpt(std::vector<uint8_t>* out_data);
+ Result ParseVarList(VarVector* out_var_list);
+ bool ParseVarListOpt(VarVector* out_var_list);
+ Result ParseValueType(Type* out_type);
+ Result ParseValueTypeList(TypeVector* out_type_list);
+ Result ParseQuotedText(std::string* text);
+ bool ParseOffsetOpt(uint32_t* offset);
+ bool ParseAlignOpt(uint32_t* align);
+ Result ParseLimits(Limits*);
+ Result ParseNat(uint64_t*);
+
+ Result ParseModuleFieldList(Module*);
+ Result ParseModuleField(Module*);
+ Result ParseDataModuleField(Module*);
+ Result ParseElemModuleField(Module*);
+ Result ParseExceptModuleField(Module*);
+ Result ParseExportModuleField(Module*);
+ Result ParseFuncModuleField(Module*);
+ Result ParseTypeModuleField(Module*);
+ Result ParseGlobalModuleField(Module*);
+ Result ParseImportModuleField(Module*);
+ Result ParseMemoryModuleField(Module*);
+ Result ParseStartModuleField(Module*);
+ Result ParseTableModuleField(Module*);
+
+ Result ParseExportDesc(Export*);
+ Result ParseInlineExports(ModuleFieldList*, ExternalKind);
+ Result ParseInlineImport(Import*);
+ Result ParseTypeUseOpt(FuncDeclaration*);
+ Result ParseFuncSignature(FuncSignature*, BindingHash* param_bindings);
+ Result ParseBoundValueTypeList(TokenType, TypeVector*, BindingHash*);
+ Result ParseResultList(TypeVector*);
+ Result ParseInstrList(ExprList*);
+ Result ParseTerminatingInstrList(ExprList*);
+ Result ParseInstr(ExprList*);
+ Result ParsePlainInstr(std::unique_ptr<Expr>*);
+ Result ParseConst(Const*);
+ Result ParseConstList(ConstVector*);
+ Result ParseBlockInstr(std::unique_ptr<Expr>*);
+ Result ParseLabelOpt(std::string*);
+ Result ParseEndLabelOpt(const std::string&);
+ Result ParseBlock(Block*);
+ Result ParseExprList(ExprList*);
+ Result ParseExpr(ExprList*);
+ Result ParseCatchInstrList(CatchVector* catches);
+ Result ParseCatchExprList(CatchVector* catches);
+ Result ParseGlobalType(Global*);
+
+ template <typename T>
+ Result ParsePlainInstrVar(Location, std::unique_ptr<Expr>*);
+
+ Result ParseCommandList(CommandPtrVector*);
+ Result ParseCommand(CommandPtr*);
+ Result ParseAssertExhaustionCommand(CommandPtr*);
+ Result ParseAssertInvalidCommand(CommandPtr*);
+ Result ParseAssertMalformedCommand(CommandPtr*);
+ Result ParseAssertReturnCommand(CommandPtr*);
+ Result ParseAssertReturnArithmeticNanCommand(CommandPtr*);
+ Result ParseAssertReturnCanonicalNanCommand(CommandPtr*);
+ Result ParseAssertTrapCommand(CommandPtr*);
+ Result ParseAssertUnlinkableCommand(CommandPtr*);
+ Result ParseActionCommand(CommandPtr*);
+ Result ParseModuleCommand(CommandPtr*);
+ Result ParseRegisterCommand(CommandPtr*);
+
+ Result ParseAction(Action*);
+ Result ParseScriptModule(std::unique_ptr<ScriptModule>*);
+
+ template <typename T>
+ Result ParseActionCommand(TokenType, CommandPtr*);
+ template <typename T>
+ Result ParseAssertActionCommand(TokenType, CommandPtr*);
+ template <typename T>
+ Result ParseAssertActionTextCommand(TokenType, CommandPtr*);
+ template <typename T>
+ Result ParseAssertScriptModuleCommand(TokenType, CommandPtr*);
+
+ void CheckImportOrdering(Module*);
+
+ WastLexer* lexer_;
+ Script* script_ = nullptr;
+ Index last_module_index_ = kInvalidIndex;
+ ErrorHandler* error_handler_;
+ int errors_ = 0;
+ WastParseOptions* options_;
+
+ CircularArray<Token, 2> tokens_;
+};
+
Result ParseWast(WastLexer* lexer,
Script** out_script,
ErrorHandler*,
diff --git a/src/wast-parser.y b/src/wast-parser.y
deleted file mode 100644
index 39423abd..00000000
--- a/src/wast-parser.y
+++ /dev/null
@@ -1,1848 +0,0 @@
-/*
- * Copyright 2016 WebAssembly Community Group participants
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-%{
-#include <algorithm>
-#include <cassert>
-#include <cstdarg>
-#include <cstdio>
-#include <cstdlib>
-#include <iterator>
-#include <utility>
-
-#include "binary-reader.h"
-#include "binary-reader-ir.h"
-#include "cast.h"
-#include "error-handler.h"
-#include "literal.h"
-#include "string-view.h"
-#include "wast-parser.h"
-#include "wast-parser-lexer-shared.h"
-
-#define YYDEBUG 1
-
-#define RELOCATE_STACK(type, array, stack_base, old_size, new_size) \
- do { \
- type* new_stack = new type[new_size](); \
- std::move((stack_base), (stack_base) + (old_size), (new_stack)); \
- if ((stack_base) != (array)) { \
- delete[](stack_base); \
- } else { \
- for (size_t i = 0; i < (old_size); ++i) { \
- (stack_base)[i].~type(); \
- } \
- } \
- /* Cache the pointer in the parser struct to be deleted later. */ \
- parser->array = (stack_base) = new_stack; \
- } while (0)
-
-#define yyoverflow(message, ss, ss_size, vs, vs_size, ls, ls_size, new_size) \
- do { \
- size_t old_size = *(new_size); \
- *(new_size) *= 2; \
- RELOCATE_STACK(yytype_int16, yyssa, *(ss), old_size, *(new_size)); \
- RELOCATE_STACK(YYSTYPE, yyvsa, *(vs), old_size, *(new_size)); \
- RELOCATE_STACK(YYLTYPE, yylsa, *(ls), old_size, *(new_size)); \
- } while (0)
-
-#define YYLLOC_DEFAULT(Current, Rhs, N) \
- do \
- if (N) { \
- (Current).filename = YYRHSLOC(Rhs, 1).filename; \
- (Current).line = YYRHSLOC(Rhs, 1).line; \
- (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \
- if (YYRHSLOC(Rhs, N).line == (Current).line) \
- (Current).last_column = YYRHSLOC(Rhs, N).last_column; \
- else \
- (Current).last_column = YYRHSLOC(Rhs, 1).last_column; \
- } else { \
- (Current).filename = nullptr; \
- (Current).line = YYRHSLOC(Rhs, 0).line; \
- (Current).first_column = (Current).last_column = \
- YYRHSLOC(Rhs, 0).last_column; \
- } \
- while (0)
-
-#define CHECK_END_LABEL(loc, begin_label, end_label) \
- do { \
- if (!end_label->empty()) { \
- if (begin_label.empty()) { \
- WastParserError(&loc, lexer, parser, "unexpected label \"%s\"", \
- end_label->c_str()); \
- } else if (begin_label != *end_label) { \
- WastParserError(&loc, lexer, parser, \
- "mismatching label \"%s\" != \"%s\"", \
- begin_label.c_str(), end_label->c_str()); \
- } \
- } \
- delete (end_label); \
- } while (0)
-
-#define CHECK_ALLOW_EXCEPTIONS(loc, opcode_name) \
- do { \
- if (!parser->options->allow_future_exceptions) { \
- WastParserError(loc, lexer, parser, "opcode not allowed: %s", \
- opcode_name); \
- } \
- } while (0)
-
-#define YYMALLOC(size) new char [size]
-#define YYFREE(p) delete [] (p)
-
-#define USE_NATURAL_ALIGNMENT (~0)
-
-namespace wabt {
-
-static bool IsPowerOfTwo(uint32_t x) {
- return x && ((x & (x - 1)) == 0);
-}
-
-Result ParseConst(Type type, const Literal& literal, Const* out);
-
-static void ReverseBindings(TypeVector*, BindingHash*);
-
-static bool IsEmptySignature(const FuncSignature* sig);
-
-static void CheckImportOrdering(Location* loc,
- WastLexer* lexer,
- WastParser* parser,
- Module* module,
- const ModuleFieldList&);
-static void AppendModuleFields(Module*, ModuleFieldList&&);
-static void ResolveFuncTypes(Module*);
-
-class BinaryErrorHandlerModule : public ErrorHandler {
- public:
- BinaryErrorHandlerModule(Location* loc, WastLexer* lexer, WastParser* parser);
- bool OnError(const Location&,
- const std::string& error,
- const std::string& source_line,
- size_t source_line_column_offset) override;
-
- // Unused.
- size_t source_line_max_length() const override { return 0; }
-
- private:
- Location* loc_;
- WastLexer* lexer_;
- WastParser* parser_;
-};
-
-template <typename OutputIter>
-void RemoveEscapes(string_view text, OutputIter dest) {
- // Remove surrounding quotes; if any. This may be empty if the string was
- // invalid (e.g. if it contained a bad escape sequence).
- if (text.size() <= 2)
- return;
-
- text = text.substr(1, text.size() - 2);
-
- const char* src = text.data();
- const char* end = text.data() + text.size();
-
- while (src < end) {
- if (*src == '\\') {
- src++;
- switch (*src) {
- case 'n':
- *dest++ = '\n';
- break;
- case 'r':
- *dest++ = '\r';
- break;
- case 't':
- *dest++ = '\t';
- break;
- case '\\':
- *dest++ = '\\';
- break;
- case '\'':
- *dest++ = '\'';
- break;
- case '\"':
- *dest++ = '\"';
- break;
- default: {
- // The string should be validated already, so we know this is a hex
- // sequence.
- uint32_t hi;
- uint32_t lo;
- if (Succeeded(ParseHexdigit(src[0], &hi)) &&
- Succeeded(ParseHexdigit(src[1], &lo))) {
- *dest++ = (hi << 4) | lo;
- } else {
- assert(0);
- }
- src++;
- break;
- }
- }
- src++;
- } else {
- *dest++ = *src++;
- }
- }
-}
-
-template <typename OutputIter>
-void RemoveEscapes(const TextVector& texts, OutputIter out) {
- for (const std::string& text: texts)
- RemoveEscapes(text, out);
-}
-
-template <typename T>
-T MoveAndDelete(T* ptr) {
- T result = std::move(*ptr);
- delete ptr;
- return result;
-}
-
-template <typename T, typename U>
-void PrependAndDelete(T& dest, U* source) {
- dest.insert(dest.begin(), std::begin(*source), std::end(*source));
- delete source;
-}
-
-template <typename T, typename U>
-void AppendAndDelete(T& dest, U* source) {
- dest.insert(dest.end(), std::begin(*source), std::end(*source));
- delete source;
-}
-
-#define wabt_wast_parser_lex(...) lexer->GetToken(__VA_ARGS__, parser)
-#define wabt_wast_parser_error WastParserError
-
-%}
-
-%define api.prefix {wabt_wast_parser_}
-%define api.pure true
-%define api.value.type {::wabt::Token}
-%define api.token.prefix {WABT_TOKEN_TYPE_}
-%define parse.error verbose
-%parse-param {::wabt::WastLexer* lexer} {::wabt::WastParser* parser}
-%locations
-
-%token LPAR "("
-%token RPAR ")"
-%token NAT INT FLOAT TEXT VAR VALUE_TYPE ANYFUNC MUT
-%token NOP DROP BLOCK END IF THEN ELSE LOOP BR BR_IF BR_TABLE
-%token TRY CATCH CATCH_ALL THROW RETHROW
-%token LPAR_CATCH LPAR_CATCH_ALL
-%token CALL CALL_INDIRECT RETURN
-%token GET_LOCAL SET_LOCAL TEE_LOCAL GET_GLOBAL SET_GLOBAL
-%token LOAD STORE OFFSET_EQ_NAT ALIGN_EQ_NAT
-%token CONST UNARY BINARY COMPARE CONVERT SELECT
-%token UNREACHABLE CURRENT_MEMORY GROW_MEMORY
-%token FUNC START TYPE PARAM RESULT LOCAL GLOBAL
-%token TABLE ELEM MEMORY DATA OFFSET IMPORT EXPORT EXCEPT
-%token MODULE BIN QUOTE
-%token REGISTER INVOKE GET
-%token ASSERT_MALFORMED ASSERT_INVALID ASSERT_UNLINKABLE
-%token ASSERT_RETURN ASSERT_RETURN_CANONICAL_NAN ASSERT_RETURN_ARITHMETIC_NAN
-%token ASSERT_TRAP ASSERT_EXHAUSTION
-%token EOF 0 "EOF"
-
-%type<t_opcode> BINARY COMPARE CONVERT LOAD STORE UNARY
-%type<t_text> ALIGN_EQ_NAT OFFSET_EQ_NAT TEXT VAR
-%type<t_type> SELECT
-%type<t_type> CONST VALUE_TYPE
-%type<t_literal> NAT INT FLOAT
-
-%type<action> action
-%type<block> block
-%type<command> assertion cmd
-%type<commands> cmd_list
-%type<const_> const
-%type<consts> const_list
-%type<exception> exception
-%type<export_> export_desc inline_export
-%type<expr> plain_instr block_instr
-%type<catch_> plain_catch plain_catch_all catch_instr catch_sexp
-%type<expr_list> instr instr_list expr expr1 expr_list if_ if_block const_expr offset
-%type<func> func_fields_body func_fields_body1 func_result_body func_body func_body1
-%type<func> func_fields_import func_fields_import1 func_fields_import_result
-%type<func_sig> func_sig func_sig_result func_type
-%type<global> global_type
-%type<import> import_desc inline_import
-%type<limits> limits
-%type<memory> memory_sig
-%type<module> module module_fields_opt module_fields inline_module
-%type<module_field> type_def start data elem import export exception_field
-%type<module_fields> func func_fields table table_fields memory memory_fields global global_fields module_field
-%type<script_module> script_module
-%type<literal> literal
-%type<script> script
-%type<string> bind_var bind_var_opt labeling_opt quoted_text
-%type<table> table_sig
-%type<texts> text_list text_list_opt
-%type<try_expr> try_ catch_sexp_list catch_instr_list
-%type<types> block_sig value_type_list
-%type<u32> align_opt
-%type<u64> nat offset_opt
-%type<vars> var_list
-%type<var> type_use var script_var_opt
-
-%destructor { delete $$; } <action>
-%destructor { delete $$; } <block>
-%destructor { delete $$; } <command>
-%destructor { delete $$; } <commands>
-%destructor { delete $$; } <consts>
-%destructor { delete $$; } <export_>
-%destructor { delete $$; } <expr>
-%destructor { delete $$; } <expr_list>
-%destructor { delete $$; } <module_fields>
-%destructor { delete $$; } <func>
-%destructor { delete $$; } <func_sig>
-%destructor { delete $$; } <global>
-%destructor { delete $$; } <import>
-%destructor { delete $$; } <memory>
-%destructor { delete $$; } <module>
-%destructor { delete $$; } <script_module>
-%destructor { delete $$; } <script>
-%destructor { delete $$; } <string>
-%destructor { delete $$; } <texts>
-%destructor { delete $$; } <types>
-%destructor { delete $$; } <var>
-%destructor { delete $$; } <vars>
-
-
-%nonassoc LOW
-%nonassoc VAR
-
-%start script_start
-
-%%
-
-/* Auxiliaries */
-
-text_list :
- TEXT {
- $$ = new TextVector();
- $$->emplace_back($1.to_string());
- }
- | text_list TEXT {
- $$ = $1;
- $$->emplace_back($2.to_string());
- }
-;
-text_list_opt :
- /* empty */ { $$ = new TextVector(); }
- | text_list
-;
-
-quoted_text :
- TEXT {
- $$ = new std::string();
- RemoveEscapes($1.to_string_view(), std::back_inserter(*$$));
- }
-;
-
-/* Types */
-
-value_type_list :
- /* empty */ { $$ = new TypeVector(); }
- | value_type_list VALUE_TYPE {
- $$ = $1;
- $$->push_back($2);
- }
-;
-elem_type :
- ANYFUNC {}
-;
-global_type :
- VALUE_TYPE {
- $$ = new Global();
- $$->type = $1;
- $$->mutable_ = false;
- }
- | LPAR MUT VALUE_TYPE RPAR {
- $$ = new Global();
- $$->type = $3;
- $$->mutable_ = true;
- }
-;
-
-func_type :
- LPAR FUNC func_sig RPAR { $$ = $3; }
-;
-
-func_sig :
- func_sig_result
- | LPAR PARAM value_type_list RPAR func_sig {
- $$ = $5;
- PrependAndDelete($$->param_types, $3);
- }
- | LPAR PARAM bind_var VALUE_TYPE RPAR func_sig {
- $$ = $6;
- $$->param_types.insert($$->param_types.begin(), $4);
- // Ignore bind_var.
- delete $3;
- }
-;
-
-func_sig_result :
- /* empty */ { $$ = new FuncSignature(); }
- | LPAR RESULT value_type_list RPAR func_sig_result {
- $$ = $5;
- PrependAndDelete($$->result_types, $3);
- }
-;
-
-table_sig :
- limits elem_type {
- $$ = new Table();
- $$->elem_limits = $1;
- }
-;
-memory_sig :
- limits {
- $$ = new Memory();
- $$->page_limits = $1;
- }
-;
-limits :
- nat {
- $$.has_max = false;
- $$.initial = $1;
- $$.max = 0;
- }
- | nat nat {
- $$.has_max = true;
- $$.initial = $1;
- $$.max = $2;
- }
-;
-type_use :
- LPAR TYPE var RPAR { $$ = $3; }
-;
-
-/* Expressions */
-
-nat :
- NAT {
- string_view sv = $1.text.to_string_view();
- if (Failed(ParseUint64(sv.begin(), sv.end(), &$$))) {
- WastParserError(&@1, lexer, parser, "invalid int \"" PRIstringview "\"",
- WABT_PRINTF_STRING_VIEW_ARG(sv));
- }
- }
-;
-
-literal :
- NAT {
- $$ = new Literal($1);
- }
- | INT {
- $$ = new Literal($1);
- }
- | FLOAT {
- $$ = new Literal($1);
- }
-;
-
-var :
- nat {
- $$ = new Var($1, @1);
- }
- | VAR {
- $$ = new Var($1.to_string_view(), @1);
- }
-;
-var_list :
- /* empty */ { $$ = new VarVector(); }
- | var_list var {
- $$ = $1;
- $$->emplace_back(MoveAndDelete($2));
- }
-;
-bind_var_opt :
- /* empty */ { $$ = new std::string(); }
- | bind_var
-;
-bind_var :
- VAR { $$ = new std::string($1.to_string()); }
-;
-
-labeling_opt :
- /* empty */ %prec LOW { $$ = new std::string(); }
- | bind_var
-;
-
-offset_opt :
- /* empty */ { $$ = 0; }
- | OFFSET_EQ_NAT {
- uint64_t offset64;
- string_view sv = $1.to_string_view();
- if (Failed(ParseInt64(sv.begin(), sv.end(), &offset64,
- ParseIntType::SignedAndUnsigned))) {
- WastParserError(&@1, lexer, parser,
- "invalid offset \"" PRIstringview "\"",
- WABT_PRINTF_STRING_VIEW_ARG(sv));
- }
- if (offset64 > UINT32_MAX) {
- WastParserError(&@1, lexer, parser,
- "offset must be less than or equal to 0xffffffff");
- }
- $$ = static_cast<uint32_t>(offset64);
- }
-;
-align_opt :
- /* empty */ { $$ = USE_NATURAL_ALIGNMENT; }
- | ALIGN_EQ_NAT {
- string_view sv = $1.to_string_view();
- if (Failed(ParseInt32(sv.begin(), sv.end(), &$$,
- ParseIntType::UnsignedOnly))) {
- WastParserError(&@1, lexer, parser,
- "invalid alignment \"" PRIstringview "\"",
- WABT_PRINTF_STRING_VIEW_ARG(sv));
- }
-
- if ($$ != WABT_USE_NATURAL_ALIGNMENT && !IsPowerOfTwo($$)) {
- WastParserError(&@1, lexer, parser, "alignment must be power-of-two");
- }
- }
-;
-
-instr :
- plain_instr {
- $$ = new ExprList($1);
- $$->back().loc = @1;
- }
- | block_instr {
- $$ = new ExprList($1);
- $$->back().loc = @1;
- }
- | expr
-;
-
-plain_instr :
- UNREACHABLE {
- $$ = new UnreachableExpr();
- }
- | NOP {
- $$ = new NopExpr();
- }
- | DROP {
- $$ = new DropExpr();
- }
- | SELECT {
- $$ = new SelectExpr();
- }
- | BR var {
- $$ = new BrExpr(MoveAndDelete($2));
- }
- | BR_IF var {
- $$ = new BrIfExpr(MoveAndDelete($2));
- }
- | BR_TABLE var_list var {
- $$ = new BrTableExpr($2, MoveAndDelete($3));
- }
- | RETURN {
- $$ = new ReturnExpr();
- }
- | CALL var {
- $$ = new CallExpr(MoveAndDelete($2));
- }
- | CALL_INDIRECT var {
- $$ = new CallIndirectExpr(MoveAndDelete($2));
- }
- | GET_LOCAL var {
- $$ = new GetLocalExpr(MoveAndDelete($2));
- }
- | SET_LOCAL var {
- $$ = new SetLocalExpr(MoveAndDelete($2));
- }
- | TEE_LOCAL var {
- $$ = new TeeLocalExpr(MoveAndDelete($2));
- }
- | GET_GLOBAL var {
- $$ = new GetGlobalExpr(MoveAndDelete($2));
- }
- | SET_GLOBAL var {
- $$ = new SetGlobalExpr(MoveAndDelete($2));
- }
- | LOAD offset_opt align_opt {
- $$ = new LoadExpr($1, $3, $2);
- }
- | STORE offset_opt align_opt {
- $$ = new StoreExpr($1, $3, $2);
- }
- | CONST literal {
- Const const_;
- const_.loc = @1;
- auto literal = MoveAndDelete($2);
- if (Failed(ParseConst($1, literal, &const_))) {
- WastParserError(&@2, lexer, parser, "invalid literal \"%s\"",
- literal.text.c_str());
- }
- $$ = new ConstExpr(const_);
- }
- | UNARY {
- $$ = new UnaryExpr($1);
- }
- | BINARY {
- $$ = new BinaryExpr($1);
- }
- | COMPARE {
- $$ = new CompareExpr($1);
- }
- | CONVERT {
- $$ = new ConvertExpr($1);
- }
- | CURRENT_MEMORY {
- $$ = new CurrentMemoryExpr();
- }
- | GROW_MEMORY {
- $$ = new GrowMemoryExpr();
- }
- | throw_check var {
- $$ = new ThrowExpr(MoveAndDelete($2));
- }
- | rethrow_check var {
- $$ = new RethrowExpr(MoveAndDelete($2));
- }
-;
-
-block_instr :
- BLOCK labeling_opt block END labeling_opt {
- auto expr = new BlockExpr($3);
- expr->block->label = MoveAndDelete($2);
- CHECK_END_LABEL(@5, expr->block->label, $5);
- $$ = expr;
- }
- | LOOP labeling_opt block END labeling_opt {
- auto expr = new LoopExpr($3);
- expr->block->label = MoveAndDelete($2);
- CHECK_END_LABEL(@5, expr->block->label, $5);
- $$ = expr;
- }
- | IF labeling_opt block END labeling_opt {
- auto expr = new IfExpr($3);
- expr->true_->label = MoveAndDelete($2);
- CHECK_END_LABEL(@5, expr->true_->label, $5);
- $$ = expr;
- }
- | IF labeling_opt block ELSE labeling_opt instr_list END labeling_opt {
- auto expr = new IfExpr($3, MoveAndDelete($6));
- expr->true_->label = MoveAndDelete($2);
- CHECK_END_LABEL(@5, expr->true_->label, $5);
- CHECK_END_LABEL(@8, expr->true_->label, $8);
- $$ = expr;
- }
- | try_check labeling_opt block catch_instr_list END labeling_opt {
- $3->label = MoveAndDelete($2);
- $$ = $4;
- cast<TryExpr>($$)->block = $3;
- CHECK_END_LABEL(@6, $3->label, $6);
- }
-;
-
-block_sig :
- LPAR RESULT value_type_list RPAR { $$ = $3; }
-;
-block :
- block_sig block {
- $$ = $2;
- AppendAndDelete($$->sig, $1);
- }
- | instr_list {
- $$ = new Block(MoveAndDelete($1));
- }
-;
-
-plain_catch :
- CATCH var instr_list {
- $$ = new Catch(MoveAndDelete($2), MoveAndDelete($3));
- $$->loc = @1;
- }
- ;
-plain_catch_all :
- CATCH_ALL instr_list {
- $$ = new Catch(MoveAndDelete($2));
- $$->loc = @1;
- }
- ;
-
-catch_instr :
- plain_catch
- | plain_catch_all
- ;
-
-catch_instr_list :
- catch_instr {
- auto expr = new TryExpr();
- expr->catches.push_back($1);
- $$ = expr;
- }
- | catch_instr_list catch_instr {
- $$ = $1;
- cast<TryExpr>($$)->catches.push_back($2);
- }
- ;
-
-expr :
- LPAR expr1 RPAR { $$ = $2; }
-;
-
-expr1 :
- plain_instr expr_list {
- $$ = $2;
- $$->push_back($1);
- $1->loc = @1;
- }
- | BLOCK labeling_opt block {
- auto expr = new BlockExpr($3);
- expr->block->label = MoveAndDelete($2);
- expr->loc = @1;
- $$ = new ExprList(expr);
- }
- | LOOP labeling_opt block {
- auto expr = new LoopExpr($3);
- expr->block->label = MoveAndDelete($2);
- expr->loc = @1;
- $$ = new ExprList(expr);
- }
- | IF labeling_opt if_block {
- $$ = $3;
- IfExpr* if_ = cast<IfExpr>(&$3->back());
- if_->true_->label = MoveAndDelete($2);
- }
- | try_check labeling_opt try_ {
- Block* block = $3->block;
- block->label = MoveAndDelete($2);
- $3->loc = @1;
- $$ = new ExprList($3);
- }
- ;
-
-try_ :
- block_sig try_ {
- $$ = $2;
- Block* block = $$->block;
- AppendAndDelete(block->sig, $1);
- }
- | instr_list catch_sexp_list {
- Block* block = new Block();
- block->exprs = MoveAndDelete($1);
- $$ = $2;
- $$->block = block;
- }
- ;
-
-catch_sexp :
- LPAR_CATCH LPAR plain_catch RPAR {
- $$ = $3;
- }
- | LPAR_CATCH_ALL LPAR plain_catch_all RPAR {
- $$ = $3;
- }
- ;
-
-catch_sexp_list :
- catch_sexp {
- auto expr = new TryExpr();
- expr->catches.push_back($1);
- $$ = expr;
- }
- | catch_sexp_list catch_sexp {
- $$ = $1;
- cast<TryExpr>($$)->catches.push_back($2);
- }
- ;
-
-
-if_block :
- block_sig if_block {
- IfExpr* if_ = cast<IfExpr>(&$2->back());
- $$ = $2;
- Block* true_ = if_->true_;
- AppendAndDelete(true_->sig, $1);
- }
- | if_
-;
-if_ :
- LPAR THEN instr_list RPAR LPAR ELSE instr_list RPAR {
- Expr* expr = new IfExpr(new Block(MoveAndDelete($3)), MoveAndDelete($7));
- expr->loc = @1;
- $$ = new ExprList(expr);
- }
- | LPAR THEN instr_list RPAR {
- Expr* expr = new IfExpr(new Block(MoveAndDelete($3)));
- expr->loc = @1;
- $$ = new ExprList(expr);
- }
- | expr LPAR THEN instr_list RPAR LPAR ELSE instr_list RPAR {
- Expr* expr = new IfExpr(new Block(MoveAndDelete($4)), MoveAndDelete($8));
- expr->loc = @1;
- $$ = $1;
- $$->push_back(expr);
- }
- | expr LPAR THEN instr_list RPAR {
- Expr* expr = new IfExpr(new Block(MoveAndDelete($4)));
- expr->loc = @1;
- $$ = $1;
- $$->push_back(expr);
- }
- | expr expr expr {
- Expr* expr = new IfExpr(new Block(MoveAndDelete($2)), MoveAndDelete($3));
- expr->loc = @1;
- $$ = $1;
- $$->push_back(expr);
- }
- | expr expr {
- Expr* expr = new IfExpr(new Block(MoveAndDelete($2)));
- expr->loc = @1;
- $$ = $1;
- $$->push_back(expr);
- }
-;
-
-rethrow_check :
- RETHROW {
- CHECK_ALLOW_EXCEPTIONS(&@1, "rethrow");
- }
- ;
-throw_check :
- THROW {
- CHECK_ALLOW_EXCEPTIONS(&@1, "throw");
- }
- ;
-
-try_check :
- TRY {
- CHECK_ALLOW_EXCEPTIONS(&@1, "try");
- }
- ;
-
-instr_list :
- /* empty */ { $$ = new ExprList(); }
- | instr instr_list {
- $$ = $2;
- $$->splice($$->begin(), MoveAndDelete($1));
- }
-;
-expr_list :
- /* empty */ { $$ = new ExprList(); }
- | expr expr_list {
- $$ = $2;
- $$->splice($$->begin(), MoveAndDelete($1));
- }
-
-const_expr :
- instr_list
-;
-
-/* Exceptions */
-exception :
- LPAR EXCEPT bind_var_opt value_type_list RPAR {
- $$ = new Exception(MoveAndDelete($3), MoveAndDelete($4));
- }
- ;
-exception_field :
- exception {
- $$ = new ExceptionModuleField($1);
- }
- ;
-
-/* Functions */
-func :
- LPAR FUNC bind_var_opt func_fields RPAR {
- $$ = $4;
- ModuleField* main_field = &$$->front();
- main_field->loc = @2;
- if (auto func_field = dyn_cast<FuncModuleField>(main_field)) {
- func_field->func->name = MoveAndDelete($3);
- } else {
- cast<ImportModuleField>(main_field)->import->func->name =
- MoveAndDelete($3);
- }
- }
-;
-
-func_fields :
- type_use func_fields_body {
- auto field = new FuncModuleField($2);
- field->func->decl.has_func_type = true;
- field->func->decl.type_var = MoveAndDelete($1);
- $$ = new ModuleFieldList(field);
- }
- | func_fields_body {
- $$ = new ModuleFieldList(new FuncModuleField($1));
- }
- | inline_import type_use func_fields_import {
- auto field = new ImportModuleField($1, @1);
- field->import->kind = ExternalKind::Func;
- field->import->func = $3;
- field->import->func->decl.has_func_type = true;
- field->import->func->decl.type_var = MoveAndDelete($2);
- $$ = new ModuleFieldList(field);
- }
- | inline_import func_fields_import {
- auto field = new ImportModuleField($1, @1);
- field->import->kind = ExternalKind::Func;
- field->import->func = $2;
- $$ = new ModuleFieldList(field);
- }
- | inline_export func_fields {
- auto field = new ExportModuleField($1, @1);
- field->export_->kind = ExternalKind::Func;
- $$ = $2;
- $$->push_back(field);
- }
-;
-
-func_fields_import :
- func_fields_import1 {
- $$ = $1;
- ReverseBindings(&$$->decl.sig.param_types, &$$->param_bindings);
- }
-;
-
-func_fields_import1 :
- func_fields_import_result
- | LPAR PARAM value_type_list RPAR func_fields_import1 {
- $$ = $5;
- PrependAndDelete($$->decl.sig.param_types, $3);
- }
- | LPAR PARAM bind_var VALUE_TYPE RPAR func_fields_import1 {
- $$ = $6;
- $$->param_bindings.emplace(MoveAndDelete($3),
- Binding(@3, $$->decl.sig.param_types.size()));
- $$->decl.sig.param_types.insert($$->decl.sig.param_types.begin(), $4);
- }
-;
-
-func_fields_import_result :
- /* empty */ { $$ = new Func(); }
- | LPAR RESULT value_type_list RPAR func_fields_import_result {
- $$ = $5;
- PrependAndDelete($$->decl.sig.result_types, $3);
- }
-;
-
-func_fields_body :
- func_fields_body1 {
- $$ = $1;
- ReverseBindings(&$$->decl.sig.param_types, &$$->param_bindings);
- }
-;
-
-func_fields_body1 :
- func_result_body
- | LPAR PARAM value_type_list RPAR func_fields_body1 {
- $$ = $5;
- PrependAndDelete($$->decl.sig.param_types, $3);
- }
- | LPAR PARAM bind_var VALUE_TYPE RPAR func_fields_body1 {
- $$ = $6;
- $$->param_bindings.emplace(MoveAndDelete($3),
- Binding(@3, $$->decl.sig.param_types.size()));
- $$->decl.sig.param_types.insert($$->decl.sig.param_types.begin(), $4);
- }
-;
-
-func_result_body :
- func_body
- | LPAR RESULT value_type_list RPAR func_result_body {
- $$ = $5;
- PrependAndDelete($$->decl.sig.result_types, $3);
- }
-;
-
-func_body :
- func_body1 {
- $$ = $1;
- ReverseBindings(&$$->local_types, &$$->local_bindings);
- }
-;
-
-func_body1 :
- instr_list {
- $$ = new Func();
- $$->exprs = MoveAndDelete($1);
- }
- | LPAR LOCAL value_type_list RPAR func_body1 {
- $$ = $5;
- PrependAndDelete($$->local_types, $3);
- }
- | LPAR LOCAL bind_var VALUE_TYPE RPAR func_body1 {
- $$ = $6;
- $$->local_bindings.emplace(MoveAndDelete($3),
- Binding(@3, $$->local_types.size()));
- $$->local_types.insert($$->local_types.begin(), $4);
- }
-;
-
-/* Tables & Memories */
-
-offset :
- LPAR OFFSET const_expr RPAR {
- $$ = $3;
- }
- | expr
-;
-
-elem :
- LPAR ELEM var offset var_list RPAR {
- auto elem_segment = new ElemSegment();
- elem_segment->table_var = MoveAndDelete($3);
- elem_segment->offset = MoveAndDelete($4);
- elem_segment->vars = MoveAndDelete($5);
- $$ = new ElemSegmentModuleField(elem_segment, @2);
- }
- | LPAR ELEM offset var_list RPAR {
- auto elem_segment = new ElemSegment();
- elem_segment->table_var = Var(0, @2);
- elem_segment->offset = MoveAndDelete($3);
- elem_segment->vars = MoveAndDelete($4);
- $$ = new ElemSegmentModuleField(elem_segment, @2);
- }
-;
-
-table :
- LPAR TABLE bind_var_opt table_fields RPAR {
- $$ = $4;
- ModuleField* main_field = &$$->front();
- main_field->loc = @2;
- if (auto table_field = dyn_cast<TableModuleField>(main_field)) {
- table_field->table->name = MoveAndDelete($3);
- } else {
- cast<ImportModuleField>(main_field)->import->table->name =
- MoveAndDelete($3);
- }
- }
-;
-
-table_fields :
- table_sig {
- $$ = new ModuleFieldList(new TableModuleField($1));
- }
- | inline_import table_sig {
- auto field = new ImportModuleField($1);
- field->import->kind = ExternalKind::Table;
- field->import->table = $2;
- $$ = new ModuleFieldList(field);
- }
- | inline_export table_fields {
- auto field = new ExportModuleField($1, @1);
- field->export_->kind = ExternalKind::Table;
- $$ = $2;
- $$->push_back(field);
- }
- | elem_type LPAR ELEM var_list RPAR {
- auto table = new Table();
- table->elem_limits.initial = $4->size();
- table->elem_limits.max = $4->size();
- table->elem_limits.has_max = true;
-
- auto elem_segment = new ElemSegment();
- elem_segment->table_var = Var(kInvalidIndex);
- elem_segment->offset.push_back(new ConstExpr(Const(Const::I32(), 0)));
- elem_segment->offset.back().loc = @3;
- elem_segment->vars = MoveAndDelete($4);
-
- $$ = new ModuleFieldList();
- $$->push_back(new TableModuleField(table));
- $$->push_back(new ElemSegmentModuleField(elem_segment, @3));
- }
-;
-
-data :
- LPAR DATA var offset text_list_opt RPAR {
- auto data_segment = new DataSegment();
- data_segment->memory_var = MoveAndDelete($3);
- data_segment->offset = MoveAndDelete($4);
- RemoveEscapes(MoveAndDelete($5), std::back_inserter(data_segment->data));
- $$ = new DataSegmentModuleField(data_segment, @2);
- }
- | LPAR DATA offset text_list_opt RPAR {
- auto data_segment = new DataSegment();
- data_segment->memory_var = Var(0, @2);
- data_segment->offset = MoveAndDelete($3);
- RemoveEscapes(MoveAndDelete($4), std::back_inserter(data_segment->data));
- $$ = new DataSegmentModuleField(data_segment, @2);
- }
-;
-
-memory :
- LPAR MEMORY bind_var_opt memory_fields RPAR {
- $$ = $4;
- ModuleField* main_field = &$$->front();
- main_field->loc = @2;
- if (auto memory_field = dyn_cast<MemoryModuleField>(main_field)) {
- memory_field->memory->name = MoveAndDelete($3);
- } else {
- cast<ImportModuleField>(main_field)->import->memory->name =
- MoveAndDelete($3);
- }
- }
-;
-
-memory_fields :
- memory_sig {
- $$ = new ModuleFieldList(new MemoryModuleField($1));
- }
- | inline_import memory_sig {
- auto field = new ImportModuleField($1);
- field->import->kind = ExternalKind::Memory;
- field->import->memory = $2;
- $$ = new ModuleFieldList(field);
- }
- | inline_export memory_fields {
- auto field = new ExportModuleField($1, @1);
- field->export_->kind = ExternalKind::Memory;
- $$ = $2;
- $$->push_back(field);
- }
- | LPAR DATA text_list_opt RPAR {
- auto data_segment = new DataSegment();
- data_segment->memory_var = Var(kInvalidIndex);
- data_segment->offset.push_back(new ConstExpr(Const(Const::I32(), 0)));
- data_segment->offset.back().loc = @2;
- RemoveEscapes(MoveAndDelete($3), std::back_inserter(data_segment->data));
-
- uint32_t byte_size = WABT_ALIGN_UP_TO_PAGE(data_segment->data.size());
- uint32_t page_size = WABT_BYTES_TO_PAGES(byte_size);
-
- auto memory = new Memory();
- memory->page_limits.initial = page_size;
- memory->page_limits.max = page_size;
- memory->page_limits.has_max = true;
-
- $$ = new ModuleFieldList();
- $$->push_back(new MemoryModuleField(memory));
- $$->push_back(new DataSegmentModuleField(data_segment, @2));
- }
-;
-
-global :
- LPAR GLOBAL bind_var_opt global_fields RPAR {
- $$ = $4;
- ModuleField* main_field = &$$->front();
- main_field->loc = @2;
- if (auto global_field = dyn_cast<GlobalModuleField>(main_field)) {
- global_field->global->name = MoveAndDelete($3);
- } else {
- cast<ImportModuleField>(main_field)->import->global->name =
- MoveAndDelete($3);
- }
- }
-;
-
-global_fields :
- global_type const_expr {
- auto field = new GlobalModuleField($1);
- field->global->init_expr = MoveAndDelete($2);
- $$ = new ModuleFieldList(field);
- }
- | inline_import global_type {
- auto field = new ImportModuleField($1);
- field->import->kind = ExternalKind::Global;
- field->import->global = $2;
- $$ = new ModuleFieldList(field);
- }
- | inline_export global_fields {
- auto field = new ExportModuleField($1, @1);
- field->export_->kind = ExternalKind::Global;
- $$ = $2;
- $$->push_back(field);
- }
-;
-
-/* Imports & Exports */
-
-import_desc :
- LPAR FUNC bind_var_opt type_use RPAR {
- $$ = new Import();
- $$->kind = ExternalKind::Func;
- $$->func = new Func();
- $$->func->name = MoveAndDelete($3);
- $$->func->decl.has_func_type = true;
- $$->func->decl.type_var = MoveAndDelete($4);
- }
- | LPAR FUNC bind_var_opt func_sig RPAR {
- $$ = new Import();
- $$->kind = ExternalKind::Func;
- $$->func = new Func();
- $$->func->name = MoveAndDelete($3);
- $$->func->decl.sig = MoveAndDelete($4);
- }
- | LPAR TABLE bind_var_opt table_sig RPAR {
- $$ = new Import();
- $$->kind = ExternalKind::Table;
- $$->table = $4;
- $$->table->name = MoveAndDelete($3);
- }
- | LPAR MEMORY bind_var_opt memory_sig RPAR {
- $$ = new Import();
- $$->kind = ExternalKind::Memory;
- $$->memory = $4;
- $$->memory->name = MoveAndDelete($3);
- }
- | LPAR GLOBAL bind_var_opt global_type RPAR {
- $$ = new Import();
- $$->kind = ExternalKind::Global;
- $$->global = $4;
- $$->global->name = MoveAndDelete($3);
- }
- | exception {
- $$ = new Import();
- $$->kind = ExternalKind::Except;
- $$->except = $1;
- }
-;
-
-import :
- LPAR IMPORT quoted_text quoted_text import_desc RPAR {
- auto field = new ImportModuleField($5, @2);
- field->import->module_name = MoveAndDelete($3);
- field->import->field_name = MoveAndDelete($4);
- $$ = field;
- }
-;
-
-inline_import :
- LPAR IMPORT quoted_text quoted_text RPAR {
- $$ = new Import();
- $$->module_name = MoveAndDelete($3);
- $$->field_name = MoveAndDelete($4);
- }
-;
-
-export_desc :
- LPAR FUNC var RPAR {
- $$ = new Export();
- $$->kind = ExternalKind::Func;
- $$->var = MoveAndDelete($3);
- }
- | LPAR TABLE var RPAR {
- $$ = new Export();
- $$->kind = ExternalKind::Table;
- $$->var = MoveAndDelete($3);
- }
- | LPAR MEMORY var RPAR {
- $$ = new Export();
- $$->kind = ExternalKind::Memory;
- $$->var = MoveAndDelete($3);
- }
- | LPAR GLOBAL var RPAR {
- $$ = new Export();
- $$->kind = ExternalKind::Global;
- $$->var = MoveAndDelete($3);
- }
- | LPAR EXCEPT var RPAR {
- $$ = new Export();
- $$->kind = ExternalKind::Except;
- $$->var = MoveAndDelete($3);
- }
-;
-export :
- LPAR EXPORT quoted_text export_desc RPAR {
- auto field = new ExportModuleField($4, @2);
- field->export_->name = MoveAndDelete($3);
- $$ = field;
- }
-;
-
-inline_export :
- LPAR EXPORT quoted_text RPAR {
- $$ = new Export();
- $$->name = MoveAndDelete($3);
- }
-;
-
-
-/* Modules */
-
-type_def :
- LPAR TYPE func_type RPAR {
- auto func_type = new FuncType();
- func_type->sig = MoveAndDelete($3);
- $$ = new FuncTypeModuleField(func_type, @2);
- }
- | LPAR TYPE bind_var func_type RPAR {
- auto func_type = new FuncType();
- func_type->name = MoveAndDelete($3);
- func_type->sig = MoveAndDelete($4);
- $$ = new FuncTypeModuleField(func_type, @2);
- }
-;
-
-start :
- LPAR START var RPAR {
- $$ = new StartModuleField(MoveAndDelete($3), @2);
- }
-;
-
-module_field :
- type_def { $$ = new ModuleFieldList($1); }
- | global
- | table
- | memory
- | func
- | elem { $$ = new ModuleFieldList($1); }
- | data { $$ = new ModuleFieldList($1); }
- | start { $$ = new ModuleFieldList($1); }
- | import { $$ = new ModuleFieldList($1); }
- | export { $$ = new ModuleFieldList($1); }
- | exception_field { $$ = new ModuleFieldList($1); }
-;
-
-module_fields_opt :
- /* empty */ { $$ = new Module(); }
- | module_fields
-;
-
-module_fields :
- module_field {
- $$ = new Module();
- CheckImportOrdering(&@1, lexer, parser, $$, *$1);
- AppendModuleFields($$, MoveAndDelete($1));
- }
- | module_fields module_field {
- $$ = $1;
- CheckImportOrdering(&@2, lexer, parser, $$, *$2);
- AppendModuleFields($$, MoveAndDelete($2));
- }
-;
-
-module :
- script_module {
- if ($1->type == ScriptModule::Type::Text) {
- $$ = $1->text;
- $1->text = nullptr;
- } else {
- assert($1->type == ScriptModule::Type::Binary);
- $$ = new Module();
- ReadBinaryOptions options;
- BinaryErrorHandlerModule error_handler(&$1->binary.loc, lexer, parser);
- const char* filename = "<text>";
- ReadBinaryIr(filename, $1->binary.data.data(), $1->binary.data.size(),
- &options, &error_handler, $$);
- $$->name = $1->binary.name;
- $$->loc = $1->binary.loc;
- }
- delete $1;
- }
-;
-
-inline_module :
- module_fields {
- $$ = $1;
- ResolveFuncTypes($$);
- }
-;
-
-
-/* Scripts */
-
-script_var_opt :
- /* empty */ {
- $$ = new Var(kInvalidIndex);
- }
- | VAR {
- $$ = new Var($1.to_string_view(), @1);
- }
-;
-
-script_module :
- LPAR MODULE bind_var_opt module_fields_opt RPAR {
- $$ = new ScriptModule(ScriptModule::Type::Text);
- auto module = $4;
- $$->text = module;
- $$->text->name = MoveAndDelete($3);
- $$->text->loc = @2;
- ResolveFuncTypes(module);
- }
- | LPAR MODULE bind_var_opt BIN text_list RPAR {
- $$ = new ScriptModule(ScriptModule::Type::Binary);
- $$->binary.name = MoveAndDelete($3);
- $$->binary.loc = @2;
- RemoveEscapes(MoveAndDelete($5), std::back_inserter($$->binary.data));
- }
- | LPAR MODULE bind_var_opt QUOTE text_list RPAR {
- $$ = new ScriptModule(ScriptModule::Type::Quoted);
- $$->quoted.name = MoveAndDelete($3);
- $$->quoted.loc = @2;
- RemoveEscapes(MoveAndDelete($5), std::back_inserter($$->quoted.data));
- }
-;
-
-action :
- LPAR INVOKE script_var_opt quoted_text const_list RPAR {
- $$ = new Action();
- $$->loc = @2;
- $$->module_var = MoveAndDelete($3);
- $$->type = ActionType::Invoke;
- $$->name = MoveAndDelete($4);
- $$->invoke = new ActionInvoke();
- $$->invoke->args = MoveAndDelete($5);
- }
- | LPAR GET script_var_opt quoted_text RPAR {
- $$ = new Action();
- $$->loc = @2;
- $$->module_var = MoveAndDelete($3);
- $$->type = ActionType::Get;
- $$->name = MoveAndDelete($4);
- }
-;
-
-assertion :
- LPAR ASSERT_MALFORMED script_module quoted_text RPAR {
- $$ = new AssertMalformedCommand($3, MoveAndDelete($4));
- }
- | LPAR ASSERT_INVALID script_module quoted_text RPAR {
- $$ = new AssertInvalidCommand($3, MoveAndDelete($4));
- }
- | LPAR ASSERT_UNLINKABLE script_module quoted_text RPAR {
- $$ = new AssertUnlinkableCommand($3, MoveAndDelete($4));
- }
- | LPAR ASSERT_TRAP script_module quoted_text RPAR {
- $$ = new AssertUninstantiableCommand($3, MoveAndDelete($4));
- }
- | LPAR ASSERT_RETURN action const_list RPAR {
- $$ = new AssertReturnCommand($3, $4);
- }
- | LPAR ASSERT_RETURN_CANONICAL_NAN action RPAR {
- $$ = new AssertReturnCanonicalNanCommand($3);
- }
- | LPAR ASSERT_RETURN_ARITHMETIC_NAN action RPAR {
- $$ = new AssertReturnArithmeticNanCommand($3);
- }
- | LPAR ASSERT_TRAP action quoted_text RPAR {
- $$ = new AssertTrapCommand($3, MoveAndDelete($4));
- }
- | LPAR ASSERT_EXHAUSTION action quoted_text RPAR {
- $$ = new AssertExhaustionCommand($3, MoveAndDelete($4));
- }
-;
-
-cmd :
- action {
- $$ = new ActionCommand($1);
- }
- | assertion
- | module {
- $$ = new ModuleCommand($1);
- }
- | LPAR REGISTER quoted_text script_var_opt RPAR {
- auto* command = new RegisterCommand(MoveAndDelete($3), MoveAndDelete($4));
- command->var.loc = @4;
- $$ = command;
- }
-;
-cmd_list :
- cmd {
- $$ = new CommandPtrVector();
- $$->emplace_back($1);
- }
- | cmd_list cmd {
- $$ = $1;
- $$->emplace_back($2);
- }
-;
-
-const :
- LPAR CONST literal RPAR {
- $$.loc = @2;
- auto literal = MoveAndDelete($3);
- if (Failed(ParseConst($2, literal, &$$))) {
- WastParserError(&@3, lexer, parser, "invalid literal \"%s\"",
- literal.text.c_str());
- }
- }
-;
-const_list :
- /* empty */ { $$ = new ConstVector(); }
- | const_list const {
- $$ = $1;
- $$->push_back($2);
- }
-;
-
-script :
- /* empty */ {
- $$ = new Script();
- }
- | cmd_list {
- $$ = new Script();
- $$->commands = MoveAndDelete($1);
-
- int last_module_index = -1;
- for (size_t i = 0; i < $$->commands.size(); ++i) {
- Command* command = $$->commands[i].get();
- Var* module_var = nullptr;
- switch (command->type) {
- case CommandType::Module: {
- last_module_index = i;
-
- // Wire up module name bindings.
- Module* module = cast<ModuleCommand>(command)->module;
- if (module->name.empty())
- continue;
-
- $$->module_bindings.emplace(module->name, Binding(module->loc, i));
- break;
- }
-
- case CommandType::AssertReturn:
- module_var =
- &cast<AssertReturnCommand>(command)->action->module_var;
- goto has_module_var;
- case CommandType::AssertReturnCanonicalNan:
- module_var = &cast<AssertReturnCanonicalNanCommand>(command)
- ->action->module_var;
- goto has_module_var;
- case CommandType::AssertReturnArithmeticNan:
- module_var = &cast<AssertReturnArithmeticNanCommand>(command)
- ->action->module_var;
- goto has_module_var;
- case CommandType::AssertTrap:
- module_var = &cast<AssertTrapCommand>(command)->action->module_var;
- goto has_module_var;
- case CommandType::AssertExhaustion:
- module_var =
- &cast<AssertExhaustionCommand>(command)->action->module_var;
- goto has_module_var;
- case CommandType::Action:
- module_var = &cast<ActionCommand>(command)->action->module_var;
- goto has_module_var;
- case CommandType::Register:
- module_var = &cast<RegisterCommand>(command)->var;
- goto has_module_var;
-
- has_module_var: {
- // Resolve actions with an invalid index to use the preceding
- // module.
- if (module_var->is_index() &&
- module_var->index() == kInvalidIndex) {
- module_var->set_index(last_module_index);
- }
- break;
- }
-
- default:
- break;
- }
- }
- }
- | inline_module {
- $$ = new Script();
- $$->commands.emplace_back(new ModuleCommand($1));
- }
-;
-
-/* bison destroys the start symbol even on a successful parse. We want to keep
- script from being destroyed, so create a dummy start symbol. */
-script_start :
- script { parser->script = $1; }
-;
-
-%%
-
-Result ParseConst(Type type, const Literal& literal, Const* out) {
- string_view sv = literal.text;
- const char* s = sv.begin();
- const char* end = sv.end();
-
- out->type = type;
- switch (type) {
- case Type::I32:
- return ParseInt32(s, end, &out->u32, ParseIntType::SignedAndUnsigned);
- case Type::I64:
- return ParseInt64(s, end, &out->u64, ParseIntType::SignedAndUnsigned);
- case Type::F32:
- return ParseFloat(literal.type, s, end, &out->f32_bits);
- case Type::F64:
- return ParseDouble(literal.type, s, end, &out->f64_bits);
- default:
- assert(0);
- break;
- }
- return Result::Error;
-}
-
-void ReverseBindings(TypeVector* types, BindingHash* bindings) {
- for (auto& pair : *bindings) {
- pair.second.index = types->size() - pair.second.index - 1;
- }
-}
-
-bool IsEmptySignature(const FuncSignature* sig) {
- return sig->result_types.empty() && sig->param_types.empty();
-}
-
-void CheckImportOrdering(Location* loc, WastLexer* lexer, WastParser* parser,
- Module* module, const ModuleFieldList& fields) {
- for (const ModuleField& field: fields) {
- if (field.type == ModuleFieldType::Import) {
- if (module->funcs.size() != module->num_func_imports ||
- module->tables.size() != module->num_table_imports ||
- module->memories.size() != module->num_memory_imports ||
- module->globals.size() != module->num_global_imports ||
- module->excepts.size() != module->num_except_imports) {
- WastParserError(loc, lexer, parser,
- "imports must occur before all non-import definitions");
- }
- }
- }
-}
-
-void AppendModuleFields(Module* module, ModuleFieldList&& fields) {
- ModuleField* main_field = &fields.front();
- Index main_index = kInvalidIndex;
-
- for (ModuleField& field : fields) {
- std::string* name = nullptr;
- BindingHash* bindings = nullptr;
- Index index = kInvalidIndex;
-
- switch (field.type) {
- case ModuleFieldType::Func: {
- Func* func = cast<FuncModuleField>(&field)->func;
- name = &func->name;
- bindings = &module->func_bindings;
- index = module->funcs.size();
- module->funcs.push_back(func);
- break;
- }
-
- case ModuleFieldType::Global: {
- Global* global = cast<GlobalModuleField>(&field)->global;
- name = &global->name;
- bindings = &module->global_bindings;
- index = module->globals.size();
- module->globals.push_back(global);
- break;
- }
-
- case ModuleFieldType::Import: {
- Import* import = cast<ImportModuleField>(&field)->import;
-
- switch (import->kind) {
- case ExternalKind::Func:
- name = &import->func->name;
- bindings = &module->func_bindings;
- index = module->funcs.size();
- module->funcs.push_back(import->func);
- ++module->num_func_imports;
- break;
- case ExternalKind::Table:
- name = &import->table->name;
- bindings = &module->table_bindings;
- index = module->tables.size();
- module->tables.push_back(import->table);
- ++module->num_table_imports;
- break;
- case ExternalKind::Memory:
- name = &import->memory->name;
- bindings = &module->memory_bindings;
- index = module->memories.size();
- module->memories.push_back(import->memory);
- ++module->num_memory_imports;
- break;
- case ExternalKind::Global:
- name = &import->global->name;
- bindings = &module->global_bindings;
- index = module->globals.size();
- module->globals.push_back(import->global);
- ++module->num_global_imports;
- break;
- case ExternalKind::Except:
- name = &import->except->name;
- bindings = &module->except_bindings;
- index = module->excepts.size();
- module->excepts.push_back(import->except);
- ++module->num_except_imports;
- break;
- }
- module->imports.push_back(import);
- break;
- }
-
- case ModuleFieldType::Export: {
- Export* export_ = cast<ExportModuleField>(&field)->export_;
- if (&field != main_field) {
- // If this is not the main field, it must be an inline export.
- export_->var.set_index(main_index);
- }
- name = &export_->name;
- bindings = &module->export_bindings;
- index = module->exports.size();
- module->exports.push_back(export_);
- break;
- }
-
- case ModuleFieldType::FuncType: {
- FuncType* func_type = cast<FuncTypeModuleField>(&field)->func_type;
- name = &func_type->name;
- bindings = &module->func_type_bindings;
- index = module->func_types.size();
- module->func_types.push_back(func_type);
- break;
- }
-
- case ModuleFieldType::Table: {
- Table* table = cast<TableModuleField>(&field)->table;
- name = &table->name;
- bindings = &module->table_bindings;
- index = module->tables.size();
- module->tables.push_back(table);
- break;
- }
-
- case ModuleFieldType::ElemSegment: {
- ElemSegment* elem_segment =
- cast<ElemSegmentModuleField>(&field)->elem_segment;
- if (&field != main_field) {
- // If this is not the main field, it must be an inline elem segment.
- elem_segment->table_var.set_index(main_index);
- }
- module->elem_segments.push_back(elem_segment);
- break;
- }
-
- case ModuleFieldType::Memory: {
- Memory* memory = cast<MemoryModuleField>(&field)->memory;
- name = &memory->name;
- bindings = &module->memory_bindings;
- index = module->memories.size();
- module->memories.push_back(memory);
- break;
- }
-
- case ModuleFieldType::DataSegment: {
- DataSegment* data_segment =
- cast<DataSegmentModuleField>(&field)->data_segment;
- if (&field != main_field) {
- // If this is not the main field, it must be an inline data segment.
- data_segment->memory_var.set_index(main_index);
- }
- module->data_segments.push_back(data_segment);
- break;
- }
-
- case ModuleFieldType::Except: {
- Exception* except = cast<ExceptionModuleField>(&field)->except;
- name = &except->name;
- bindings = &module->except_bindings;
- index = module->excepts.size();
- module->excepts.push_back(except);
- break;
- }
-
- case ModuleFieldType::Start:
- module->start = &cast<StartModuleField>(&field)->start;
- break;
- }
-
- if (&field == main_field)
- main_index = index;
-
- if (name && bindings) {
- // Exported names are allowed to be empty; other names aren't.
- if (bindings == &module->export_bindings || !name->empty()) {
- bindings->emplace(*name, Binding(field.loc, index));
- }
- }
- }
-
- module->fields.splice(module->fields.end(), fields);
-}
-
-void ResolveFuncTypes(Module* module) {
- for (ModuleField& field : module->fields) {
- Func* func = nullptr;
- if (field.type == ModuleFieldType::Func) {
- func = dyn_cast<FuncModuleField>(&field)->func;
- } else if (field.type == ModuleFieldType::Import) {
- Import* import = dyn_cast<ImportModuleField>(&field)->import;
- if (import->kind == ExternalKind::Func) {
- func = import->func;
- } else {
- continue;
- }
- } else {
- continue;
- }
-
- // Resolve func type variables where the signature was not specified
- // explicitly, e.g.: (func (type 1) ...)
- if (func->decl.has_func_type && IsEmptySignature(&func->decl.sig)) {
- FuncType* func_type = module->GetFuncType(func->decl.type_var);
- if (func_type) {
- func->decl.sig = func_type->sig;
- }
- }
-
- // Resolve implicitly defined function types, e.g.: (func (param i32) ...)
- if (!func->decl.has_func_type) {
- Index func_type_index = module->GetFuncTypeIndex(func->decl.sig);
- if (func_type_index == kInvalidIndex) {
- auto func_type = new FuncType();
- func_type->sig = func->decl.sig;
- ModuleFieldList fields;
- fields.push_back(new FuncTypeModuleField(func_type, field.loc));
- AppendModuleFields(module, std::move(fields));
- }
- }
- }
-}
-
-Result ParseWast(WastLexer * lexer, Script * *out_script,
- ErrorHandler * error_handler, WastParseOptions * options) {
- WastParser parser;
- ZeroMemory(parser);
- static WastParseOptions default_options;
- if (options == nullptr)
- options = &default_options;
- parser.options = options;
- parser.error_handler = error_handler;
- wabt_wast_parser_debug = int(options->debug_parsing);
- int result = wabt_wast_parser_parse(lexer, &parser);
- delete [] parser.yyssa;
- delete [] parser.yyvsa;
- delete [] parser.yylsa;
- if (out_script) {
- *out_script = parser.script;
- } else {
- delete parser.script;
- }
- return result == 0 && parser.errors == 0 ? Result::Ok : Result::Error;
-}
-
-BinaryErrorHandlerModule::BinaryErrorHandlerModule(
- Location* loc, WastLexer* lexer, WastParser* parser)
- : ErrorHandler(Location::Type::Binary),
- loc_(loc),
- lexer_(lexer),
- parser_(parser) {}
-
-bool BinaryErrorHandlerModule::OnError(
- const Location& binary_loc, const std::string& error,
- const std::string& source_line, size_t source_line_column_offset) {
- if (binary_loc.offset == kInvalidOffset) {
- WastParserError(loc_, lexer_, parser_, "error in binary module: %s",
- error.c_str());
- } else {
- WastParserError(loc_, lexer_, parser_,
- "error in binary module: @0x%08" PRIzx ": %s",
- binary_loc.offset, error.c_str());
- }
- return true;
-}
-
-} // namespace wabt