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

features of regexp

parent 213e4e4b
No related branches found
No related tags found
No related merge requests found
/*
* RegExpFeatures.h
*
* Created on: Jun 19, 2014
* Author: Jan Travnicek
*/
#ifndef REG_EXP_FEATURES_H_
#define REG_EXP_FEATURES_H_
namespace regexp {
enum class FEATURES {
COMPACT
};
} /* namespace regexp */
#endif /* REG_EXP_FEATURES_H_ */
...@@ -9,6 +9,11 @@ RegExpFromStringParser::RegExpFromStringParser(std::stringstream& input) : m_Reg ...@@ -9,6 +9,11 @@ RegExpFromStringParser::RegExpFromStringParser(std::stringstream& input) : m_Reg
} }
   
RegExp RegExpFromStringParser::parse() { RegExp RegExpFromStringParser::parse() {
return parse(std::set<FEATURES>({FEATURES::COMPACT}));
}
RegExp RegExpFromStringParser::parse(const std::set<FEATURES>& features) {
if(!features.count(FEATURES::COMPACT)) throw alib::AlibException();
RegExpElement* element = this->alternation(); RegExpElement* element = this->alternation();
RegExp regexp(std::move(*element)); RegExp regexp(std::move(*element));
delete element; delete element;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
   
#include "RegExpFromStringLexer.h" #include "RegExpFromStringLexer.h"
#include "../alphabet/SymbolFromStringParser.h" #include "../alphabet/SymbolFromStringParser.h"
#include "RegExpFeatures.h"
   
namespace regexp { namespace regexp {
   
...@@ -32,6 +33,7 @@ class RegExpFromStringParser { ...@@ -32,6 +33,7 @@ class RegExpFromStringParser {
alphabet::SymbolFromStringParser m_SymbolParser; alphabet::SymbolFromStringParser m_SymbolParser;
   
RegExp parse(); RegExp parse();
RegExp parse(const std::set<FEATURES>& features);
RegExp* parsePointer(); RegExp* parsePointer();
public: public:
RegExpFromStringParser(std::stringstream&); RegExpFromStringParser(std::stringstream&);
......
...@@ -14,6 +14,11 @@ ...@@ -14,6 +14,11 @@
namespace regexp { namespace regexp {
   
RegExp RegExpFromXMLParser::parse(std::list<sax::Token>& input) const { RegExp RegExpFromXMLParser::parse(std::list<sax::Token>& input) const {
return parse(input, std::set<FEATURES>({FEATURES::COMPACT}));
}
RegExp RegExpFromXMLParser::parse(std::list<sax::Token>& input, const std::set<FEATURES>& features) const {
if(!features.count(FEATURES::COMPACT)) throw alib::AlibException();
popToken(input, sax::Token::TokenType::START_ELEMENT, "regexp"); popToken(input, sax::Token::TokenType::START_ELEMENT, "regexp");
RegExp regexp; RegExp regexp;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
   
#include "../sax/FromXMLParser.h" #include "../sax/FromXMLParser.h"
#include "RegExp.h" #include "RegExp.h"
#include "RegExpFeatures.h"
#include "RegExpElements.h" #include "RegExpElements.h"
#include "../sax/Token.h" #include "../sax/Token.h"
#include "../alphabet/Symbol.h" #include "../alphabet/Symbol.h"
...@@ -21,7 +22,7 @@ namespace regexp { ...@@ -21,7 +22,7 @@ namespace regexp {
*/ */
class RegExpFromXMLParser : public sax::FromXMLParser { class RegExpFromXMLParser : public sax::FromXMLParser {
void parseAlphabet(std::list<sax::Token>& input, RegExp& regexp) const; void parseAlphabet(std::list<sax::Token>& input, RegExp& regexp) const;
RegExpElement* parseElement(std::list<sax::Token>& input) const; RegExpElement* parseElement(std::list<sax::Token>& input) const;
   
RegExpEpsilon* parseEpsilon(std::list<sax::Token>& input) const; RegExpEpsilon* parseEpsilon(std::list<sax::Token>& input) const;
...@@ -31,6 +32,7 @@ class RegExpFromXMLParser : public sax::FromXMLParser { ...@@ -31,6 +32,7 @@ class RegExpFromXMLParser : public sax::FromXMLParser {
Concatenation* parseConcatenation(std::list<sax::Token> &input) const; Concatenation* parseConcatenation(std::list<sax::Token> &input) const;
   
RegExp parse(std::list<sax::Token>& input) const; RegExp parse(std::list<sax::Token>& input) const;
RegExp parse(std::list<sax::Token>& input, const std::set<FEATURES>& features) const;
RegExp* parsePointer(std::list<sax::Token>& input) const; RegExp* parsePointer(std::list<sax::Token>& input) const;
public: public:
/** /**
......
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