Browse Source

#include support

master
Julio Biason 1 year ago
parent
commit
308f028f49
  1. 59
      pestfoamtest/resources/controlDict
  2. 11
      pestfoamtest/src/foam.pest
  3. 7
      pestfoamtest/src/lib.rs

59
pestfoamtest/resources/controlDict

@ -0,0 +1,59 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2212 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application pimpleFoam;
startFrom latestTime;
startTime 0;
stopAt endTime;
endTime 1;
deltaT 0.0002;
writeControl adjustable;
writeInterval 0.02;
purgeWrite 0;
writeFormat ascii;
writePrecision 7;
writeCompression no;
timeFormat general;
timePrecision 6;
runTimeModifiable yes;
adjustTimeStep yes;
maxCo 1;
maxDeltaT 1;
functions
{
#include "relVelocity"
}
// ************************************************************************* //

11
pestfoamtest/src/foam.pest

@ -4,8 +4,17 @@ single_comment = { "//" ~ (!NEWLINE ~ ANY)* }
identifier = { ASCII_ALPHA+ ~ (ASCII_ALPHA | ASCII_DIGIT | "_")* }
rvalue = { ('a'..'z' | 'A'..'Z' | '0'..'9' | "_" | ".")+ }
middle = { (whitespace | multi_comment)+ }
include = { "#" ~ identifier ~ middle ~ "\"" ~ identifier ~ "\"" }
attribution = { identifier ~ middle ~ rvalue ~ ";" }
dictionary = { identifier ~ middle ~ "{" ~ (dictionary | attribution | whitespace | multi_comment | single_comment)+ ~ "}" }
dictionary = { identifier ~ middle ~ "{" ~ (
dictionary
| attribution
| whitespace
| multi_comment
| single_comment
| include
)+ ~ "}" }
list_size = _{ ASCII_DIGIT+ ~ whitespace+ }
list = { identifier ~ middle ~ list_size? ~ "(" ~ (rvalue | whitespace | multi_comment | single_comment)+ ~ ");" }

7
pestfoamtest/src/lib.rs

@ -124,4 +124,11 @@ mod file {
let parse = FoamParser::parse(Rule::file, text);
assert!(parse.is_ok(), "{:?}", parse);
}
#[test]
fn control_dict() {
let text = include_bytes!("../resources/controlDict");
let parse = FoamParser::parse(Rule::file, &std::str::from_utf8(text).unwrap());
assert!(parse.is_ok(), "{:?}", parse);
}
}

Loading…
Cancel
Save