--- trunk/src/mdParser/MDTreeParser.g 2008/07/14 12:35:58 1277 +++ branches/development/src/mdParser/MDTreeParser.g 2012/08/09 15:52:59 1776 @@ -4,7 +4,7 @@ using namespace std; #include "io/Globals.hpp" #include "utils/StringUtils.hpp" using namespace std; -using namespace oopse; +using namespace OpenMD; } options { @@ -35,28 +35,38 @@ statement : assignment ; statement : assignment - | componentblock - | moleculeblock - | zconstraintblock - ; + | componentblock + | moleculeblock + | zconstraintblock + | restraintblock + | flucqblock + | rnemdblock + | minimizerblock + ; - assignment : #(ASSIGNEQUAL id:ID constant[#id]) //{blockStack.top()->assign(#ID->getText(),);} ; constant [ANTLR_USE_NAMESPACE(antlr)RefAST id] { - int ival; - RealType dval; + int ival; + RealType dval, x, y, z; + Vector3d dvec; } - : ival=intConst {blockStack.top()->assign(id->getText(), ival);} - | dval=floatConst {blockStack.top()->assign(id->getText(), dval);} - | str1:ID {blockStack.top()->assign(id->getText(), str1->getText());} - | str2:StringLiteral { std::string s = str2->getText(); - s = s.substr(1, s.length()-2); - blockStack.top()->assign(id->getText(),s); - } - ; + : ival=intConst {blockStack.top()->assign(id->getText(), ival);} + | dval=floatConst {blockStack.top()->assign(id->getText(), dval);} + | #(LPAREN x=doubleNumber COMMA y=doubleNumber COMMA z=doubleNumber RPAREN) + { dvec.x() = x; + dvec.y() = y; + dvec.z() = z; + blockStack.top()->assign(id->getText(), dvec); + } + | str1:ID {blockStack.top()->assign(id->getText(), str1->getText());} + | str2:StringLiteral {std::string s = str2->getText(); + s = s.substr(1, s.length()-2); + blockStack.top()->assign(id->getText(),s); + } + ; componentblock : #(COMPONENT {Component* currComponet = new Component(); blockStack.push(currComponet);} @@ -68,7 +78,28 @@ zconstraintblock : #(ZCONSTRAINT {ZConsStamp* currZCo (assignment)* ENDBLOCK ) {blockStack.top()->validate();blockStack.pop(); currConf->addZConsStamp(currZConsStamp);} ; + +restraintblock : #(RESTRAINT {RestraintStamp* currRestraintStamp = new RestraintStamp(); blockStack.push(currRestraintStamp);} + (assignment)* + ENDBLOCK ) {blockStack.top()->validate();blockStack.pop(); currConf->addRestraintStamp(currRestraintStamp);} + ; +flucqblock : #(FLUCQ {FluctuatingChargeParameters* flucQpars = new FluctuatingChargeParameters(); blockStack.push(flucQpars);} + (assignment)* + ENDBLOCK ) {blockStack.top()->validate();blockStack.pop(); currConf->addFluctuatingChargeParameters(flucQpars);} + ; + +rnemdblock : #(RNEMD {RNEMDParameters* rnemdPars = new RNEMDParameters(); blockStack.push(rnemdPars);} + (assignment)* + ENDBLOCK ) {blockStack.top()->validate();blockStack.pop(); currConf->addRNEMDParameters(rnemdPars);} + ; + +minimizerblock : #(MINIMIZER {MinimizerParameters* minimizerPars = new MinimizerParameters(); blockStack.push(minimizerPars);} + (assignment)* + ENDBLOCK ) {blockStack.top()->validate();blockStack.pop(); currConf->addMinimizerParameters(minimizerPars);} + ; + + moleculeblock : #(MOLECULE {MoleculeStamp* currMoleculeStamp = new MoleculeStamp(); blockStack.push(currMoleculeStamp);} (moleculestatement)* ENDBLOCK ) {blockStack.top()->validate(); blockStack.pop(); currConf->addMoleculeStamp(currMoleculeStamp);} @@ -240,41 +271,40 @@ fragmentstatement : assignment ; fragmentstatement : assignment - ; + ; -doubleNumberTuple returns [vector dvec] +doubleNumberTuple returns [vector dvec] { - RealType dval; -} - : (dval=doubleNumber {dvec.push_back(dval);})+ - ; - -inttuple returns [vector ivec] + RealType dval; +} + : (dval=doubleNumber {dvec.push_back(dval);})+ + ; + + +inttuple returns [vector ivec] { - int ival; + int ival; } - : (ival=intConst {ivec.push_back(ival);})+ - ; + : (ival=intConst {ivec.push_back(ival);})+ + ; protected intConst returns [int ival] - : i1:NUM_INT {ival = lexi_cast(i1->getText());} - | i2:NUM_LONG {ival = lexi_cast(i2->getText());} - ; + : i1:NUM_INT {ival = lexi_cast(i1->getText());} + | i2:NUM_LONG {ival = lexi_cast(i2->getText());} + ; protected -doubleNumber returns [RealType dval] - : - ic:intConst {dval = lexi_cast(ic->getText());} - | fc:floatConst {dval = lexi_cast(fc->getText());} - - ; +doubleNumber returns [RealType dval] + : ic:intConst {dval = lexi_cast(ic->getText());} + | fc:floatConst {dval = lexi_cast(fc->getText());} + ; protected floatConst returns [RealType dval] - : d1:NUM_FLOAT {dval = lexi_cast(d1->getText());} - | d2:NUM_DOUBLE {dval = lexi_cast(d2->getText());} - ; - + : d1:NUM_FLOAT {dval = lexi_cast(d1->getText());} + | d2:NUM_DOUBLE {dval = lexi_cast(d2->getText());} + ; +