After realizing how the lexer code generation works, I went back and made my changes to json.hpp.re2c as I should have.

Tests back to green, with no direct edits to json.hpp
This commit is contained in:
Cameron T. Druyor 2016-04-29 20:44:51 -04:00
parent faa5a4d0f8
commit 8468750409
3 changed files with 586 additions and 821 deletions

306
Makefile
View File

@ -1,98 +1,226 @@
.PHONY: pretty clean ChangeLog.md # CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.5
# used programs # Default target executed when no arguments are given to make.
RE2C = re2c default_target: all
SED = sed
# main target .PHONY : default_target
all: json_unit
# clean up # Allow only one "make -f Makefile2" at a time, but pass parallelism.
.NOTPARALLEL:
#=============================================================================
# Special targets provided by cmake.
# Disable implicit rules so canonical targets will work.
.SUFFIXES:
# Remove some rules from gmake that .SUFFIXES does not remove.
SUFFIXES =
.SUFFIXES: .hpux_make_needs_suffix_list
# Suppress display of executed commands.
$(VERBOSE).SILENT:
# A target that is always out of date.
cmake_force:
.PHONY : cmake_force
#=============================================================================
# Set environment variables for the build.
# The shell in which to execute make rules.
SHELL = /bin/sh
# The CMake executable.
CMAKE_COMMAND = /usr/local/Cellar/cmake/3.5.1/bin/cmake
# The command to remove a file.
RM = /usr/local/Cellar/cmake/3.5.1/bin/cmake -E remove -f
# Escaping for special characters.
EQUALS = =
# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /Users/cameron/Projects/json
# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /Users/cameron/Projects/json
#=============================================================================
# Targets provided globally by CMake.
# Special rule for the target rebuild_cache
rebuild_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
/usr/local/Cellar/cmake/3.5.1/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : rebuild_cache
# Special rule for the target rebuild_cache
rebuild_cache/fast: rebuild_cache
.PHONY : rebuild_cache/fast
# Special rule for the target list_install_components
list_install_components:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Available install components are: \"Unspecified\""
.PHONY : list_install_components
# Special rule for the target list_install_components
list_install_components/fast: list_install_components
.PHONY : list_install_components/fast
# Special rule for the target install
install: preinstall
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
/usr/local/Cellar/cmake/3.5.1/bin/cmake -P cmake_install.cmake
.PHONY : install
# Special rule for the target install
install/fast: preinstall/fast
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
/usr/local/Cellar/cmake/3.5.1/bin/cmake -P cmake_install.cmake
.PHONY : install/fast
# Special rule for the target install/strip
install/strip: preinstall
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..."
/usr/local/Cellar/cmake/3.5.1/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake
.PHONY : install/strip
# Special rule for the target install/strip
install/strip/fast: install/strip
.PHONY : install/strip/fast
# Special rule for the target install/local
install/local: preinstall
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..."
/usr/local/Cellar/cmake/3.5.1/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake
.PHONY : install/local
# Special rule for the target install/local
install/local/fast: install/local
.PHONY : install/local/fast
# Special rule for the target edit_cache
edit_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..."
/usr/local/Cellar/cmake/3.5.1/bin/ccmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : edit_cache
# Special rule for the target edit_cache
edit_cache/fast: edit_cache
.PHONY : edit_cache/fast
# The main all target
all: cmake_check_build_system
$(CMAKE_COMMAND) -E cmake_progress_start /Users/cameron/Projects/json/CMakeFiles /Users/cameron/Projects/json/CMakeFiles/progress.marks
$(MAKE) -f CMakeFiles/Makefile2 all
$(CMAKE_COMMAND) -E cmake_progress_start /Users/cameron/Projects/json/CMakeFiles 0
.PHONY : all
# The main clean target
clean: clean:
rm -fr json_unit json_benchmarks fuzz fuzz-testing *.dSYM $(MAKE) -f CMakeFiles/Makefile2 clean
.PHONY : clean
# The main clean target
clean/fast: clean
.PHONY : clean/fast
# Prepare targets for installation.
preinstall: all
$(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall
# Prepare targets for installation.
preinstall/fast:
$(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall/fast
# clear depends
depend:
$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
.PHONY : depend
#=============================================================================
# Target rules for targets named json_unit
# Build rule for target.
json_unit: cmake_check_build_system
$(MAKE) -f CMakeFiles/Makefile2 json_unit
.PHONY : json_unit
# fast build rule for target.
json_unit/fast:
$(MAKE) -f CMakeFiles/json_unit.dir/build.make CMakeFiles/json_unit.dir/build
.PHONY : json_unit/fast
test/unit.o: test/unit.cpp.o
.PHONY : test/unit.o
# target to build an object file
test/unit.cpp.o:
$(MAKE) -f CMakeFiles/json_unit.dir/build.make CMakeFiles/json_unit.dir/test/unit.cpp.o
.PHONY : test/unit.cpp.o
test/unit.i: test/unit.cpp.i
.PHONY : test/unit.i
# target to preprocess a source file
test/unit.cpp.i:
$(MAKE) -f CMakeFiles/json_unit.dir/build.make CMakeFiles/json_unit.dir/test/unit.cpp.i
.PHONY : test/unit.cpp.i
test/unit.s: test/unit.cpp.s
.PHONY : test/unit.s
# target to generate assembly for a file
test/unit.cpp.s:
$(MAKE) -f CMakeFiles/json_unit.dir/build.make CMakeFiles/json_unit.dir/test/unit.cpp.s
.PHONY : test/unit.cpp.s
# Help Target
help:
@echo "The following are some of the valid targets for this Makefile:"
@echo "... all (the default if no target is provided)"
@echo "... clean"
@echo "... depend"
@echo "... rebuild_cache"
@echo "... list_install_components"
@echo "... install"
@echo "... install/strip"
@echo "... install/local"
@echo "... edit_cache"
@echo "... json_unit"
@echo "... test/unit.o"
@echo "... test/unit.i"
@echo "... test/unit.s"
.PHONY : help
##########################################################################
# unit tests
##########################################################################
# additional flags #=============================================================================
FLAGS = -Wall -Wextra -pedantic -Weffc++ -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch -Wundef -Wno-unused -Wnon-virtual-dtor -Wreorder -Wdeprecated -Wfloat-equal # Special targets to cleanup operation of make.
# build unit tests # Special rule to run CMake to check the build system integrity.
json_unit: test/unit.cpp src/json.hpp test/catch.hpp # No rule that depends on this can have commands that come from listfiles
$(CXX) -std=c++11 $(CXXFLAGS) $(FLAGS) $(CPPFLAGS) -I src -I test $< $(LDFLAGS) -o $@ # because they might be regenerated.
cmake_check_build_system:
$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
.PHONY : cmake_check_build_system
##########################################################################
# documentation tests
##########################################################################
# compile example files and check output
doctest:
make check_output -C doc
##########################################################################
# fuzzing
##########################################################################
# the overall fuzz testing target
fuzz_testing:
rm -fr fuzz-testing
mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out
$(MAKE) fuzz CXX=afl-clang++
mv fuzz fuzz-testing
find test/json_tests -size -5k -name *json | xargs -I{} cp "{}" fuzz-testing/testcases
@echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzz"
# the fuzzer binary
fuzz: test/fuzz.cpp src/json.hpp
$(CXX) -std=c++11 $(CXXFLAGS) $(FLAGS) $(CPPFLAGS) -I src $< $(LDFLAGS) -o $@
##########################################################################
# static analyzer
##########################################################################
# call cppcheck on the main header file
cppcheck:
cppcheck --enable=all --inconclusive --std=c++11 src/json.hpp
##########################################################################
# maintainer targets
##########################################################################
# create scanner with re2c
re2c: src/json.hpp.re2c
$(RE2C) --bit-vectors --nested-ifs --no-debug-info $< | $(SED) '1d' > src/json.hpp
# pretty printer
pretty:
astyle --style=allman --indent=spaces=4 --indent-modifiers \
--indent-switches --indent-preproc-block --indent-preproc-define \
--indent-col1-comments --pad-oper --pad-header --align-pointer=type \
--align-reference=type --add-brackets --convert-tabs --close-templates \
--lineend=linux --preserve-date --suffix=none --formatted \
src/json.hpp src/json.hpp.re2c test/unit.cpp test/fuzz.cpp benchmarks/benchmarks.cpp doc/examples/*.cpp
##########################################################################
# benchmarks
##########################################################################
# benchmarks
json_benchmarks: benchmarks/benchmarks.cpp benchmarks/benchpress.hpp benchmarks/cxxopts.hpp src/json.hpp
$(CXX) -std=c++11 $(CXXFLAGS) -O3 -flto -I src -I benchmarks $< $(LDFLAGS) -o $@
./json_benchmarks
##########################################################################
# changelog
##########################################################################
ChangeLog.md:
github_changelog_generator -o ChangeLog.md --simple-list --release-url https://github.com/nlohmann/json/releases/tag/%s
gsed -i 's|https://github.com/nlohmann/json/releases/tag/HEAD|https://github.com/nlohmann/json/tree/HEAD|' ChangeLog.md
gsed -i '2i All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).' ChangeLog.md

View File

@ -7527,8 +7527,7 @@ class basic_json
{ {
lexer_char_t yych; lexer_char_t yych;
unsigned int yyaccept = 0; unsigned int yyaccept = 0;
static const unsigned char yybm[] = static const unsigned char yybm[] = {
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 32, 32, 0, 0, 32, 0, 0, 0, 32, 32, 0, 0, 32, 0, 0,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
@ -7562,716 +7561,340 @@ class basic_json
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
}; };
if ((m_limit - m_cursor) < 5) if ((m_limit - m_cursor) < 5) yyfill(); // LCOV_EXCL_LINE;
{
yyfill(); // LCOV_EXCL_LINE;
}
yych = *m_cursor; yych = *m_cursor;
if (yybm[0 + yych] & 32) if (yybm[0+yych] & 32) {
{
goto basic_json_parser_6; goto basic_json_parser_6;
} }
if (yych <= '\\') if (yych <= '\\') {
{ if (yych <= '-') {
if (yych <= '-') if (yych <= '"') {
{ if (yych <= 0x00) goto basic_json_parser_2;
if (yych <= '"') if (yych <= '!') goto basic_json_parser_4;
{
if (yych <= 0x00)
{
goto basic_json_parser_2;
}
if (yych <= '!')
{
goto basic_json_parser_4;
}
goto basic_json_parser_9; goto basic_json_parser_9;
} } else {
else if (yych <= '+') goto basic_json_parser_4;
{ if (yych <= ',') goto basic_json_parser_10;
if (yych <= '+')
{
goto basic_json_parser_4;
}
if (yych <= ',')
{
goto basic_json_parser_10;
}
goto basic_json_parser_12; goto basic_json_parser_12;
} }
} } else {
else if (yych <= '9') {
{ if (yych <= '/') goto basic_json_parser_4;
if (yych <= '9') if (yych <= '0') goto basic_json_parser_13;
{
if (yych <= '/')
{
goto basic_json_parser_4;
}
if (yych <= '0')
{
goto basic_json_parser_13;
}
goto basic_json_parser_15; goto basic_json_parser_15;
} } else {
else if (yych <= ':') goto basic_json_parser_17;
{ if (yych == '[') goto basic_json_parser_19;
if (yych <= ':')
{
goto basic_json_parser_17;
}
if (yych == '[')
{
goto basic_json_parser_19;
}
goto basic_json_parser_4; goto basic_json_parser_4;
} }
} }
} } else {
else if (yych <= 't') {
{ if (yych <= 'f') {
if (yych <= 't') if (yych <= ']') goto basic_json_parser_21;
{ if (yych <= 'e') goto basic_json_parser_4;
if (yych <= 'f')
{
if (yych <= ']')
{
goto basic_json_parser_21;
}
if (yych <= 'e')
{
goto basic_json_parser_4;
}
goto basic_json_parser_23; goto basic_json_parser_23;
} } else {
else if (yych == 'n') goto basic_json_parser_24;
{ if (yych <= 's') goto basic_json_parser_4;
if (yych == 'n')
{
goto basic_json_parser_24;
}
if (yych <= 's')
{
goto basic_json_parser_4;
}
goto basic_json_parser_25; goto basic_json_parser_25;
} }
} } else {
else if (yych <= '|') {
{ if (yych == '{') goto basic_json_parser_26;
if (yych <= '|')
{
if (yych == '{')
{
goto basic_json_parser_26;
}
goto basic_json_parser_4; goto basic_json_parser_4;
} } else {
else if (yych <= '}') goto basic_json_parser_28;
{ if (yych == 0xEF) goto basic_json_parser_30;
if (yych <= '}')
{
goto basic_json_parser_28;
}
if (yych == 0xEF)
{
goto basic_json_parser_30;
}
goto basic_json_parser_4; goto basic_json_parser_4;
} }
} }
} }
basic_json_parser_2: basic_json_parser_2:
++m_cursor; ++m_cursor;
{ { return token_type::end_of_input; }
return token_type::end_of_input;
}
basic_json_parser_4: basic_json_parser_4:
++m_cursor; ++m_cursor;
basic_json_parser_5: basic_json_parser_5:
{ { return token_type::parse_error; }
return token_type::parse_error;
}
basic_json_parser_6: basic_json_parser_6:
++m_cursor; ++m_cursor;
if (m_limit <= m_cursor) if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE;
{
yyfill(); // LCOV_EXCL_LINE;
}
yych = *m_cursor; yych = *m_cursor;
if (yybm[0 + yych] & 32) if (yybm[0+yych] & 32) {
{
goto basic_json_parser_6; goto basic_json_parser_6;
} }
{ { return scan(); }
return scan();
}
basic_json_parser_9: basic_json_parser_9:
yyaccept = 0; yyaccept = 0;
yych = *(m_marker = ++m_cursor); yych = *(m_marker = ++m_cursor);
if (yych <= 0x0F) if (yych <= 0x0F) goto basic_json_parser_5;
{
goto basic_json_parser_5;
}
goto basic_json_parser_32; goto basic_json_parser_32;
basic_json_parser_10: basic_json_parser_10:
++m_cursor; ++m_cursor;
{ { return token_type::value_separator; }
return token_type::value_separator;
}
basic_json_parser_12: basic_json_parser_12:
yych = *++m_cursor; yych = *++m_cursor;
if (yych <= '/') if (yych <= '/') goto basic_json_parser_5;
{ if (yych <= '0') goto basic_json_parser_13;
goto basic_json_parser_5; if (yych <= '9') goto basic_json_parser_15;
}
if (yych <= '0')
{
goto basic_json_parser_13;
}
if (yych <= '9')
{
goto basic_json_parser_15;
}
goto basic_json_parser_5; goto basic_json_parser_5;
basic_json_parser_13: basic_json_parser_13:
yyaccept = 1; yyaccept = 1;
yych = *(m_marker = ++m_cursor); yych = *(m_marker = ++m_cursor);
if (yych <= 'D') if (yych <= 'D') {
{ if (yych == '.') goto basic_json_parser_37;
if (yych == '.') } else {
{ if (yych <= 'E') goto basic_json_parser_38;
goto basic_json_parser_37; if (yych == 'e') goto basic_json_parser_38;
}
}
else
{
if (yych <= 'E')
{
goto basic_json_parser_38;
}
if (yych == 'e')
{
goto basic_json_parser_38;
}
} }
basic_json_parser_14: basic_json_parser_14:
{ { return token_type::value_number; }
return token_type::value_number;
}
basic_json_parser_15: basic_json_parser_15:
yyaccept = 1; yyaccept = 1;
m_marker = ++m_cursor; m_marker = ++m_cursor;
if ((m_limit - m_cursor) < 3) if ((m_limit - m_cursor) < 3) yyfill(); // LCOV_EXCL_LINE;
{
yyfill(); // LCOV_EXCL_LINE;
}
yych = *m_cursor; yych = *m_cursor;
if (yybm[0 + yych] & 64) if (yybm[0+yych] & 64) {
{
goto basic_json_parser_15; goto basic_json_parser_15;
} }
if (yych <= 'D') if (yych <= 'D') {
{ if (yych == '.') goto basic_json_parser_37;
if (yych == '.')
{
goto basic_json_parser_37;
}
goto basic_json_parser_14; goto basic_json_parser_14;
} } else {
else if (yych <= 'E') goto basic_json_parser_38;
{ if (yych == 'e') goto basic_json_parser_38;
if (yych <= 'E')
{
goto basic_json_parser_38;
}
if (yych == 'e')
{
goto basic_json_parser_38;
}
goto basic_json_parser_14; goto basic_json_parser_14;
} }
basic_json_parser_17: basic_json_parser_17:
++m_cursor; ++m_cursor;
{ { return token_type::name_separator; }
return token_type::name_separator;
}
basic_json_parser_19: basic_json_parser_19:
++m_cursor; ++m_cursor;
{ { return token_type::begin_array; }
return token_type::begin_array;
}
basic_json_parser_21: basic_json_parser_21:
++m_cursor; ++m_cursor;
{ { return token_type::end_array; }
return token_type::end_array;
}
basic_json_parser_23: basic_json_parser_23:
yyaccept = 0; yyaccept = 0;
yych = *(m_marker = ++m_cursor); yych = *(m_marker = ++m_cursor);
if (yych == 'a') if (yych == 'a') goto basic_json_parser_39;
{
goto basic_json_parser_39;
}
goto basic_json_parser_5; goto basic_json_parser_5;
basic_json_parser_24: basic_json_parser_24:
yyaccept = 0; yyaccept = 0;
yych = *(m_marker = ++m_cursor); yych = *(m_marker = ++m_cursor);
if (yych == 'u') if (yych == 'u') goto basic_json_parser_40;
{
goto basic_json_parser_40;
}
goto basic_json_parser_5; goto basic_json_parser_5;
basic_json_parser_25: basic_json_parser_25:
yyaccept = 0; yyaccept = 0;
yych = *(m_marker = ++m_cursor); yych = *(m_marker = ++m_cursor);
if (yych == 'r') if (yych == 'r') goto basic_json_parser_41;
{
goto basic_json_parser_41;
}
goto basic_json_parser_5; goto basic_json_parser_5;
basic_json_parser_26: basic_json_parser_26:
++m_cursor; ++m_cursor;
{ { return token_type::begin_object; }
return token_type::begin_object;
}
basic_json_parser_28: basic_json_parser_28:
++m_cursor; ++m_cursor;
{ { return token_type::end_object; }
return token_type::end_object;
}
basic_json_parser_30: basic_json_parser_30:
yyaccept = 0; yyaccept = 0;
yych = *(m_marker = ++m_cursor); yych = *(m_marker = ++m_cursor);
if (yych == 0xBB) if (yych == 0xBB) goto basic_json_parser_42;
{
goto basic_json_parser_42;
}
goto basic_json_parser_5; goto basic_json_parser_5;
basic_json_parser_31: basic_json_parser_31:
++m_cursor; ++m_cursor;
if (m_limit <= m_cursor) if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE;
{
yyfill(); // LCOV_EXCL_LINE;
}
yych = *m_cursor; yych = *m_cursor;
basic_json_parser_32: basic_json_parser_32:
if (yybm[0 + yych] & 128) if (yybm[0+yych] & 128) {
{
goto basic_json_parser_31; goto basic_json_parser_31;
} }
if (yych <= 0x0F) if (yych <= 0x0F) goto basic_json_parser_33;
{ if (yych <= '"') goto basic_json_parser_34;
goto basic_json_parser_33;
}
if (yych <= '"')
{
goto basic_json_parser_34;
}
goto basic_json_parser_36; goto basic_json_parser_36;
basic_json_parser_33: basic_json_parser_33:
m_cursor = m_marker; m_cursor = m_marker;
if (yyaccept == 0) if (yyaccept == 0) {
{
goto basic_json_parser_5; goto basic_json_parser_5;
} } else {
else
{
goto basic_json_parser_14; goto basic_json_parser_14;
} }
basic_json_parser_34: basic_json_parser_34:
++m_cursor; ++m_cursor;
{ { return token_type::value_string; }
return token_type::value_string;
}
basic_json_parser_36: basic_json_parser_36:
++m_cursor; ++m_cursor;
if (m_limit <= m_cursor) if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE;
{
yyfill(); // LCOV_EXCL_LINE;
}
yych = *m_cursor; yych = *m_cursor;
if (yych <= 'e') if (yych <= 'e') {
{ if (yych <= '/') {
if (yych <= '/') if (yych == '"') goto basic_json_parser_31;
{ if (yych <= '.') goto basic_json_parser_33;
if (yych == '"')
{
goto basic_json_parser_31; goto basic_json_parser_31;
} } else {
if (yych <= '.') if (yych <= '\\') {
{ if (yych <= '[') goto basic_json_parser_33;
goto basic_json_parser_33;
}
goto basic_json_parser_31; goto basic_json_parser_31;
} } else {
else if (yych == 'b') goto basic_json_parser_31;
{
if (yych <= '\\')
{
if (yych <= '[')
{
goto basic_json_parser_33;
}
goto basic_json_parser_31;
}
else
{
if (yych == 'b')
{
goto basic_json_parser_31;
}
goto basic_json_parser_33; goto basic_json_parser_33;
} }
} }
} } else {
else if (yych <= 'q') {
{ if (yych <= 'f') goto basic_json_parser_31;
if (yych <= 'q') if (yych == 'n') goto basic_json_parser_31;
{
if (yych <= 'f')
{
goto basic_json_parser_31;
}
if (yych == 'n')
{
goto basic_json_parser_31;
}
goto basic_json_parser_33; goto basic_json_parser_33;
} } else {
else if (yych <= 's') {
{ if (yych <= 'r') goto basic_json_parser_31;
if (yych <= 's')
{
if (yych <= 'r')
{
goto basic_json_parser_31;
}
goto basic_json_parser_33; goto basic_json_parser_33;
} } else {
else if (yych <= 't') goto basic_json_parser_31;
{ if (yych <= 'u') goto basic_json_parser_43;
if (yych <= 't')
{
goto basic_json_parser_31;
}
if (yych <= 'u')
{
goto basic_json_parser_43;
}
goto basic_json_parser_33; goto basic_json_parser_33;
} }
} }
} }
basic_json_parser_37: basic_json_parser_37:
yych = *++m_cursor; yych = *++m_cursor;
if (yych <= '/') if (yych <= '/') goto basic_json_parser_33;
{ if (yych <= '9') goto basic_json_parser_44;
goto basic_json_parser_33;
}
if (yych <= '9')
{
goto basic_json_parser_44;
}
goto basic_json_parser_33; goto basic_json_parser_33;
basic_json_parser_38: basic_json_parser_38:
yych = *++m_cursor; yych = *++m_cursor;
if (yych <= ',') if (yych <= ',') {
{ if (yych == '+') goto basic_json_parser_46;
if (yych == '+')
{
goto basic_json_parser_46;
}
goto basic_json_parser_33; goto basic_json_parser_33;
} } else {
else if (yych <= '-') goto basic_json_parser_46;
{ if (yych <= '/') goto basic_json_parser_33;
if (yych <= '-') if (yych <= '9') goto basic_json_parser_47;
{
goto basic_json_parser_46;
}
if (yych <= '/')
{
goto basic_json_parser_33;
}
if (yych <= '9')
{
goto basic_json_parser_47;
}
goto basic_json_parser_33; goto basic_json_parser_33;
} }
basic_json_parser_39: basic_json_parser_39:
yych = *++m_cursor; yych = *++m_cursor;
if (yych == 'l') if (yych == 'l') goto basic_json_parser_49;
{
goto basic_json_parser_49;
}
goto basic_json_parser_33; goto basic_json_parser_33;
basic_json_parser_40: basic_json_parser_40:
yych = *++m_cursor; yych = *++m_cursor;
if (yych == 'l') if (yych == 'l') goto basic_json_parser_50;
{
goto basic_json_parser_50;
}
goto basic_json_parser_33; goto basic_json_parser_33;
basic_json_parser_41: basic_json_parser_41:
yych = *++m_cursor; yych = *++m_cursor;
if (yych == 'u') if (yych == 'u') goto basic_json_parser_51;
{
goto basic_json_parser_51;
}
goto basic_json_parser_33; goto basic_json_parser_33;
basic_json_parser_42: basic_json_parser_42:
yych = *++m_cursor; yych = *++m_cursor;
if (yych == 0xBF) if (yych == 0xBF) goto basic_json_parser_52;
{
goto basic_json_parser_52;
}
goto basic_json_parser_33; goto basic_json_parser_33;
basic_json_parser_43: basic_json_parser_43:
++m_cursor; ++m_cursor;
if (m_limit <= m_cursor) if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE;
{
yyfill(); // LCOV_EXCL_LINE;
}
yych = *m_cursor; yych = *m_cursor;
if (yych <= '@') if (yych <= '@') {
{ if (yych <= '/') goto basic_json_parser_33;
if (yych <= '/') if (yych <= '9') goto basic_json_parser_54;
{
goto basic_json_parser_33; goto basic_json_parser_33;
} } else {
if (yych <= '9') if (yych <= 'F') goto basic_json_parser_54;
{ if (yych <= '`') goto basic_json_parser_33;
goto basic_json_parser_54; if (yych <= 'f') goto basic_json_parser_54;
}
goto basic_json_parser_33;
}
else
{
if (yych <= 'F')
{
goto basic_json_parser_54;
}
if (yych <= '`')
{
goto basic_json_parser_33;
}
if (yych <= 'f')
{
goto basic_json_parser_54;
}
goto basic_json_parser_33; goto basic_json_parser_33;
} }
basic_json_parser_44: basic_json_parser_44:
yyaccept = 1; yyaccept = 1;
m_marker = ++m_cursor; m_marker = ++m_cursor;
if ((m_limit - m_cursor) < 3) if ((m_limit - m_cursor) < 3) yyfill(); // LCOV_EXCL_LINE;
{
yyfill(); // LCOV_EXCL_LINE;
}
yych = *m_cursor; yych = *m_cursor;
if (yych <= 'D') if (yych <= 'D') {
{ if (yych <= '/') goto basic_json_parser_14;
if (yych <= '/') if (yych <= '9') goto basic_json_parser_44;
{
goto basic_json_parser_14; goto basic_json_parser_14;
} } else {
if (yych <= '9') if (yych <= 'E') goto basic_json_parser_38;
{ if (yych == 'e') goto basic_json_parser_38;
goto basic_json_parser_44;
}
goto basic_json_parser_14;
}
else
{
if (yych <= 'E')
{
goto basic_json_parser_38;
}
if (yych == 'e')
{
goto basic_json_parser_38;
}
goto basic_json_parser_14; goto basic_json_parser_14;
} }
basic_json_parser_46: basic_json_parser_46:
yych = *++m_cursor; yych = *++m_cursor;
if (yych <= '/') if (yych <= '/') goto basic_json_parser_33;
{ if (yych >= ':') goto basic_json_parser_33;
goto basic_json_parser_33;
}
if (yych >= ':')
{
goto basic_json_parser_33;
}
basic_json_parser_47: basic_json_parser_47:
++m_cursor; ++m_cursor;
if (m_limit <= m_cursor) if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE;
{
yyfill(); // LCOV_EXCL_LINE;
}
yych = *m_cursor; yych = *m_cursor;
if (yych <= '/') if (yych <= '/') goto basic_json_parser_14;
{ if (yych <= '9') goto basic_json_parser_47;
goto basic_json_parser_14;
}
if (yych <= '9')
{
goto basic_json_parser_47;
}
goto basic_json_parser_14; goto basic_json_parser_14;
basic_json_parser_49: basic_json_parser_49:
yych = *++m_cursor; yych = *++m_cursor;
if (yych == 's') if (yych == 's') goto basic_json_parser_55;
{
goto basic_json_parser_55;
}
goto basic_json_parser_33; goto basic_json_parser_33;
basic_json_parser_50: basic_json_parser_50:
yych = *++m_cursor; yych = *++m_cursor;
if (yych == 'l') if (yych == 'l') goto basic_json_parser_56;
{
goto basic_json_parser_56;
}
goto basic_json_parser_33; goto basic_json_parser_33;
basic_json_parser_51: basic_json_parser_51:
yych = *++m_cursor; yych = *++m_cursor;
if (yych == 'e') if (yych == 'e') goto basic_json_parser_58;
{
goto basic_json_parser_58;
}
goto basic_json_parser_33; goto basic_json_parser_33;
basic_json_parser_52: basic_json_parser_52:
++m_cursor; ++m_cursor;
{ { return scan(); }
return scan();
}
basic_json_parser_54: basic_json_parser_54:
++m_cursor; ++m_cursor;
if (m_limit <= m_cursor) if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE;
{
yyfill(); // LCOV_EXCL_LINE;
}
yych = *m_cursor; yych = *m_cursor;
if (yych <= '@') if (yych <= '@') {
{ if (yych <= '/') goto basic_json_parser_33;
if (yych <= '/') if (yych <= '9') goto basic_json_parser_60;
{
goto basic_json_parser_33; goto basic_json_parser_33;
} } else {
if (yych <= '9') if (yych <= 'F') goto basic_json_parser_60;
{ if (yych <= '`') goto basic_json_parser_33;
goto basic_json_parser_60; if (yych <= 'f') goto basic_json_parser_60;
}
goto basic_json_parser_33;
}
else
{
if (yych <= 'F')
{
goto basic_json_parser_60;
}
if (yych <= '`')
{
goto basic_json_parser_33;
}
if (yych <= 'f')
{
goto basic_json_parser_60;
}
goto basic_json_parser_33; goto basic_json_parser_33;
} }
basic_json_parser_55: basic_json_parser_55:
yych = *++m_cursor; yych = *++m_cursor;
if (yych == 'e') if (yych == 'e') goto basic_json_parser_61;
{
goto basic_json_parser_61;
}
goto basic_json_parser_33; goto basic_json_parser_33;
basic_json_parser_56: basic_json_parser_56:
++m_cursor; ++m_cursor;
{ { return token_type::literal_null; }
return token_type::literal_null;
}
basic_json_parser_58: basic_json_parser_58:
++m_cursor; ++m_cursor;
{ { return token_type::literal_true; }
return token_type::literal_true;
}
basic_json_parser_60: basic_json_parser_60:
++m_cursor; ++m_cursor;
if (m_limit <= m_cursor) if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE;
{
yyfill(); // LCOV_EXCL_LINE;
}
yych = *m_cursor; yych = *m_cursor;
if (yych <= '@') if (yych <= '@') {
{ if (yych <= '/') goto basic_json_parser_33;
if (yych <= '/') if (yych <= '9') goto basic_json_parser_63;
{
goto basic_json_parser_33; goto basic_json_parser_33;
} } else {
if (yych <= '9') if (yych <= 'F') goto basic_json_parser_63;
{ if (yych <= '`') goto basic_json_parser_33;
goto basic_json_parser_63; if (yych <= 'f') goto basic_json_parser_63;
}
goto basic_json_parser_33;
}
else
{
if (yych <= 'F')
{
goto basic_json_parser_63;
}
if (yych <= '`')
{
goto basic_json_parser_33;
}
if (yych <= 'f')
{
goto basic_json_parser_63;
}
goto basic_json_parser_33; goto basic_json_parser_33;
} }
basic_json_parser_61: basic_json_parser_61:
++m_cursor; ++m_cursor;
{ { return token_type::literal_false; }
return token_type::literal_false;
}
basic_json_parser_63: basic_json_parser_63:
++m_cursor; ++m_cursor;
if (m_limit <= m_cursor) if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE;
{
yyfill(); // LCOV_EXCL_LINE;
}
yych = *m_cursor; yych = *m_cursor;
if (yych <= '@') if (yych <= '@') {
{ if (yych <= '/') goto basic_json_parser_33;
if (yych <= '/') if (yych <= '9') goto basic_json_parser_31;
{
goto basic_json_parser_33; goto basic_json_parser_33;
} } else {
if (yych <= '9') if (yych <= 'F') goto basic_json_parser_31;
{ if (yych <= '`') goto basic_json_parser_33;
goto basic_json_parser_31; if (yych <= 'f') goto basic_json_parser_31;
}
goto basic_json_parser_33;
}
else
{
if (yych <= 'F')
{
goto basic_json_parser_31;
}
if (yych <= '`')
{
goto basic_json_parser_33;
}
if (yych <= 'f')
{
goto basic_json_parser_31;
}
goto basic_json_parser_33; goto basic_json_parser_33;
} }
} }
@ -8537,9 +8160,9 @@ basic_json_parser_63:
// remember this number was parsed (for later serialization) // remember this number was parsed (for later serialization)
result.m_type.bits.parsed = true; result.m_type.bits.parsed = true;
// 'found_radix_point' will be set to true upon finding a radix // 'found_radix_point' will be set to 0xFF upon finding a radix
// point. If no radix point is found, the precision will be corrected // point. if it is not found, then the precision will be updated
uint8_t found_radix_point = 0; bool found_radix_point = false;
uint8_t precision = 0; uint8_t precision = 0;
// accumulate the integer conversion result (unsigned for now) // accumulate the integer conversion result (unsigned for now)
@ -8581,7 +8204,7 @@ basic_json_parser_63:
// reset precision count // reset precision count
precision = 0; precision = 0;
found_radix_point = 0xFF; found_radix_point = true;
continue; continue;
} }
// assume exponent (if not then will fail parse): change to // assume exponent (if not then will fail parse): change to
@ -8620,7 +8243,7 @@ basic_json_parser_63:
// If no radix point was found then precision would now be set to // If no radix point was found then precision would now be set to
// the number of digits, which is wrong - decrement it to sig figs - 1 // the number of digits, which is wrong - decrement it to sig figs - 1
if(found_radix_point == 0) if(not found_radix_point)
{ {
int trailing_zeros = 0; int trailing_zeros = 0;
for (int j = precision-1;j>=0;--j) for (int j = precision-1;j>=0;--j)

View File

@ -7848,9 +7848,8 @@ class basic_json
result.m_type.bits.parsed = true; result.m_type.bits.parsed = true;
// 'found_radix_point' will be set to 0xFF upon finding a radix // 'found_radix_point' will be set to 0xFF upon finding a radix
// point and later used to mask in/out the precision depending // point. if it is not found, then the precision will be updated
// whether a radix is found i.e. 'precision &= found_radix_point' bool found_radix_point = false;
uint8_t found_radix_point = 0;
uint8_t precision = 0; uint8_t precision = 0;
// accumulate the integer conversion result (unsigned for now) // accumulate the integer conversion result (unsigned for now)
@ -7892,7 +7891,7 @@ class basic_json
// reset precision count // reset precision count
precision = 0; precision = 0;
found_radix_point = 0xFF; found_radix_point = true;
continue; continue;
} }
// assume exponent (if not then will fail parse): change to // assume exponent (if not then will fail parse): change to
@ -7930,8 +7929,23 @@ class basic_json
} }
// If no radix point was found then precision would now be set to // If no radix point was found then precision would now be set to
// the number of digits, which is wrong - clear it. // the number of digits, which is wrong - decrement it to sig figs - 1
result.m_type.bits.precision = precision & found_radix_point; if(not found_radix_point)
{
int trailing_zeros = 0;
for (int j = precision-1;j>=0;--j)
{
auto c = *(m_start+j);
if(c == '0')
++trailing_zeros;
else if(c > '0' and c <= '9' or c == '-')
break;
else
throw std::logic_error("unexpected character: "+std::to_string(c));
}
precision -= (trailing_zeros + 1);
}
result.m_type.bits.precision = precision;
// save the value (if not a float) // save the value (if not a float)
if (type == value_t::number_unsigned) if (type == value_t::number_unsigned)