diff options
| author | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2015-02-08 21:42:58 +0100 | 
|---|---|---|
| committer | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2015-02-08 21:42:58 +0100 | 
| commit | fbaad57be8ddf3f90eb13551cc7eb18674b3efa2 (patch) | |
| tree | 0c7390346731ebfd739f273b7f7d624608fa3be5 /src/core | |
| parent | 616e9bfeee29556952ebdccf57cb1fd304744acb (diff) | |
| parent | bb8c69fbdeba3fa95fc780552252525b222ceb5a (diff) | |
Merge branch 'master' of somweyr.de:ousia
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/common/CharReader.cpp | 12 | ||||
| -rw-r--r-- | src/core/common/CharReader.hpp | 9 | ||||
| -rw-r--r-- | src/core/common/Utils.cpp | 4 | ||||
| -rw-r--r-- | src/core/common/Utils.hpp | 16 | ||||
| -rw-r--r-- | src/core/common/VariantReader.hpp | 1 | 
5 files changed, 36 insertions, 6 deletions
| diff --git a/src/core/common/CharReader.cpp b/src/core/common/CharReader.cpp index 5b9b1d4..4d3638c 100644 --- a/src/core/common/CharReader.cpp +++ b/src/core/common/CharReader.cpp @@ -468,6 +468,18 @@ bool CharReader::read(char &c)  	return res;  } +bool CharReader::expect(char c) +{ +	char actual = 0; +	peek(actual); +	if (c == actual) { +		consumePeek(); +		return true; +	} +	resetPeek(); +	return false; +} +  void CharReader::resetPeek()  {  	if (!coherent) { diff --git a/src/core/common/CharReader.hpp b/src/core/common/CharReader.hpp index cbfeaf2..64c80af 100644 --- a/src/core/common/CharReader.hpp +++ b/src/core/common/CharReader.hpp @@ -490,6 +490,15 @@ public:  	bool read(char &c);  	/** +	 * Peeks a character, checks whether this character equals the given +	 * character -- and if yes -- consumes the peek, otherwise resets it. +	 * +	 * @param c is the character that is expected. +	 * @return true if this character is actually next. +	 */ +	bool expect(char c); + +	/**  	 * Resets the peek pointer to the "read" pointer.  	 */  	void resetPeek(); diff --git a/src/core/common/Utils.cpp b/src/core/common/Utils.cpp index e5e2d39..563fe2a 100644 --- a/src/core/common/Utils.cpp +++ b/src/core/common/Utils.cpp @@ -35,10 +35,10 @@ bool Utils::isIdentifier(const std::string &name)  {  	bool first = true;  	for (char c : name) { -		if (first && !(isAlphabetic(c) || c == '_')) { +		if (first && !isIdentifierStartCharacter(c)) {  			return false;  		} -		if (!first && !(isAlphanumeric(c) || c == '_' || c == '-')) { +		if (!first && !isIdentifierCharacter(c)) {  			return false;  		}  		first = false; diff --git a/src/core/common/Utils.hpp b/src/core/common/Utils.hpp index 457d446..2c8a5b3 100644 --- a/src/core/common/Utils.hpp +++ b/src/core/common/Utils.hpp @@ -58,15 +58,23 @@ public:  	}  	/** -	 * Returns true if the given character is in [A-Za-z_] +	 * Returns true if the given character is in [A-Za-z].  	 */ -	static bool isIdentifierStart(const char c) +	static bool isIdentifierStartCharacter(const char c)  	{ -		return isAlphabetic(c) || (c == '_'); +		return isAlphabetic(c);  	}  	/** -	 * Returns true if the given character is in [A-Za-z_][A-Za-z0-9_-]* +	 * Returns true if the given character is in [A-Za-z0-9_-]. +	 */ +	static bool isIdentifierCharacter(const char c) +	{ +		return isAlphanumeric(c) || (c == '_') || (c == '-'); +	} + +	/** +	 * Returns true if the given character is in [A-Za-z][A-Za-z0-9_-]*  	 */  	static bool isIdentifier(const std::string &name); diff --git a/src/core/common/VariantReader.hpp b/src/core/common/VariantReader.hpp index 7f00251..6b157d8 100644 --- a/src/core/common/VariantReader.hpp +++ b/src/core/common/VariantReader.hpp @@ -195,6 +195,7 @@ public:  	static std::pair<bool, Variant::mapType> parseObject(CharReader &reader,  	                                                     Logger &logger,  	                                                     char delim = 0); +  	/**  	 * Parses a Cardinality. A Cardinality is specified as a list of Ranges,  	 * separated by commas and enclosed in curly braces. The ranges can be | 
