diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-03-02 00:34:15 +0100 |
---|---|---|
committer | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-03-02 00:34:15 +0100 |
commit | 596fdab71b8bd116e20e33647d68f1d7a567696e (patch) | |
tree | cba0b3a79d9608265d9171942324935931d75421 /src/core/common/Utils.hpp | |
parent | 8197dc488926e8645efb47e60d0988a6a65fc15f (diff) |
Wrote isUserDefinedToken function which checks whether a token is a valid user defined token and added unit tests
Diffstat (limited to 'src/core/common/Utils.hpp')
-rw-r--r-- | src/core/common/Utils.hpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/core/common/Utils.hpp b/src/core/common/Utils.hpp index 82a8f8c..25a4de5 100644 --- a/src/core/common/Utils.hpp +++ b/src/core/common/Utils.hpp @@ -103,6 +103,25 @@ public: static bool isNamespacedIdentifier(const std::string &name); /** + * Returns true if the given characters form a valid user-defined token. + * This function returns true under the following circumstances: + * <ul> + * <li>The given token is not empty</li> + * <li>The given token starts and ends with a non-alphanumeric character + * </li> + * <li>The token is none of the following character sequences (which are + * special in OSML): + * <ul> + * <li>'{', '}' or any combined repetition of these characters</li> + * <li>'\', '{!', '<\', '\>'</li> + * <li>'%', '%{', '}%'</li> + * </ul> + * </li> + * </ul> + */ + static bool isUserDefinedToken(const std::string &token); + + /** * Returns true if the given character is a linebreak character. */ static bool isLinebreak(const char c) { return (c == '\n') || (c == '\r'); } |