Ver Fonte

Minor changes in the tokenizer

Panagiotis Christopoulos Charitos há 15 anos atrás
pai
commit
c8cb445168
2 ficheiros alterados com 26 adições e 61 exclusões
  1. 18 1
      src/Util/Tokenizer/Parser.h
  2. 8 60
      src/Util/Tokenizer/Scanner.h

+ 18 - 1
src/Util/Tokenizer/Parser.h

@@ -37,7 +37,8 @@ namespace Parser {
  * @param arr The array that the func returns the numbers
  * @param arr The array that the func returns the numbers
  * @return True if the parsing was successful
  * @return True if the parsing was successful
 */
 */
-template <typename Type> bool parseArrOfNumbers(Scanner& scanner, bool bracket, bool signs, uint size, Type* arr)
+template <typename Type>
+bool parseArrOfNumbers(Scanner& scanner, bool bracket, bool signs, uint size, Type* arr)
 {
 {
 	const Scanner::Token* token;
 	const Scanner::Token* token;
 
 
@@ -107,6 +108,22 @@ template <typename Type> bool parseArrOfNumbers(Scanner& scanner, bool bracket,
 }
 }
 
 
 
 
+//======================================================================================================================
+// parseSignedNumber                                                                                                   =
+//======================================================================================================================
+/**
+ * Parse a single number
+ * @param scanner The scanner that we will use
+ * @param out The output number
+ * @return True on success
+ */
+template <typename Type>
+bool parseSignedNumber(Scanner& scanner, Type& out)
+{
+	return parseArrOfNumbers(scanner, false, true, 1, &out);
+}
+
+
 } // end namespace Parser
 } // end namespace Parser
 
 
 #endif
 #endif

+ 8 - 60
src/Util/Tokenizer/Scanner.h

@@ -90,10 +90,10 @@ class Scanner
 				 * @name Accessors
 				 * @name Accessors
 				 */
 				 */
 				/**@{*/
 				/**@{*/
-				char getChar() const; ///< Access the data as C char
-				ulong getInt() const; ///< Access the data as unsigned int
-				float getFloat() const; ///< Access the data as double
-				const char* getString() const; ///< Access the data as C string
+				char getChar() const {return char_;} ///< Access the data as C char
+				ulong getInt() const {return int_;} ///< Access the data as unsigned int
+				double getFloat() const {return float_;} ///< Access the data as double
+				const char* getString() const {return string;} ///< Access the data as C string
 				/**@}*/
 				/**@}*/
 		}; // end class TokenDataVal
 		}; // end class TokenDataVal
 
 
@@ -112,7 +112,7 @@ class Scanner
 			public:
 			public:
 				Token(): code(TC_ERROR) {}
 				Token(): code(TC_ERROR) {}
 				Token(const Token& b);
 				Token(const Token& b);
-				const char* getString() const;
+				const char* getString() const {return asString;}
 				string getInfoStr() const; ///< Get a string with the info of the token
 				string getInfoStr() const; ///< Get a string with the info of the token
 				void print() const; ///< Print info of the token
 				void print() const; ///< Print info of the token
 
 
@@ -188,17 +188,17 @@ class Scanner
 		/**
 		/**
 		 * Accessor for the current token
 		 * Accessor for the current token
 		 */
 		 */
-		const Token& getCrntToken() const;
+		const Token& getCrntToken() const {return crntToken;}
 
 
 		/**
 		/**
 		 * Get the name of the input stream
 		 * Get the name of the input stream
 		 */
 		 */
-		const char* getScriptName() const;
+		const char* getScriptName() const {return scriptName;}
 
 
 		/**
 		/**
 		 * Get the current line the Scanner is processing
 		 * Get the current line the Scanner is processing
 		 */
 		 */
-		int getLineNumber() const;
+		int getLineNumber() const {return lineNmbr;}
 
 
 
 
 	//====================================================================================================================
 	//====================================================================================================================
@@ -286,58 +286,6 @@ class Scanner
 }; // end class Scanner
 }; // end class Scanner
 
 
 
 
-//======================================================================================================================
-// Inlines                                                                                                             =
-//======================================================================================================================
-
-inline char Scanner::TokenDataVal::getChar() const
-{
-	return char_;
-}
-
-
-inline ulong Scanner::TokenDataVal::getInt() const
-{
-	return int_;
-}
-
-
-inline float Scanner::TokenDataVal::getFloat() const
-{
-	return float_;
-}
-
-
-inline const char* Scanner::TokenDataVal::getString() const
-{
-	return string;
-}
-
-
-inline const Scanner::Token& Scanner::getCrntToken() const
-{
-	return crntToken;
-}
-
-
-inline const char* Scanner::getScriptName() const
-{
-	return scriptName;
-}
-
-
-inline int Scanner::getLineNumber() const
-{
-	return lineNmbr;
-}
-
-
-inline const char* Scanner::Token::getString() const
-{
-	return asString;
-}
-
-
 inline Scanner::AsciiFlag Scanner::lookupAscii(char ch_)
 inline Scanner::AsciiFlag Scanner::lookupAscii(char ch_)
 {
 {
 	return asciiLookupTable[(int)ch_];
 	return asciiLookupTable[(int)ch_];