diff options
author | Ben Smith <binjimin@gmail.com> | 2017-06-07 12:45:08 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-07 12:45:08 -0700 |
commit | d999df990e41634e45c199ca1e391b06f4734ebe (patch) | |
tree | 99335c60f7262b94e76204f35748ced7b62f5b85 /src/wast-parser-lexer-shared.h | |
parent | 044a198e827521f54b5260486ad3c89350b79450 (diff) | |
download | wabt-d999df990e41634e45c199ca1e391b06f4734ebe.tar.gz wabt-d999df990e41634e45c199ca1e391b06f4734ebe.tar.bz2 wabt-d999df990e41634e45c199ca1e391b06f4734ebe.zip |
Update testsuite; various lexing/parsing fixes (#482)
* Update testsuite; various lexing/parsing fixes
Lexer changes:
* Switch re2c parser to UTF-8 parser. This can almost be done "for
free" with a flag, but required a bit of work to allow us to catch
malformed UTF-8 as well.
* Change the re2c fill value to 0xff, since it's never a valid UTF-8 byte.
* Allow for more reserved tokens (basically any ascii aside from
parentheses, double-quote, and semi-colon)
* Remove "infinity" from lexer, only "inf" is allowed now.
* Change definition of EOF token, it was implemented incorrectly. The
correct way to handle it is to only return it from FILL when there is no
more data to fill.
* \r is a valid escape.
Parser changes:
* Changes to match the spec parser:
- block signatures use (result <type>) syntax
- func/global/table/memory can have multiple inline exports
- inline imports are handled in func definition instead of import
definition
- allow for inline modules (i.e. no "(module ...)" s-expr required)
* Remove FuncField. This was previously used for parsing
params/results/locals, but it's less code to just parse
right-recursive (i.e. backward) and insert everything at the front.
This requires reversing the indexes in the BindingHash too.
* Remove the nasty macros `APPEND_FIELD_TO_LIST`,
`APPEND_ITEM_TO_VECTOR`, `APPEND_INLINE_EXPORT`, and
`CHECK_IMPORT_ORDERING`. This behavior is all handled by
`append_module_fields` now.
* All inline imports/exports are handled by returning additional
ModuleFields in a list. This removes the need for `OptionalExport`,
`ExportedFunc`, `ExportedGlobal`, `ExportedTable`, and
`ExportedMemory`.
* Use "_opt" suffix instead of "non_empty_" prefix, e.g.:
- text_list => text_list_opt, non_empty_text_list => text_list
* The locations changed for some symbols, typically the use the name
following the LPAR now, e.g. (import
^^^^^^
* Add PPA for re2c 0.16
* add -y to skip confirmation on travis
Diffstat (limited to 'src/wast-parser-lexer-shared.h')
-rw-r--r-- | src/wast-parser-lexer-shared.h | 75 |
1 files changed, 6 insertions, 69 deletions
diff --git a/src/wast-parser-lexer-shared.h b/src/wast-parser-lexer-shared.h index e8e0acbb..4b36a917 100644 --- a/src/wast-parser-lexer-shared.h +++ b/src/wast-parser-lexer-shared.h @@ -30,8 +30,6 @@ #define YYSTYPE WABT_WAST_PARSER_STYPE #define YYLTYPE WABT_WAST_PARSER_LTYPE -#define WABT_INVALID_LINE_OFFSET (static_cast<size_t>(~0)) - namespace wabt { struct ExprList { @@ -50,66 +48,9 @@ struct TextList { TextListNode* last; }; -struct OptionalExport { - std::unique_ptr<Export> export_; - bool has_export; -}; - -struct ExportedFunc { - std::unique_ptr<Func> func; - OptionalExport export_; -}; - -struct ExportedGlobal { - std::unique_ptr<Global> global; - OptionalExport export_; -}; - -struct ExportedTable { - std::unique_ptr<Table> table; - std::unique_ptr<ElemSegment> elem_segment; - OptionalExport export_; - bool has_elem_segment; -}; - -struct ExportedMemory { - std::unique_ptr<Memory> memory; - std::unique_ptr<DataSegment> data_segment; - OptionalExport export_; - bool has_data_segment; -}; - -enum class FuncFieldType { - Exprs, - ParamTypes, - BoundParam, - ResultTypes, - LocalTypes, - BoundLocal, -}; - -struct BoundType { - WABT_DISALLOW_COPY_AND_ASSIGN(BoundType); - BoundType(); - ~BoundType(); - - Location loc; - StringSlice name; - Type type; -}; - -struct FuncField { - WABT_DISALLOW_COPY_AND_ASSIGN(FuncField); - FuncField(); - ~FuncField(); - - FuncFieldType type; - union { - Expr* first_expr; /* WABT_FUNC_FIELD_TYPE_EXPRS */ - TypeVector* types; /* WABT_FUNC_FIELD_TYPE_*_TYPES */ - BoundType bound_type; /* WABT_FUNC_FIELD_TYPE_BOUND_{LOCAL, PARAM} */ - }; - struct FuncField* next; +struct ModuleFieldList { + ModuleField* first; + ModuleField* last; }; union Token { @@ -131,22 +72,18 @@ union Token { DataSegment* data_segment; ElemSegment* elem_segment; Export* export_; - ExportedFunc* exported_func; - ExportedGlobal* exported_global; - ExportedMemory* exported_memory; - ExportedTable* exported_table; Expr* expr; ExprList expr_list; - FuncField* func_fields; Func* func; FuncSignature* func_sig; FuncType* func_type; Global* global; Import* import; Limits limits; - OptionalExport* optional_export; Memory* memory; Module* module; + ModuleField* module_field; + ModuleFieldList module_fields; RawModule* raw_module; Script* script; Table* table; @@ -182,8 +119,8 @@ void wast_format_error(SourceErrorHandler*, WastLexer*, const char* format, va_list); -void destroy_func_fields(FuncField*); void destroy_text_list(TextList*); +void destroy_module_field_list(ModuleFieldList*); } // namespace wabt |