From ed15efeedd33bbdbadfafabc812d70a792a9a06c Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Mon, 5 Feb 2024 10:24:16 -0800 Subject: [Parser] Templatize lexing of integers (#6272) Have a single implementation for lexing each of unsigned, signed, and uninterpreted integers, each generic over the bit width of the integer. This reduces duplication in the existing code and it will make it much easier to support lexing more 8- and 16-bit integers. --- src/parser/input.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/parser/input.h') diff --git a/src/parser/input.h b/src/parser/input.h index dbf3e4868..d4fdde1bd 100644 --- a/src/parser/input.h +++ b/src/parser/input.h @@ -51,11 +51,9 @@ struct ParseInput { std::optional takeOffset(); std::optional takeAlign(); std::optional takeU64(); - std::optional takeS64(); - std::optional takeI64(); + std::optional takeI64(); std::optional takeU32(); - std::optional takeS32(); - std::optional takeI32(); + std::optional takeI32(); std::optional takeU8(); std::optional takeF64(); std::optional takeF32(); @@ -67,6 +65,11 @@ struct ParseInput { Index getPos(); [[nodiscard]] Err err(Index pos, std::string reason); [[nodiscard]] Err err(std::string reason) { return err(getPos(), reason); } + +private: + template std::optional takeU(); + template std::optional takeS(); + template std::optional takeI(); }; #include "input-impl.h" -- cgit v1.2.3