summaryrefslogtreecommitdiff
path: root/include/wabt/wast-parser.h
diff options
context:
space:
mode:
authorKeith Winstein <keithw@cs.stanford.edu>2023-09-18 22:06:57 -0700
committerGitHub <noreply@github.com>2023-09-18 22:06:57 -0700
commit3b108c1d1dc2d633b5d5842321e9c5b2bdcea413 (patch)
tree469c96bb6d1a12e486e6cf30cc410e5c99f8f18c /include/wabt/wast-parser.h
parentb22be5a08611c53e8a893bbab049e6f18da6c55a (diff)
downloadwabt-3b108c1d1dc2d633b5d5842321e9c5b2bdcea413.tar.gz
wabt-3b108c1d1dc2d633b5d5842321e9c5b2bdcea413.tar.bz2
wabt-3b108c1d1dc2d633b5d5842321e9c5b2bdcea413.zip
WastParser: replace CircularArray with internal TokenQueue (NFC) (#2300)
Diffstat (limited to 'include/wabt/wast-parser.h')
-rw-r--r--include/wabt/wast-parser.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/include/wabt/wast-parser.h b/include/wabt/wast-parser.h
index 9464147d..36447c58 100644
--- a/include/wabt/wast-parser.h
+++ b/include/wabt/wast-parser.h
@@ -19,9 +19,9 @@
#include <array>
#include <memory>
+#include <optional>
#include <unordered_map>
-#include "wabt/circular-array.h"
#include "wabt/error.h"
#include "wabt/feature.h"
#include "wabt/intrusive-list.h"
@@ -262,7 +262,21 @@ class WastParser {
Errors* errors_;
WastParseOptions* options_;
- CircularArray<Token, 2> tokens_;
+ // two-element queue of upcoming tokens
+ class TokenQueue {
+ std::array<std::optional<Token>, 2> tokens{};
+ bool i{};
+
+ public:
+ void push_back(Token t);
+ void pop_front();
+ const Token& at(size_t n) const;
+ const Token& front() const;
+ bool empty() const;
+ size_t size() const;
+ };
+
+ TokenQueue tokens_{};
};
Result ParseWatModule(WastLexer* lexer,