cerr<<"Could not build grammar from sipgrammar.txt"<<endl;
return-1;
}
//now instanciate a parser and assign it collectors and handlers
//This parser expects to build objects which are all inherited from SipElement, and that are stored as shared_ptr.
Parser<shared_ptr<SipElement>>parser(grammar);
//Now, tell our parser where to assign elements when they are found during parsing.
parser.setHandler("SIP-URI",make_fn(&SipUri::create))//tells that whenever a SIP-URI is found, a SipUri object must be created.
->setCollector("user",make_sfn(&SipUri::setUsername))//tells that when a "user" field is found, SipUri::setUsername() is to be called for assigning the "user"
->setCollector("host",make_sfn(&SipUri::setHost))//tells that when host is encountered, use SipUri::setHost() to assign it to our SipUri object.
parser.setHandler("other-param",make_fn(&OtherParam::create))//when other-param is matched, construct an OtherParam object to hold the name and value of the other-params.