From a5b2fc5e89f1f32bb90eac8635292b6edf4ae51f Mon Sep 17 00:00:00 2001 From: Thomas Helfer Date: Fri, 28 Jun 2024 09:18:05 +0200 Subject: [PATCH] Fix Issue #370 --- docs/web/release-notes-5.0.md | 32 ++++++++++++++++++- mfront/tests/behaviours/CMakeLists.txt | 1 + .../behaviours/DigitSeparatorTest.mfront | 14 ++++++++ .../tests/behaviours/generic/CMakeLists.txt | 1 + src/Utilities/CxxTokenizer.cxx | 3 +- 5 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 mfront/tests/behaviours/DigitSeparatorTest.mfront diff --git a/docs/web/release-notes-5.0.md b/docs/web/release-notes-5.0.md index e9e13f40a..e440a1747 100644 --- a/docs/web/release-notes-5.0.md +++ b/docs/web/release-notes-5.0.md @@ -17,9 +17,35 @@ secPrefixTemplate: "$$i$$" eqnPrefixTemplate: "($$i$$)" --- +# New `TFEL/Utilities` features + +## Support for `C++` digit separator in `CxxTokenizer` + +The `CxxTokenizer` class now supports `C++` digit separators in numbers, +(integer of floatting point numbers), as illustrated in the following +example: + +~~~~{.cxx} +@DSL IsotropicMisesCreep; +@Behaviour DigitSeparatorTest; + +@UseQt true; +@Epsilon 0.000'000'000'1; +@IterMax 1'000; + +@ElasticMaterialProperties{150'000'000'000, 0.3}; +@Parameter stress s0 = 10'000'000; +@Parameter strainrate de0 = 8.230'512e-67; +@Parameter strainrate E = 8.2; + +@FlowRule{ + f = de0 * pow(seq / s0, E); +} +~~~~ + # New `TFEL/Math` features -## tiny matrices product +## Tiny matrices product The product of two tiny matrices has been implemented: @@ -287,3 +313,7 @@ For more details, see ## Issue 476: [generic interface] Add support for arrays of thermodynamic forces For more details, see + +## Issue 370: [tfel-utilities] Support for `C++` digit separator + +For more details, see \ No newline at end of file diff --git a/mfront/tests/behaviours/CMakeLists.txt b/mfront/tests/behaviours/CMakeLists.txt index 417f6021c..34cc75540 100644 --- a/mfront/tests/behaviours/CMakeLists.txt +++ b/mfront/tests/behaviours/CMakeLists.txt @@ -50,6 +50,7 @@ endif(HAVE_DIANAFEA) configure_file(PolyCrystals_DD_CC.mfront PolyCrystals_DD_CC.mfront.in @ONLY) +install_mfront_data(tests/behaviours DigitSeparatorTest.mfront) install_mfront_data(tests/behaviours DSLOptionsTest.mfront) install_mfront_data(tests/behaviours MaterialPropertiesBoundsCheck.mfront) install_mfront_data(tests/behaviours StateVariablesBoundsCheck.mfront) diff --git a/mfront/tests/behaviours/DigitSeparatorTest.mfront b/mfront/tests/behaviours/DigitSeparatorTest.mfront new file mode 100644 index 000000000..8a74d3444 --- /dev/null +++ b/mfront/tests/behaviours/DigitSeparatorTest.mfront @@ -0,0 +1,14 @@ +@DSL IsotropicMisesCreep; +@Behaviour DigitSeparatorTest; + +@Epsilon 0.000'000'000'1; +@IterMax 1'000; + +@ElasticMaterialProperties{150'000'000'000, 0.3}; +@Parameter stress s0 = 10'000'000; +@Parameter strainrate de0 = 8.230'512e-67; +@Parameter strainrate E = 8.2; + +@FlowRule{ + f = de0 * pow(seq / s0, E); +} \ No newline at end of file diff --git a/mfront/tests/behaviours/generic/CMakeLists.txt b/mfront/tests/behaviours/generic/CMakeLists.txt index f2f295fdf..85af9170d 100644 --- a/mfront/tests/behaviours/generic/CMakeLists.txt +++ b/mfront/tests/behaviours/generic/CMakeLists.txt @@ -15,6 +15,7 @@ configure_file("${PROJECT_SOURCE_DIR}/mfront/tests/behaviours/references/PolyCry PolyCrystalsAngles-30.txt @ONLY) set(mfront_tests_SOURCES + DigitSeparatorTest MaterialPropertiesBoundsCheck StateVariablesBoundsCheck ExternalStateVariablesBoundsCheck diff --git a/src/Utilities/CxxTokenizer.cxx b/src/Utilities/CxxTokenizer.cxx index dbf2a66f5..44a276ba6 100644 --- a/src/Utilities/CxxTokenizer.cxx +++ b/src/Utilities/CxxTokenizer.cxx @@ -506,7 +506,8 @@ namespace tfel::utilities { } } throw_if((p != pe) && (*p == '.'), "invalid number"); - this->tokens.emplace_back(std::string{b, p}, n, o, Token::Number); + this->tokens.emplace_back(replace_all(std::string{b, p}, "\'", ""), n, o, + Token::Number); const auto d = p - b; p = b; advance(o, p, d);