mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
- minor simplification of #if/#endif handling ENH: improve input robustness with negative-prefixed expansions (#2095) - especially in blockMeshDict it is useful to negate an value directly. Eg, ``` xmax 100; xmin -$xmax; ``` However, this fails since the dictionary expansion is a two-step process of tokenization followed by expansion. After the expansion the given input would now be the following: ``` xmax 100; xmin - 100; ``` and retrieving a scalar value for 'xmin' fails. Counteract this by being more generous on tokenized input when attempting to retrieve a label or scalar value. If a '-' is found where a number is expected, use it to negate the subsequent value. The previous solution was to invoke an 'eval': ``` xmax 100; xmin #eval{-$xmax}; ``` which adds additional clutter.
50 lines
1.4 KiB
C++
50 lines
1.4 KiB
C++
/*--------------------------------*- C++ -*----------------------------------*\
|
|
| ========= | |
|
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
|
| \\ / O peration | Version: v2012 |
|
|
| \\ / A nd | Website: www.openfoam.com |
|
|
| \\/ M anipulation | |
|
|
\*---------------------------------------------------------------------------*/
|
|
FoamFile
|
|
{
|
|
version 2.0;
|
|
format ascii;
|
|
class dictionary;
|
|
object dictionary;
|
|
}
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
// Test parsing of primitive entry
|
|
// Can pass through foamDictionary -expand for test
|
|
|
|
dict1
|
|
{
|
|
entry1 no brackets;
|
|
|
|
entry2 balanced ( set of { brackets } in the ) entry;
|
|
|
|
entry3a mismatch ( set of { brackets ) in the } entry;
|
|
|
|
entry3b mismatch ( set of { brackets } in the } entry;
|
|
|
|
// Runs on
|
|
// entry3c too many ( set of ) brackets ) in ) entry;
|
|
|
|
//entry4 missing closing ( set of { brackets } in entry;
|
|
}
|
|
|
|
|
|
dict2
|
|
{
|
|
entry1 no brackets;
|
|
entry2 no brackets but missing semi-colon
|
|
}
|
|
|
|
dict3
|
|
{
|
|
entry1 anything;
|
|
}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|