mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 05:51:27 +12:00
Added some parser exceptions.
This commit is contained in:
parent
901d16a96f
commit
2ccbfeff47
9 changed files with 201 additions and 30 deletions
11
parser.cpp
11
parser.cpp
|
@ -1,6 +1,7 @@
|
|||
#include "parser.h"
|
||||
#include "scanner.h"
|
||||
#include "token.h"
|
||||
#include "exceptions.h"
|
||||
#include <sstream>
|
||||
|
||||
namespace YAML
|
||||
|
@ -62,23 +63,23 @@ namespace YAML
|
|||
// . Should be of the form 'major.minor' (like a version number)
|
||||
void Parser::HandleYamlDirective(const std::vector <std::string>& params)
|
||||
{
|
||||
if(params.empty())
|
||||
return; // TODO: throw? (or throw on params.size() > 1?)
|
||||
if(params.size() != 1)
|
||||
throw BadYAMLDirective();
|
||||
|
||||
std::stringstream str(params[0]);
|
||||
str >> m_state.version.major;
|
||||
str.get();
|
||||
str >> m_state.version.minor;
|
||||
if(!str)
|
||||
return; // TODO: throw? (or throw if there are any more characters in the stream?)
|
||||
throw BadYAMLDirective(); // TODO: or throw if there are any more characters in the stream?
|
||||
|
||||
// TODO: throw on major > 1? warning on major == 1, minor > 1?
|
||||
// TODO: throw on major > 1? warning on major == 1, minor > 2?
|
||||
}
|
||||
|
||||
void Parser::HandleTagDirective(const std::vector <std::string>& params)
|
||||
{
|
||||
if(params.size() != 2)
|
||||
return; // TODO: throw?
|
||||
throw BadTAGDirective();
|
||||
|
||||
std::string handle = params[0], prefix = params[1];
|
||||
m_state.tags[handle] = prefix;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue