From 410b7c92ea2e36b6a938fc34b4fd11e2eeea9fb3 Mon Sep 17 00:00:00 2001 From: Thomas Lively <7121787+tlively@users.noreply.github.com> Date: Fri, 27 May 2022 14:19:04 -0700 Subject: [Parser][NFC] Improve comments about default NaN payloads (#4697) --- src/wasm/wat-lexer.cpp | 5 +++++ src/wat-lexer.h | 2 ++ 2 files changed, 7 insertions(+) (limited to 'src') diff --git a/src/wasm/wat-lexer.cpp b/src/wasm/wat-lexer.cpp index 401ea6b7a..1992e9bab 100644 --- a/src/wasm/wat-lexer.cpp +++ b/src/wasm/wat-lexer.cpp @@ -222,6 +222,8 @@ struct LexFloatResult : LexResult { // The payload if we lexed a nan with payload. We cannot store the payload // directly in `d` because we do not know at this point whether we are parsing // an f32 or f64 and therefore we do not know what the allowable payloads are. + // No payload with NaN means to use the default payload for the expected float + // width. std::optional nanPayload; double d; }; @@ -602,6 +604,9 @@ std::optional float_(std::string_view in) { // TODO: Add error production for malformed NaN payload. return {}; } + } else { + // No explicit payload necessary; we will inject the default payload + // later. } } else { return {}; diff --git a/src/wat-lexer.h b/src/wat-lexer.h index d5c3b33ce..057d7eed7 100644 --- a/src/wat-lexer.h +++ b/src/wat-lexer.h @@ -69,6 +69,8 @@ struct FloatTok { // The payload if we lexed a nan with payload. We cannot store the payload // directly in `d` because we do not know at this point whether we are parsing // an f32 or f64 and therefore we do not know what the allowable payloads are. + // No payload with NaN means to use the default payload for the expected float + // width. std::optional nanPayload; double d; -- cgit v1.2.3