From 6775276e738e2a3bc866aa549cd3818a8e1acc23 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Sun, 17 Aug 2025 10:23:10 -0400 Subject: [PATCH] Tinkering with gperf options --- src/json_token_enum.hpp | 10 +++++----- src/json_tokens.gperf | 10 ++++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/json_token_enum.hpp b/src/json_token_enum.hpp index 3cf5215..5a6b2b7 100644 --- a/src/json_token_enum.hpp +++ b/src/json_token_enum.hpp @@ -1,5 +1,8 @@ #pragma once +#include "json_tokens.hpp" +#include + enum class JsonTokenType { Unknown = 0, Preconditions = 1, @@ -20,14 +23,11 @@ enum class JsonTokenType { RangeDelete = 16 }; -#include "json_tokens.hpp" -#include - inline JsonTokenType get_json_token_type(std::string_view str) { const JsonToken *token = Perfect_Hash::lookup_json_token(str.data(), str.size()); - if (token && token->name[0] != '\0') { // Check that we got a valid token + if (token) { return static_cast(token->token_id); } return JsonTokenType::Unknown; -} \ No newline at end of file +} diff --git a/src/json_tokens.gperf b/src/json_tokens.gperf index e7b7b4d..451f8b0 100644 --- a/src/json_tokens.gperf +++ b/src/json_tokens.gperf @@ -3,11 +3,13 @@ %} %define hash-function-name hash_json_token %define lookup-function-name lookup_json_token -%language=C++ -%global-table -%struct-type -%readonly-tables %compare-lengths +%global-table +%language=C++ +%null-strings +%readonly-tables +%struct-type +%switch=1 struct JsonToken { const char* name;