From 52d9cb50cec8479aed2bbf2cf5ab90bd617cae09 Mon Sep 17 00:00:00 2001 From: Zach Laine Date: Thu, 7 Nov 2024 19:43:39 -0600 Subject: [PATCH] Add much longer lexing test; fix errors. See #202. --- include/boost/parser/lexer.hpp | 7 +- test/lexer.cpp | 600 +++++++++++++++++++++++++++++++++ 2 files changed, 605 insertions(+), 2 deletions(-) diff --git a/include/boost/parser/lexer.hpp b/include/boost/parser/lexer.hpp index a27a631c..cfbf3d7d 100644 --- a/include/boost/parser/lexer.hpp +++ b/include/boost/parser/lexer.hpp @@ -294,6 +294,8 @@ namespace boost { namespace parser { return parse_spec{token_parsed_type::character, base}; } else if constexpr (std::is_same_v) { return parse_spec{token_parsed_type::string_view, base}; + } else if constexpr (std::is_same_v) { + return parse_spec{token_parsed_type::bool_, base}; } else if constexpr (std::is_same_v) { return parse_spec{token_parsed_type::signed_char, base}; } else if constexpr (std::is_same_v) { @@ -878,8 +880,7 @@ namespace boost { namespace parser { auto const ctre_last = ctre_range.end(); size_t i = parent_->tokens_.size(); - for (; i < new_size && ctre_first != ctre_last; - ++i, ++ctre_first) { + for (; i < new_size && ctre_first != ctre_last; ++ctre_first) { auto const parse_results = *ctre_first; if constexpr (Lexer::has_ws) { @@ -893,6 +894,8 @@ namespace boost { namespace parser { } } + ++i; + detail::hl::fold_n( string_view{}, [&](auto state, auto i) { if constexpr (!i.value) { diff --git a/test/lexer.cpp b/test/lexer.cpp index 686eed15..93ba8eeb 100644 --- a/test/lexer.cpp +++ b/test/lexer.cpp @@ -506,6 +506,606 @@ sheet alert_dialog BOOST_TEST(position == (int)std::size(expected)); } + { + char const large_input[] = R"(/* + Copyright 2005-2007 Adobe Systems Incorporated + Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt + or a copy at http://stlab.adobe.com/licenses.html) +*/ + +sheet image_size +{ +input: + original_width : 1600; + original_height : 1200; + original_resolution : 300; + +constant: + original_doc_width : original_width / original_resolution; + original_doc_height : original_height / original_resolution; + +interface: + resample : true; + unlink constrain : true <== resample ? constrain : true; + unlink scale_styles : true <== resample && constrain ? scale_styles : false; + + resample_method : @bicubic; + + dim_width_pixels : original_width <== resample ? round(dim_width_pixels) : original_width; + dim_width_percent : 100 <== resample ? dim_width_percent : 100; + + dim_height_pixels : original_height <== resample ? round(dim_height_pixels) : original_height; + dim_height_percent : 100 <== resample ? dim_height_percent : 100; + + doc_width_inches : original_doc_width; + doc_width_percent : 100; + + /* + Resolution must be initialized before width and height inches to allow proportions + to be constrained. + */ + doc_resolution : original_resolution; + + doc_height_inches : original_doc_height; + doc_height_percent : 100; + + auto_quality : @draft; + + screen_lpi; // initialized from doc_resolution + +logic: + relate { + doc_width_inches <== doc_width_percent * original_doc_width / 100; + doc_width_percent <== doc_width_inches * 100 / original_doc_width; + } + + relate { + doc_height_inches <== doc_height_percent * original_doc_height / 100; + doc_height_percent <== doc_height_inches * 100 / original_doc_height; + } + + relate { + screen_lpi <== doc_resolution / (auto_quality == @draft ? 1 : (auto_quality == @good ? 1.5 : 2.0)); + doc_resolution <== screen_lpi * (auto_quality == @draft ? 1 : (auto_quality == @good ? 1.5 : 2.0)); + } + + when (resample) relate { + dim_width_pixels <== dim_width_percent * original_width / 100; + dim_width_percent <== dim_width_pixels * 100 / original_width; + } + + when (resample) relate { + dim_height_pixels <== dim_height_percent * original_height / 100; + dim_height_percent <== dim_height_pixels * 100 / original_height; + } + + when (resample) relate { + doc_width_inches <== dim_width_pixels / doc_resolution; + dim_width_pixels <== doc_width_inches * doc_resolution; + doc_resolution <== dim_width_pixels / doc_width_inches; + } + + when (resample) relate { + doc_height_inches <== dim_height_pixels / doc_resolution; + dim_height_pixels <== doc_height_inches * doc_resolution; + doc_resolution <== dim_height_pixels / doc_height_inches; + } + + when (!resample) relate { + doc_resolution <== original_width / doc_width_inches; + doc_width_inches <== original_width / doc_resolution; + } + + when (!resample) relate { + doc_resolution <== original_height / doc_height_inches; + doc_height_inches <== original_height / doc_resolution; + } + + when (constrain && resample) relate { + dim_width_percent <== dim_height_percent; + dim_height_percent <== dim_width_percent; + } + + output: + byte_count <== dim_width_pixels * dim_height_pixels * 32; + + result <== resample ? { + command: @resize_image, + width: dim_width_pixels, + height: dim_height_pixels, + resolution: doc_resolution, + scale_styles: scale_styles, + resample_method: resample_method + } : { + command: @set_resolution, + resolution: doc_resolution + }; + + invariant: + width_max <== dim_width_pixels <= 300000; + height_max <== dim_height_pixels <= 300000; +} +)"; + + tok_t const expected[] = { + tok_t((int)adobe_tokens::lead_comment, R"(/* + Copyright 2005-2007 Adobe Systems Incorporated + Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt + or a copy at http://stlab.adobe.com/licenses.html) +*/)"), + tok_t((int)adobe_tokens::identifier, "sheet"), + tok_t((int)adobe_tokens::identifier, "image_size"), + tok_t((int)bp::character_id, (long long)'{'), + tok_t((int)adobe_tokens::identifier, "input"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::identifier, "original_width"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::number, 1600.0), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "original_height"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::number, 1200.0), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "original_resolution"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::number, 300.0), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "constant"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::identifier, "original_doc_width"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::identifier, "original_width"), + tok_t((int)adobe_tokens::mul_op, "/"), + tok_t((int)adobe_tokens::identifier, "original_resolution"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "original_doc_height"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::identifier, "original_height"), + tok_t((int)adobe_tokens::mul_op, "/"), + tok_t((int)adobe_tokens::identifier, "original_resolution"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "interface"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::identifier, "resample"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::keyword_true_false, 1ll), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "unlink"), + tok_t((int)adobe_tokens::identifier, "constrain"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::keyword_true_false, 1ll), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "resample"), + tok_t((int)bp::character_id, (long long)'?'), + tok_t((int)adobe_tokens::identifier, "constrain"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::keyword_true_false, 1ll), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "unlink"), + tok_t((int)adobe_tokens::identifier, "scale_styles"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::keyword_true_false, 1ll), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "resample"), + tok_t((int)adobe_tokens::and_, "&&"), + tok_t((int)adobe_tokens::identifier, "constrain"), + tok_t((int)bp::character_id, (long long)'?'), + tok_t((int)adobe_tokens::identifier, "scale_styles"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::keyword_true_false, 0ll), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "resample_method"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)bp::character_id, (long long)'@'), + tok_t((int)adobe_tokens::identifier, "bicubic"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "dim_width_pixels"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::identifier, "original_width"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "resample"), + tok_t((int)bp::character_id, (long long)'?'), + tok_t((int)adobe_tokens::identifier, "round"), + tok_t((int)bp::character_id, (long long)'('), + tok_t((int)adobe_tokens::identifier, "dim_width_pixels"), + tok_t((int)bp::character_id, (long long)')'), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::identifier, "original_width"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "dim_width_percent"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::number, 100.0), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "resample"), + tok_t((int)bp::character_id, (long long)'?'), + tok_t((int)adobe_tokens::identifier, "dim_width_percent"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::number, 100.0), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "dim_height_pixels"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::identifier, "original_height"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "resample"), + tok_t((int)bp::character_id, (long long)'?'), + tok_t((int)adobe_tokens::identifier, "round"), + tok_t((int)bp::character_id, (long long)'('), + tok_t((int)adobe_tokens::identifier, "dim_height_pixels"), + tok_t((int)bp::character_id, (long long)')'), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::identifier, "original_height"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "dim_height_percent"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::number, 100.0), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "resample"), + tok_t((int)bp::character_id, (long long)'?'), + tok_t((int)adobe_tokens::identifier, "dim_height_percent"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::number, 100.0), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "doc_width_inches"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::identifier, "original_doc_width"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "doc_width_percent"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::number, 100.0), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::lead_comment, R"(/* + Resolution must be initialized before width and height inches to allow proportions + to be constrained. + */)"), + tok_t((int)adobe_tokens::identifier, "doc_resolution"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::identifier, "original_resolution"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "doc_height_inches"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::identifier, "original_doc_height"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "doc_height_percent"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::number, 100.0), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "auto_quality"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)bp::character_id, (long long)'@'), + tok_t((int)adobe_tokens::identifier, "draft"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "screen_lpi"), + tok_t((int)bp::character_id, (long long)';'), + tok_t( + (int)adobe_tokens::trail_comment, + "// initialized from doc_resolution"), + tok_t((int)adobe_tokens::identifier, "logic"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::identifier, "relate"), + tok_t((int)bp::character_id, (long long)'{'), + tok_t((int)adobe_tokens::identifier, "doc_width_inches"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "doc_width_percent"), + tok_t((int)adobe_tokens::mul_op, "*"), + tok_t((int)adobe_tokens::identifier, "original_doc_width"), + tok_t((int)adobe_tokens::mul_op, "/"), + tok_t((int)adobe_tokens::number, 100.0), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "doc_width_percent"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "doc_width_inches"), + tok_t((int)adobe_tokens::mul_op, "*"), + tok_t((int)adobe_tokens::number, 100.0), + tok_t((int)adobe_tokens::mul_op, "/"), + tok_t((int)adobe_tokens::identifier, "original_doc_width"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)bp::character_id, (long long)'}'), + tok_t((int)adobe_tokens::identifier, "relate"), + tok_t((int)bp::character_id, (long long)'{'), + tok_t((int)adobe_tokens::identifier, "doc_height_inches"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "doc_height_percent"), + tok_t((int)adobe_tokens::mul_op, "*"), + tok_t((int)adobe_tokens::identifier, "original_doc_height"), + tok_t((int)adobe_tokens::mul_op, "/"), + tok_t((int)adobe_tokens::number, 100.0), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "doc_height_percent"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "doc_height_inches"), + tok_t((int)adobe_tokens::mul_op, "*"), + tok_t((int)adobe_tokens::number, 100.0), + tok_t((int)adobe_tokens::mul_op, "/"), + tok_t((int)adobe_tokens::identifier, "original_doc_height"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)bp::character_id, (long long)'}'), + tok_t((int)adobe_tokens::identifier, "relate"), + tok_t((int)bp::character_id, (long long)'{'), + tok_t((int)adobe_tokens::identifier, "screen_lpi"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "doc_resolution"), + tok_t((int)adobe_tokens::mul_op, "/"), + tok_t((int)bp::character_id, (long long)'('), + tok_t((int)adobe_tokens::identifier, "auto_quality"), + tok_t((int)adobe_tokens::eq_op, "=="), + tok_t((int)bp::character_id, (long long)'@'), + tok_t((int)adobe_tokens::identifier, "draft"), + tok_t((int)bp::character_id, (long long)'?'), + tok_t((int)adobe_tokens::number, 1.0), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)bp::character_id, (long long)'('), + tok_t((int)adobe_tokens::identifier, "auto_quality"), + tok_t((int)adobe_tokens::eq_op, "=="), + tok_t((int)bp::character_id, (long long)'@'), + tok_t((int)adobe_tokens::identifier, "good"), + tok_t((int)bp::character_id, (long long)'?'), + tok_t((int)adobe_tokens::number, 1.5), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::number, 2.0), + tok_t((int)bp::character_id, (long long)')'), + tok_t((int)bp::character_id, (long long)')'), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "doc_resolution"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "screen_lpi"), + tok_t((int)adobe_tokens::mul_op, "*"), + tok_t((int)bp::character_id, (long long)'('), + tok_t((int)adobe_tokens::identifier, "auto_quality"), + tok_t((int)adobe_tokens::eq_op, "=="), + tok_t((int)bp::character_id, (long long)'@'), + tok_t((int)adobe_tokens::identifier, "draft"), + tok_t((int)bp::character_id, (long long)'?'), + tok_t((int)adobe_tokens::number, 1.0), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)bp::character_id, (long long)'('), + tok_t((int)adobe_tokens::identifier, "auto_quality"), + tok_t((int)adobe_tokens::eq_op, "=="), + tok_t((int)bp::character_id, (long long)'@'), + tok_t((int)adobe_tokens::identifier, "good"), + tok_t((int)bp::character_id, (long long)'?'), + tok_t((int)adobe_tokens::number, 1.5), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::number, 2.0), + tok_t((int)bp::character_id, (long long)')'), + tok_t((int)bp::character_id, (long long)')'), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)bp::character_id, (long long)'}'), + tok_t((int)adobe_tokens::identifier, "when"), + tok_t((int)bp::character_id, (long long)'('), + tok_t((int)adobe_tokens::identifier, "resample"), + tok_t((int)bp::character_id, (long long)')'), + tok_t((int)adobe_tokens::identifier, "relate"), + tok_t((int)bp::character_id, (long long)'{'), + tok_t((int)adobe_tokens::identifier, "dim_width_pixels"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "dim_width_percent"), + tok_t((int)adobe_tokens::mul_op, "*"), + tok_t((int)adobe_tokens::identifier, "original_width"), + tok_t((int)adobe_tokens::mul_op, "/"), + tok_t((int)adobe_tokens::number, 100.0), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "dim_width_percent"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "dim_width_pixels"), + tok_t((int)adobe_tokens::mul_op, "*"), + tok_t((int)adobe_tokens::number, 100.0), + tok_t((int)adobe_tokens::mul_op, "/"), + tok_t((int)adobe_tokens::identifier, "original_width"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)bp::character_id, (long long)'}'), + tok_t((int)adobe_tokens::identifier, "when"), + tok_t((int)bp::character_id, (long long)'('), + tok_t((int)adobe_tokens::identifier, "resample"), + tok_t((int)bp::character_id, (long long)')'), + tok_t((int)adobe_tokens::identifier, "relate"), + tok_t((int)bp::character_id, (long long)'{'), + tok_t((int)adobe_tokens::identifier, "dim_height_pixels"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "dim_height_percent"), + tok_t((int)adobe_tokens::mul_op, "*"), + tok_t((int)adobe_tokens::identifier, "original_height"), + tok_t((int)adobe_tokens::mul_op, "/"), + tok_t((int)adobe_tokens::number, 100.0), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "dim_height_percent"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "dim_height_pixels"), + tok_t((int)adobe_tokens::mul_op, "*"), + tok_t((int)adobe_tokens::number, 100.0), + tok_t((int)adobe_tokens::mul_op, "/"), + tok_t((int)adobe_tokens::identifier, "original_height"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)bp::character_id, (long long)'}'), + tok_t((int)adobe_tokens::identifier, "when"), + tok_t((int)bp::character_id, (long long)'('), + tok_t((int)adobe_tokens::identifier, "resample"), + tok_t((int)bp::character_id, (long long)')'), + tok_t((int)adobe_tokens::identifier, "relate"), + tok_t((int)bp::character_id, (long long)'{'), + tok_t((int)adobe_tokens::identifier, "doc_width_inches"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "dim_width_pixels"), + tok_t((int)adobe_tokens::mul_op, "/"), + tok_t((int)adobe_tokens::identifier, "doc_resolution"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "dim_width_pixels"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "doc_width_inches"), + tok_t((int)adobe_tokens::mul_op, "*"), + tok_t((int)adobe_tokens::identifier, "doc_resolution"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "doc_resolution"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "dim_width_pixels"), + tok_t((int)adobe_tokens::mul_op, "/"), + tok_t((int)adobe_tokens::identifier, "doc_width_inches"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)bp::character_id, (long long)'}'), + tok_t((int)adobe_tokens::identifier, "when"), + tok_t((int)bp::character_id, (long long)'('), + tok_t((int)adobe_tokens::identifier, "resample"), + tok_t((int)bp::character_id, (long long)')'), + tok_t((int)adobe_tokens::identifier, "relate"), + tok_t((int)bp::character_id, (long long)'{'), + tok_t((int)adobe_tokens::identifier, "doc_height_inches"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "dim_height_pixels"), + tok_t((int)adobe_tokens::mul_op, "/"), + tok_t((int)adobe_tokens::identifier, "doc_resolution"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "dim_height_pixels"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "doc_height_inches"), + tok_t((int)adobe_tokens::mul_op, "*"), + tok_t((int)adobe_tokens::identifier, "doc_resolution"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "doc_resolution"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "dim_height_pixels"), + tok_t((int)adobe_tokens::mul_op, "/"), + tok_t((int)adobe_tokens::identifier, "doc_height_inches"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)bp::character_id, (long long)'}'), + tok_t((int)adobe_tokens::identifier, "when"), + tok_t((int)bp::character_id, (long long)'('), + tok_t((int)bp::character_id, (long long)'!'), + tok_t((int)adobe_tokens::identifier, "resample"), + tok_t((int)bp::character_id, (long long)')'), + tok_t((int)adobe_tokens::identifier, "relate"), + tok_t((int)bp::character_id, (long long)'{'), + tok_t((int)adobe_tokens::identifier, "doc_resolution"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "original_width"), + tok_t((int)adobe_tokens::mul_op, "/"), + tok_t((int)adobe_tokens::identifier, "doc_width_inches"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "doc_width_inches"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "original_width"), + tok_t((int)adobe_tokens::mul_op, "/"), + tok_t((int)adobe_tokens::identifier, "doc_resolution"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)bp::character_id, (long long)'}'), + tok_t((int)adobe_tokens::identifier, "when"), + tok_t((int)bp::character_id, (long long)'('), + tok_t((int)bp::character_id, (long long)'!'), + tok_t((int)adobe_tokens::identifier, "resample"), + tok_t((int)bp::character_id, (long long)')'), + tok_t((int)adobe_tokens::identifier, "relate"), + tok_t((int)bp::character_id, (long long)'{'), + tok_t((int)adobe_tokens::identifier, "doc_resolution"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "original_height"), + tok_t((int)adobe_tokens::mul_op, "/"), + tok_t((int)adobe_tokens::identifier, "doc_height_inches"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "doc_height_inches"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "original_height"), + tok_t((int)adobe_tokens::mul_op, "/"), + tok_t((int)adobe_tokens::identifier, "doc_resolution"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)bp::character_id, (long long)'}'), + tok_t((int)adobe_tokens::identifier, "when"), + tok_t((int)bp::character_id, (long long)'('), + tok_t((int)adobe_tokens::identifier, "constrain"), + tok_t((int)adobe_tokens::and_, "&&"), + tok_t((int)adobe_tokens::identifier, "resample"), + tok_t((int)bp::character_id, (long long)')'), + tok_t((int)adobe_tokens::identifier, "relate"), + tok_t((int)bp::character_id, (long long)'{'), + tok_t((int)adobe_tokens::identifier, "dim_width_percent"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "dim_height_percent"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "dim_height_percent"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "dim_width_percent"), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)bp::character_id, (long long)'}'), + tok_t((int)adobe_tokens::identifier, "output"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::identifier, "byte_count"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "dim_width_pixels"), + tok_t((int)adobe_tokens::mul_op, "*"), + tok_t((int)adobe_tokens::identifier, "dim_height_pixels"), + tok_t((int)adobe_tokens::mul_op, "*"), + tok_t((int)adobe_tokens::number, 32.0), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "result"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "resample"), + tok_t((int)bp::character_id, (long long)'?'), + tok_t((int)bp::character_id, (long long)'{'), + tok_t((int)adobe_tokens::identifier, "command"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)bp::character_id, (long long)'@'), + tok_t((int)adobe_tokens::identifier, "resize_image"), + tok_t((int)bp::character_id, (long long)','), + tok_t((int)adobe_tokens::identifier, "width"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::identifier, "dim_width_pixels"), + tok_t((int)bp::character_id, (long long)','), + tok_t((int)adobe_tokens::identifier, "height"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::identifier, "dim_height_pixels"), + tok_t((int)bp::character_id, (long long)','), + tok_t((int)adobe_tokens::identifier, "resolution"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::identifier, "doc_resolution"), + tok_t((int)bp::character_id, (long long)','), + tok_t((int)adobe_tokens::identifier, "scale_styles"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::identifier, "scale_styles"), + tok_t((int)bp::character_id, (long long)','), + tok_t((int)adobe_tokens::identifier, "resample_method"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::identifier, "resample_method"), + tok_t((int)bp::character_id, (long long)'}'), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)bp::character_id, (long long)'{'), + tok_t((int)adobe_tokens::identifier, "command"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)bp::character_id, (long long)'@'), + tok_t((int)adobe_tokens::identifier, "set_resolution"), + tok_t((int)bp::character_id, (long long)','), + tok_t((int)adobe_tokens::identifier, "resolution"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::identifier, "doc_resolution"), + tok_t((int)bp::character_id, (long long)'}'), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "invariant"), + tok_t((int)bp::character_id, (long long)':'), + tok_t((int)adobe_tokens::identifier, "width_max"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "dim_width_pixels"), + tok_t((int)adobe_tokens::rel_op, "<"), + tok_t((int)bp::character_id, (long long)'='), + tok_t((int)adobe_tokens::number, 300000.0), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)adobe_tokens::identifier, "height_max"), + tok_t((int)adobe_tokens::define, "<=="), + tok_t((int)adobe_tokens::identifier, "dim_height_pixels"), + tok_t((int)adobe_tokens::rel_op, "<"), + tok_t((int)bp::character_id, (long long)'='), + tok_t((int)adobe_tokens::number, 300000.0), + tok_t((int)bp::character_id, (long long)';'), + tok_t((int)bp::character_id, (long long)'}')}; + + int position = 0; + for (auto tok : + std::string(large_input) | bp::to_tokens(lexer)) { + BOOST_TEST(tok == expected[position]); + if (tok != expected[position]) { + std::cout << "At pos=" << position << ": got " << tok + << " expected " << expected[position] << "\n"; + } + ++position; + } + BOOST_TEST(position == (int)std::size(expected)); + } + // TODO: Need a lex that requires the cache to grow! // TODO: Need tests with the various supported kinds of input