diff options
author | Keith Winstein <keithw@cs.stanford.edu> | 2023-09-18 22:06:57 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-18 22:06:57 -0700 |
commit | 3b108c1d1dc2d633b5d5842321e9c5b2bdcea413 (patch) | |
tree | 469c96bb6d1a12e486e6cf30cc410e5c99f8f18c /include/wabt/wast-parser.h | |
parent | b22be5a08611c53e8a893bbab049e6f18da6c55a (diff) | |
download | wabt-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.h | 18 |
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, |