Skip to content
Snippets Groups Projects
Commit 73f092f3 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

reuse label parser in symbol parser

parent 5ed8e7ed
No related branches found
No related tags found
No related merge requests found
......@@ -9,16 +9,16 @@
#include "../sax/ParserException.h"
#include "BlankSymbol.h"
#include "LabeledSymbol.h"
#include "../label/StringLabel.h"
#include "../label/Label.h"
#include "../alphabet/LabeledSymbol.h"
#include "../FromXMLParsers.h"
 
namespace alphabet {
 
Symbol SymbolFromXMLParser::parse(std::list<sax::Token>& input) const {
if(isToken(input, sax::Token::START_ELEMENT, "LabeledSymbol")) {
popToken(input, sax::Token::START_ELEMENT, "LabeledSymbol");
label::Label data = parseContent(input);
label::Label data = alib::FromXMLParsers::labelParser.parse(input);
popToken(input, sax::Token::END_ELEMENT, "LabeledSymbol");
return Symbol(LabeledSymbol(data));
} else if(isToken(input, sax::Token::START_ELEMENT, "BlankSymbol")) {
......@@ -30,14 +30,4 @@ Symbol SymbolFromXMLParser::parse(std::list<sax::Token>& input) const {
}
}
 
label::Label SymbolFromXMLParser::parseContent(std::list<sax::Token>& input) const {
if (isTokenType(input, sax::Token::CHARACTER)) {
label::Label data(label::StringLabel(input.front().getData()));
input.pop_front();
return data;
} else {
throw sax::ParserException(sax::Token("", sax::Token::CHARACTER), input.front());
}
}
} /* namespace string */
......@@ -20,8 +20,6 @@ namespace alphabet {
* Parser used to get String from XML parsed into list of tokens.
*/
class SymbolFromXMLParser : public sax::FromXMLParser {
label::Label parseContent(std::list<sax::Token>& input) const;
public:
/**
* Parses the XML and returns regular expression. The input is destroyed in the process.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment