diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2022-06-10 12:30:09 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-10 12:30:09 -0700 |
commit | 093bf06e1115e84c4300eca91197dc31336ee3e5 (patch) | |
tree | 9016245be8af54c8e47bdb3c0aaa0ed6f263b3c0 /test | |
parent | 9fbfe0f200f716a6c9a045c6a3f2606b99af8dea (diff) | |
download | binaryen-093bf06e1115e84c4300eca91197dc31336ee3e5.tar.gz binaryen-093bf06e1115e84c4300eca91197dc31336ee3e5.tar.bz2 binaryen-093bf06e1115e84c4300eca91197dc31336ee3e5.zip |
[Parser] Begin parsing modules (#4716)
Implement the basic infrastructure for the full WAT parser with just enough
detail to parse basic modules that contain only imported globals. Parsing
functions correspond to elements of the grammar in the text specification and
are templatized over context types that correspond to each phase of parsing.
Errors are explicitly propagated via `Result<T>` and `MaybeResult<T>` types.
Follow-on PRs will implement additional phases of parsing and parsing for new
elements in the grammar.
Diffstat (limited to 'test')
-rw-r--r-- | test/gtest/wat-lexer.cpp | 2 | ||||
-rw-r--r-- | test/lit/help/wasm-opt.test | 3 | ||||
-rw-r--r-- | test/lit/wat-kitchen-sink.wast | 18 |
3 files changed, 22 insertions, 1 deletions
diff --git a/test/gtest/wat-lexer.cpp b/test/gtest/wat-lexer.cpp index a1c60a706..0f83127c8 100644 --- a/test/gtest/wat-lexer.cpp +++ b/test/gtest/wat-lexer.cpp @@ -1361,7 +1361,7 @@ TEST(LexerTest, LexIdent) { Token expected{"$09azAZ!#$%&'*+-./:<=>?@\\^_`|~"sv, IdTok{}}; EXPECT_EQ(*lexer, expected); EXPECT_TRUE(lexer->getID()); - EXPECT_EQ(*lexer->getID(), "$09azAZ!#$%&'*+-./:<=>?@\\^_`|~"sv); + EXPECT_EQ(*lexer->getID(), "09azAZ!#$%&'*+-./:<=>?@\\^_`|~"sv); } { Lexer lexer("$[]{}"sv); diff --git a/test/lit/help/wasm-opt.test b/test/lit/help/wasm-opt.test index bb111d92e..66ac66f91 100644 --- a/test/lit/help/wasm-opt.test +++ b/test/lit/help/wasm-opt.test @@ -76,6 +76,9 @@ ;; CHECK-NEXT: --output-source-map-url,-osu Emit specified string as source ;; CHECK-NEXT: map URL ;; CHECK-NEXT: +;; CHECK-NEXT: --new-wat-parser Use the experimental new WAT +;; CHECK-NEXT: parser +;; CHECK-NEXT: ;; CHECK-NEXT: ;; CHECK-NEXT: Optimization passes: ;; CHECK-NEXT: -------------------- diff --git a/test/lit/wat-kitchen-sink.wast b/test/lit/wat-kitchen-sink.wast new file mode 100644 index 000000000..90d5d5b41 --- /dev/null +++ b/test/lit/wat-kitchen-sink.wast @@ -0,0 +1,18 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. + +;; RUN: wasm-opt --new-wat-parser -all %s -S -o - | filecheck %s + +(module $parse + + ;; globals + (global $g1 (export "g1") (export "g1.1") (import "mod" "g1") i32) + (global $g2 (import "mod" "g2") (mut i64)) + +) +;; CHECK: (import "mod" "g1" (global $g1 i32)) + +;; CHECK: (import "mod" "g2" (global $g2 (mut i64))) + +;; CHECK: (export "g1" (global $g1)) + +;; CHECK: (export "g1.1" (global $g1)) |