diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C index f2adc1b598..116a158bfa 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.C +++ b/src/OpenFOAM/db/dictionary/dictionary.C @@ -134,10 +134,7 @@ Foam::dictionary::dictionary if (iter().keyword().isPattern()) { patterns_.insert(&iter()); - regexps_.insert - ( - autoPtr(new regExp(iter().keyword())) - ); + regexps_.insert(autoPtr::New(iter().keyword())); } } } @@ -159,10 +156,7 @@ Foam::dictionary::dictionary if (iter().keyword().isPattern()) { patterns_.insert(&iter()); - regexps_.insert - ( - autoPtr(new regExp(iter().keyword())) - ); + regexps_.insert(autoPtr::New(iter().keyword())); } } } @@ -612,10 +606,7 @@ Foam::entry* Foam::dictionary::add(entry* entryPtr, bool mergeEntry) if (entryPtr->keyword().isPattern()) { patterns_.insert(entryPtr); - regexps_.insert - ( - autoPtr(new regExp(entryPtr->keyword())) - ); + regexps_.insert(autoPtr::New(entryPtr->keyword())); } return entryPtr; // now an entry in the dictionary @@ -641,10 +632,7 @@ Foam::entry* Foam::dictionary::add(entry* entryPtr, bool mergeEntry) if (entryPtr->keyword().isPattern()) { patterns_.insert(entryPtr); - regexps_.insert - ( - autoPtr(new regExp(entryPtr->keyword())) - ); + regexps_.insert(autoPtr::New(entryPtr->keyword())); } return entryPtr; // now an entry in the dictionary diff --git a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H index 65b4f73c6d..c7850f3124 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H +++ b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H @@ -51,7 +51,7 @@ SourceFiles namespace Foam { -// Forward declaration of friend functions and operators +// Forward declarations class dictionaryEntry; Ostream& operator<<(Ostream& os, const dictionaryEntry& e); @@ -75,7 +75,8 @@ public: // Constructors - //- Construct from the parent dictionary and Istream + //- Construct from the parent dictionary and Istream. + // The keyword is extracted from the stream dictionaryEntry(const dictionary& parentDict, Istream& is); //- Construct from the keyword, parent dictionary and a Istream diff --git a/src/OpenFOAM/db/dictionary/dictionaryIO.C b/src/OpenFOAM/db/dictionary/dictionaryIO.C index 2453f3760b..7a51ae2d67 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryIO.C +++ b/src/OpenFOAM/db/dictionary/dictionaryIO.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -100,13 +100,27 @@ bool Foam::dictionary::read(Istream& is, bool keepHeader) return false; } + // The expected end character + int endChar = token::END_BLOCK; token currToken(is); - if (currToken != token::BEGIN_BLOCK) + + if (currToken == token::END_BLOCK) + { + FatalIOErrorInFunction(is) + << "Dictionary input cannot start with '}'" + << exit(FatalIOError); + } + else if (currToken != token::BEGIN_BLOCK) { is.putBack(currToken); + endChar = 0; } - while (!is.eof() && entry::New(*this, is)) + while + ( + !is.eof() + && entry::New(*this, is, entry::inputMode::GLOBAL, endChar) + ) {} if (!keepHeader) diff --git a/src/OpenFOAM/db/dictionary/dictionarySearch.C b/src/OpenFOAM/db/dictionary/dictionarySearch.C index 34bdd4bca9..4c8ec03c07 100644 --- a/src/OpenFOAM/db/dictionary/dictionarySearch.C +++ b/src/OpenFOAM/db/dictionary/dictionarySearch.C @@ -689,10 +689,7 @@ bool Foam::dictionary::changeKeyword if (newKeyword.isPattern()) { patterns_.insert(iter()); - regexps_.insert - ( - autoPtr(new regExp(newKeyword)) - ); + regexps_.insert(autoPtr::New(newKeyword)); } return true; diff --git a/src/OpenFOAM/db/dictionary/entry/entry.H b/src/OpenFOAM/db/dictionary/entry/entry.H index 5b73b78c7d..ec7b17bd04 100644 --- a/src/OpenFOAM/db/dictionary/entry/entry.H +++ b/src/OpenFOAM/db/dictionary/entry/entry.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -51,14 +51,13 @@ SourceFiles namespace Foam { +// Forward declarations class ITstream; class dictionary; - -// Forward declaration of friend functions and operators - class entry; Ostream& operator<<(Ostream& os, const entry& e); + /*---------------------------------------------------------------------------*\ Class entry Declaration \*---------------------------------------------------------------------------*/ @@ -137,15 +136,36 @@ public: // Note: the parent directory is set to dictionary::null virtual autoPtr clone() const; - //- Construct from Istream and insert into dictionary + //- Construct from an Istream and insert into the dictionary + // \param parentDict dictionary to insert into + // \param is the input stream + // \param inpMode the input mode. + // The default is to use the currently active #globalInputMode + // \param endChar the expected end character (eg, a closing brace). + // The endChar is 0 if no expectations are asserted. static bool New ( dictionary& parentDict, Istream& is, - const inputMode inMode = inputMode::GLOBAL + const inputMode inpMode = inputMode::GLOBAL, + const int endChar = 0 ); - //- Construct on freestore from Istream and return + //- Construct an entry from Istream. + // The expected input comprises a keyword followed by a + // dictionaryEntry or a primitiveEntry. + // + // - The dictionaryEntry starts with a '{' left brace and ends + // with a '}' right brace. + // - The primitiveEntry ends with a ';' semi-colon. + // + // Example input + // \verbatim + // key1 { ... } // dictionary input + // key2 ... ; // primitive input + // \endverbatim + // + // \return The #entry read, or nullptr on error. static autoPtr New(Istream& is); //- Reset the #globalInputMode to %merge @@ -153,8 +173,7 @@ public: //- Destructor - virtual ~entry() - {} + virtual ~entry() = default; // Member functions diff --git a/src/OpenFOAM/db/dictionary/entry/entryIO.C b/src/OpenFOAM/db/dictionary/entry/entryIO.C index aea7319271..0e50a68e9b 100644 --- a/src/OpenFOAM/db/dictionary/entry/entryIO.C +++ b/src/OpenFOAM/db/dictionary/entry/entryIO.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -78,7 +78,7 @@ bool Foam::entry::getKeyword(keyType& keyword, Istream& is) return true; } - // Do some more checking + // Mark as invalid, but allow for some more checking if (keyToken == token::END_BLOCK || is.eof()) { return false; @@ -89,7 +89,7 @@ bool Foam::entry::getKeyword(keyType& keyword, Istream& is) << "--> FOAM Warning :" << nl << " From function " << FUNCTION_NAME << nl << " in file " << __FILE__ << " at line " << __LINE__ << nl - << " Reading " << is.name().c_str() << nl + << " Reading " << is.name() << nl << " found " << keyToken << nl << " expected either " << token::END_BLOCK << " or EOF" << std::endl; @@ -101,24 +101,23 @@ bool Foam::entry::New ( dictionary& parentDict, Istream& is, - const entry::inputMode inMode + const entry::inputMode inpMode, + const int endChar ) { // The inputMode for dealing with duplicate entries const entry::inputMode mode = ( - inMode == inputMode::GLOBAL + inpMode == inputMode::GLOBAL ? globalInputMode - : inMode + : inpMode ); // If somehow the global itself is 'global' - this is a severe logic error. if (mode == inputMode::GLOBAL) { - FatalIOErrorInFunction - ( - is - ) << "Cannot use 'GLOBAL' as an inputMode" + FatalIOErrorInFunction(is) + << "Cannot use 'GLOBAL' as an inputMode" << exit(FatalIOError); } @@ -130,37 +129,63 @@ bool Foam::entry::New // Get the next keyword and if a valid keyword return true const bool valid = getKeyword(keyword, keyToken, is); + // Can accept a list of entries too + if + ( + keyToken.isLabel() + || (keyToken.isPunctuation() && keyToken.pToken() == token::BEGIN_LIST) + ) + { + is.putBack(keyToken); + return parentDict.add + ( + new dictionaryListEntry(parentDict, is), + false + ); + } + if (!valid) { + // Error processing for invalid or unexpected input + // Do some more checking - if (keyToken == token::END_BLOCK || is.eof()) + if (keyToken == token::END_BLOCK) { + if (token::END_BLOCK != endChar) + { + FatalIOErrorInFunction(is) + << "Unexpected '}' while reading dictionary entry" + << exit(FatalIOError); + } + return false; + } + if (is.eof()) + { + if (endChar) + { + FatalIOErrorInFunction(is) + << "Unexpected EOF while reading dictionary entry" + << exit(FatalIOError); + } return false; } - if - ( - keyToken.isLabel() - || (keyToken.isPunctuation() && keyToken.pToken() == token::BEGIN_LIST) - ) + + if (endChar) { - is.putBack(keyToken); - return parentDict.add - ( - new dictionaryListEntry(parentDict, is), - false - ); + FatalIOErrorInFunction(is) + << "Found " << keyToken + << " but expected " << char(endChar) + << exit(FatalIOError); + } + else + { + FatalIOErrorInFunction(is) + << "Found " << keyToken + << " but expected EOF, or perhaps a '}' char" + << exit(FatalIOError); } - // Otherwise the token is invalid - std::cerr - << "--> FOAM Warning :" << nl - << " From function " << FUNCTION_NAME << nl - << " in file " << __FILE__ << " at line " << __LINE__ << nl - << " Reading " << is.name().c_str() << nl - << " found " << keyToken << nl - << " expected either " << token::END_BLOCK << " or EOF" - << std::endl; return false; } diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C index efebf3170c..4a2be026be 100644 --- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C +++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C @@ -264,17 +264,8 @@ Foam::primitiveEntry::primitiveEntry Foam::primitiveEntry::primitiveEntry(const keyType& key, Istream& is) : - entry(key), - ITstream - ( - is.name() + '.' + key, - tokenList(10), - is.format(), - is.version() - ) -{ - readEntry(dictionary::null, is); -} + primitiveEntry(key, dictionary::null, is) +{} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // diff --git a/tutorials/IO/dictionary/Allrun b/tutorials/IO/dictionary/Allrun new file mode 100755 index 0000000000..a2092676fd --- /dev/null +++ b/tutorials/IO/dictionary/Allrun @@ -0,0 +1,105 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions + +echo "dictionary input tests" + +verbose=true +npass=0 +nwarn=0 +nfail=0 + +foamDictionary -help > /dev/null 2>&1 || { + echo "Error: non-functional foamDictionary" + exit 2 +} + + +# Reduced verbosity in test mode? +if isTest "$@" +then + verbose=false +fi + + +for dict in \ + good*.dict \ + warn*.dict \ + fatal*.dict \ +; +do + [ -f "$dict" ] || continue # protect against bad globs + + # capture stderr, ignore stdout + stderr=$(foamDictionary -keywords $dict 2>&1 >/dev/null) + exitCode=$? + + case "$dict" in + *fatal*) + if [ $exitCode -eq 0 ] + then + echo "NOK did not detect fatal input $dict" + nfail=$(($fail + 1)) + else + echo "OK detected fatal input $dict" + npass=$(($npass + 1)) + fi + ;; + + *good*) + if [ $exitCode -eq 0 ] + then + npass=$(($npass + 1)) + if [ "${#stderr}" -gt 0 ] + then + # count unexpected warnings + nwarn=$(($nwarn + 1)) + echo "NOK unexpected warnings: $dict" + else + echo "OK good input $dict" + fi + else + echo "NOK failed input $dict" + nfail=$(($fail + 1)) + fi + ;; + + *warn*) + if [ $exitCode -eq 0 ] + then + npass=$(($npass + 1)) + if [ "${#stderr}" -gt 0 ] + then + echo "OK trapped warnings: $dict" + else + # count missing warnings + nwarn=$(($nwarn + 1)) + echo "NOK missing expected warnings: $dict" + fi + else + nfail=$(($fail + 1)) + echo "NOK failed (not warn) input $dict" + fi + ;; + + esac + + if [ "$verbose" = true ] && [ "${#stderr}" -gt 0 ] + then + echo "================" 1>&2 + echo "dictionary = $dict" 1>&2 + echo "$stderr" 1>&2 + echo "================" 1>&2 + fi + +done + +echo "$npass passed" +echo "$nwarn warnings" +echo "$nfail failed" + +test $nfail -eq 0 +exit $? + + +#------------------------------------------------------------------------------ diff --git a/tutorials/IO/dictionary/fatal-ending1.dict b/tutorials/IO/dictionary/fatal-ending1.dict new file mode 100644 index 0000000000..2fa8e588d6 --- /dev/null +++ b/tutorials/IO/dictionary/fatal-ending1.dict @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +} // A stray '}' before any real entries + +FoamFile +{ + version 2; + format ascii; + class dictionary; + object dictionary; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// ************************************************************************* // diff --git a/tutorials/IO/dictionary/fatal-ending2.dict b/tutorials/IO/dictionary/fatal-ending2.dict new file mode 100644 index 0000000000..fb4f85fd94 --- /dev/null +++ b/tutorials/IO/dictionary/fatal-ending2.dict @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2; + format ascii; + class dictionary; + object dictionary; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // oops extra stray '}' + + +// ************************************************************************* // diff --git a/tutorials/IO/dictionary/fatal-ending3.dict b/tutorials/IO/dictionary/fatal-ending3.dict new file mode 100644 index 0000000000..073e489efa --- /dev/null +++ b/tutorials/IO/dictionary/fatal-ending3.dict @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +{ + +FoamFile +{ + version 2; + format ascii; + class dictionary; + object dictionary; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +// ************************************************************************* // diff --git a/tutorials/IO/dictionary/fatal-ending4.dict b/tutorials/IO/dictionary/fatal-ending4.dict new file mode 100644 index 0000000000..7f97b1578d --- /dev/null +++ b/tutorials/IO/dictionary/fatal-ending4.dict @@ -0,0 +1,23 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +FoamFile +{ + version 2; + format ascii; + class dictionary; + object dictionary; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dict +{ + { key val; } // A stray '{}' pair after the first entries +} + +// ************************************************************************* // diff --git a/tutorials/IO/dictionary/fatal-premature-ending1.dict b/tutorials/IO/dictionary/fatal-premature-ending1.dict new file mode 100644 index 0000000000..40ee0b48db --- /dev/null +++ b/tutorials/IO/dictionary/fatal-premature-ending1.dict @@ -0,0 +1,25 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2; + format ascii; + class dictionary; + object dictionary; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dict +{ + key1 value1; + key2 value2; + +// oops no trailing '}' + + +// ************************************************************************* // diff --git a/tutorials/IO/dictionary/fatal-premature-ending2.dict b/tutorials/IO/dictionary/fatal-premature-ending2.dict new file mode 100644 index 0000000000..7df892f725 --- /dev/null +++ b/tutorials/IO/dictionary/fatal-premature-ending2.dict @@ -0,0 +1,34 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2; + format ascii; + class dictionary; + object dictionary; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dict1 +{ + key1 value1; + key2 value2; +} + +} // oops extra stray '}' + + +dict2 +{ + key1 value1; + key2 value2; +} + + + +// ************************************************************************* // diff --git a/tutorials/IO/dictionary/fatal-primitive-ending1.dict b/tutorials/IO/dictionary/fatal-primitive-ending1.dict new file mode 100644 index 0000000000..d097357658 --- /dev/null +++ b/tutorials/IO/dictionary/fatal-primitive-ending1.dict @@ -0,0 +1,23 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2; + format ascii; + class dictionary; + object dictionary; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dict +{ + key missing ending +} + + +// ************************************************************************* // diff --git a/tutorials/IO/dictionary/fatal-primitive-ending2.dict b/tutorials/IO/dictionary/fatal-primitive-ending2.dict new file mode 100644 index 0000000000..9187183949 --- /dev/null +++ b/tutorials/IO/dictionary/fatal-primitive-ending2.dict @@ -0,0 +1,24 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2; + format ascii; + class dictionary; + object dictionary; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dict +{ + key missing ending + +// no closing } either + + +// ************************************************************************* // diff --git a/tutorials/IO/dictionary/fatal-primitive-ending3.dict b/tutorials/IO/dictionary/fatal-primitive-ending3.dict new file mode 100644 index 0000000000..0c326f6569 --- /dev/null +++ b/tutorials/IO/dictionary/fatal-primitive-ending3.dict @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2; + format ascii; + class dictionary; + object dictionary; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +key missing ending + + +// ************************************************************************* // diff --git a/tutorials/IO/dictionary/good-empty1.dict b/tutorials/IO/dictionary/good-empty1.dict new file mode 100644 index 0000000000..7d3bbc1e37 --- /dev/null +++ b/tutorials/IO/dictionary/good-empty1.dict @@ -0,0 +1 @@ +// A dictionary file that exists, but without any tokens diff --git a/tutorials/IO/dictionary/good-empty2.dict b/tutorials/IO/dictionary/good-empty2.dict new file mode 100644 index 0000000000..9c4a3f7a0a --- /dev/null +++ b/tutorials/IO/dictionary/good-empty2.dict @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2; + format ascii; + class dictionary; + object dictionary; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// A dictionary file without any tokens except the header + + +// ************************************************************************* // diff --git a/tutorials/IO/dictionary/good-ending1.dict b/tutorials/IO/dictionary/good-ending1.dict new file mode 100644 index 0000000000..29078dcbe8 --- /dev/null +++ b/tutorials/IO/dictionary/good-ending1.dict @@ -0,0 +1,32 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2; + format ascii; + class dictionary; + object dictionary; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dict1 +{ + key1 value1; + key2 value2; +} + + +dict2 +{ + key1 value1; + key2 value2; +} + + + +// ************************************************************************* // diff --git a/tutorials/IO/dictionary/good-primitive-ending1.dict b/tutorials/IO/dictionary/good-primitive-ending1.dict new file mode 100644 index 0000000000..62c70cee37 --- /dev/null +++ b/tutorials/IO/dictionary/good-primitive-ending1.dict @@ -0,0 +1,23 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2; + format ascii; + class dictionary; + object dictionary; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dict +{ + key with ending; +} + + +// ************************************************************************* // diff --git a/tutorials/IO/dictionary/missed-ending3.dict b/tutorials/IO/dictionary/missed-ending3.dict new file mode 100644 index 0000000000..ec002dad47 --- /dev/null +++ b/tutorials/IO/dictionary/missed-ending3.dict @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +{} // A stray '{}' pair before any real entries + +FoamFile +{ + version 2; + format ascii; + class dictionary; + object dictionary; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// ************************************************************************* //