diff options
| author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-02-14 23:47:40 +0100 | 
|---|---|---|
| committer | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-02-14 23:47:40 +0100 | 
| commit | ce5ab62b564476dfacba33507f1541166fda2bfb (patch) | |
| tree | 93ecc0278de391f81e2062daf5b4ecde4b392dd2 /src/formats | |
| parent | 919552bad0f3f4db20419d3d3771c724c2ab997f (diff) | |
renamed osdm to osml and osdmx to osxml
Diffstat (limited to 'src/formats')
| -rw-r--r-- | src/formats/osml/OsmlParser.cpp | 57 | ||||
| -rw-r--r-- | src/formats/osml/OsmlParser.hpp | 48 | ||||
| -rw-r--r-- | src/formats/osml/OsmlStreamParser.cpp (renamed from src/formats/osdm/OsdmStreamParser.cpp) | 6 | ||||
| -rw-r--r-- | src/formats/osml/OsmlStreamParser.hpp (renamed from src/formats/osdm/OsdmStreamParser.hpp) | 5 | ||||
| -rw-r--r-- | src/formats/osxml/OsxmlParser.cpp (renamed from src/formats/osdmx/OsdmxParser.cpp) | 0 | ||||
| -rw-r--r-- | src/formats/osxml/OsxmlParser.hpp (renamed from src/formats/osdmx/OsdmxParser.hpp) | 0 | 
6 files changed, 110 insertions, 6 deletions
diff --git a/src/formats/osml/OsmlParser.cpp b/src/formats/osml/OsmlParser.cpp new file mode 100644 index 0000000..4973639 --- /dev/null +++ b/src/formats/osml/OsmlParser.cpp @@ -0,0 +1,57 @@ +/* +    Ousía +    Copyright (C) 2014, 2015  Benjamin Paaßen, Andreas Stöckel + +    This program is free software: you can redistribute it and/or modify +    it under the terms of the GNU General Public License as published by +    the Free Software Foundation, either version 3 of the License, or +    (at your option) any later version. + +    This program is distributed in the hope that it will be useful, +    but WITHOUT ANY WARRANTY; without even the implied warranty of +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +    GNU General Public License for more details. + +    You should have received a copy of the GNU General Public License +    along with this program.  If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <core/parser/generic/ParserStateCallbacks.hpp> +#include <core/parser/generic/ParserStateStack.hpp> + +#include "OsdmParser.hpp" +#include "OsdmStreamParser.hpp" + +namespace ousia { + +namespace { + +/** + * The OsdmParserImplementation class contains the actual implementation of the + * parsing process and is created in the "doParse" function of the OsdmParser. +  + */ +class OsdmParserImplementation : public ParserStateCallbacks { +private: +	/** +	 * OsdmStreamParser instance. +	 */ +	OsdmStreamParser parser; + +	/** +	 * Instance of the ParserStateStack. +	 */ +	ParserStateStack stack; + +public: +	OsdmParserImplementation parser(reader, ctx) : parser(reader), stack(ctx, std::multimap) +}; +} + +void OsdmParser::doParse(CharReader &reader, ParserContext &ctx) +{ +	OsdmParserImplementation parser(reader, ctx); +	parser.parse(); +} + +} diff --git a/src/formats/osml/OsmlParser.hpp b/src/formats/osml/OsmlParser.hpp new file mode 100644 index 0000000..37505b4 --- /dev/null +++ b/src/formats/osml/OsmlParser.hpp @@ -0,0 +1,48 @@ +/* +    Ousía +    Copyright (C) 2014, 2015  Benjamin Paaßen, Andreas Stöckel + +    This program is free software: you can redistribute it and/or modify +    it under the terms of the GNU General Public License as published by +    the Free Software Foundation, either version 3 of the License, or +    (at your option) any later version. + +    This program is distributed in the hope that it will be useful, +    but WITHOUT ANY WARRANTY; without even the implied warranty of +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +    GNU General Public License for more details. + +    You should have received a copy of the GNU General Public License +    along with this program.  If not, see <http://www.gnu.org/licenses/>. +*/ + +/** + * @file OsdmParser.hpp + * + * Contains the parser of the osdm format, the standard plain-text format used + * by Ousía for documents. + * + * @author Andreas Stöckel (astoecke@techfak.uni-bielefeld.de) + */ + +#ifndef _OUSIA_OSDM_PARSER_HPP_ +#define _OUSIA_OSDM_PARSER_HPP_ + +#include <core/parser/Parser.hpp> + +namespace ousia { + +/** + * OsdmParser is a small wrapper implementing the Parser interface. The actual + * parsing is performed with the OsdmStreamParser in conjunction with the + * ParserStateStack. + */ +class OsdmParser : public Parser { +protected: +	void doParse(CharReader &reader, ParserContext &ctx) override; +}; + +} + +#endif /* _OUSIA_OSDM_PARSER_HPP_ */ + diff --git a/src/formats/osdm/OsdmStreamParser.cpp b/src/formats/osml/OsmlStreamParser.cpp index 8cb8caf..6a55f12 100644 --- a/src/formats/osdm/OsdmStreamParser.cpp +++ b/src/formats/osml/OsmlStreamParser.cpp @@ -28,7 +28,7 @@ namespace ousia {  /**   * Plain format default tokenizer.   */ -class PlainFormatTokens : public DynamicTokenizer { +class PlainFormatTokens : public Tokenizer {  public:  	/**  	 * Id of the backslash token. @@ -418,7 +418,7 @@ OsdmStreamParser::State OsdmStreamParser::parseCommand(size_t start)  void OsdmStreamParser::parseBlockComment()  { -	DynamicToken token; +	Token token;  	size_t depth = 1;  	while (tokenizer.read(reader, token)) {  		if (token.type == Tokens.BlockCommentEnd) { @@ -488,7 +488,7 @@ OsdmStreamParser::State OsdmStreamParser::parse()  	DataHandler handler;  	// Read tokens until the outer loop should be left -	DynamicToken token; +	Token token;  	while (tokenizer.peek(reader, token)) {  		const TokenTypeId type = token.type; diff --git a/src/formats/osdm/OsdmStreamParser.hpp b/src/formats/osml/OsmlStreamParser.hpp index 48d8fb7..84674c0 100644 --- a/src/formats/osdm/OsdmStreamParser.hpp +++ b/src/formats/osml/OsmlStreamParser.hpp @@ -32,8 +32,7 @@  #include <stack>  #include <core/common/Variant.hpp> - -#include "DynamicTokenizer.hpp" +#include <core/parser/utils/Tokenizer.hpp>  namespace ousia { @@ -198,7 +197,7 @@ private:  	/**  	 * Tokenizer instance used to read individual tokens from the text.  	 */ -	DynamicTokenizer tokenizer; +	Tokenizer tokenizer;  	/**  	 * Stack containing the current commands. diff --git a/src/formats/osdmx/OsdmxParser.cpp b/src/formats/osxml/OsxmlParser.cpp index c46d9de..c46d9de 100644 --- a/src/formats/osdmx/OsdmxParser.cpp +++ b/src/formats/osxml/OsxmlParser.cpp diff --git a/src/formats/osdmx/OsdmxParser.hpp b/src/formats/osxml/OsxmlParser.hpp index c8b6302..c8b6302 100644 --- a/src/formats/osdmx/OsdmxParser.hpp +++ b/src/formats/osxml/OsxmlParser.hpp  | 
