From eefefdc97cd49d830cf0b72b15cb08464a3745f2 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Tue, 10 Feb 2015 13:11:23 +0100 Subject: Fully implemented and tested begin/end handling --- src/plugins/plain/PlainFormatStreamReader.hpp | 41 +++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 5 deletions(-) (limited to 'src/plugins/plain/PlainFormatStreamReader.hpp') diff --git a/src/plugins/plain/PlainFormatStreamReader.hpp b/src/plugins/plain/PlainFormatStreamReader.hpp index 4a11b8e..a14ca10 100644 --- a/src/plugins/plain/PlainFormatStreamReader.hpp +++ b/src/plugins/plain/PlainFormatStreamReader.hpp @@ -107,7 +107,17 @@ public: /** * The end of the stream has been reached. */ - END + END, + + /** + * Returned from internal functions if nothing should be done. + */ + NONE, + + /** + * Returned from internal function to indicate irrecoverable errors. + */ + ERROR }; /** @@ -159,10 +169,10 @@ public: * @param inRangeField is set to true if we currently inside the outer * field of the command. */ - Command(const Variant &name, const Variant &arguments, bool hasRange, + Command(Variant name, Variant arguments, bool hasRange, bool inField, bool inRangeField) - : name(name), - arguments(arguments), + : name(std::move(name)), + arguments(std::move(arguments)), hasRange(hasRange), inField(inField), inRangeField(inRangeField) @@ -216,13 +226,34 @@ private: */ Variant parseIdentifier(size_t start); + /** + * Function used internally to handle the special "\begin" command. + */ + State parseBeginCommand(); + + /** + * Function used internally to handle the special "\end" command. + */ + State parseEndCommand(); + + /** + * Pushes the parsed command onto the command stack. + */ + void pushCommand(Variant commandName, Variant commandArguments, bool hasRange); + + /** + * Parses the command arguments. + */ + Variant parseCommandArguments(Variant commandArgName); + /** * Function used internally to parse a command. * * @param start is the start byte offset of the command (including the * backslash) + * @return true if a command was actuall parsed, false otherwise. */ - void parseCommand(size_t start); + State parseCommand(size_t start); /** * Function used internally to parse a block comment. -- cgit v1.2.3