OgreScriptLexer.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __ScriptLexer_H_
#define __ScriptLexer_H_
#include "OgrePrerequisites.h"
#include "OgreSharedPtr.h"
#include "OgreDataStream.h"
#include "OgreStringConverter.h"
#include "OgreHeaderPrefix.h"
namespace Ogre {
enum{
TID_LBRACKET = 0, // {
TID_RBRACKET, // }
TID_COLON, // :
TID_VARIABLE, // $...
TID_WORD, // *
TID_QUOTE, // "*"
TID_NEWLINE, // \n
TID_UNKNOWN,
TID_END
};
struct ScriptToken
{
String lexeme, file;
uint32 type;
uint32 line;
};
typedef SharedPtr<ScriptToken> ScriptTokenPtr;
typedef vector<ScriptTokenPtr>::type ScriptTokenList;
typedef SharedPtr<ScriptTokenList> ScriptTokenListPtr;
class _OgreExport ScriptLexer : public ScriptCompilerAlloc
{
public:
ScriptLexer();
virtual ~ScriptLexer() {}
ScriptTokenListPtr tokenize(const String &str, const String &source);
private: // Private utility operations
void setToken(const String &lexeme, uint32 line, const String &source, ScriptTokenList *tokens);
bool isWhitespace(Ogre::String::value_type c) const;
bool isNewline(Ogre::String::value_type c) const;
};
}
#include "OgreHeaderSuffix.h"
#endif
Ogre::ScriptTokenList
vector< ScriptTokenPtr >::type ScriptTokenList
Definition: OgreScriptLexer.h:75
Ogre::TID_RBRACKET
Definition: OgreScriptLexer.h:52
Ogre::ScriptLexer
Definition: OgreScriptLexer.h:78
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::TID_VARIABLE
Definition: OgreScriptLexer.h:54
OgreSharedPtr.h
Ogre::vector::type
std::vector< T, A > type
Definition: OgrePrerequisites.h:494
Ogre::ScriptToken::type
uint32 type
This is the id associated with the lexeme, which comes from a lexeme-token id mapping.
Definition: OgreScriptLexer.h:70
Ogre::ScriptToken
This struct represents a token, which is an ID&#39;d lexeme from the parsing input stream.
Definition: OgreScriptLexer.h:65
Ogre::ScriptLexer::~ScriptLexer
virtual ~ScriptLexer()
Definition: OgreScriptLexer.h:82
Ogre::TID_END
Definition: OgreScriptLexer.h:59
Ogre::ScriptTokenListPtr
SharedPtr< ScriptTokenList > ScriptTokenListPtr
Definition: OgreScriptLexer.h:76
OgreDataStream.h
OgrePrerequisites.h
OgreStringConverter.h
Ogre::ScriptTokenPtr
SharedPtr< ScriptToken > ScriptTokenPtr
Definition: OgreScriptLexer.h:74
Ogre::TID_LBRACKET
Definition: OgreScriptLexer.h:51
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::TID_WORD
Definition: OgreScriptLexer.h:55
OgreHeaderSuffix.h
Ogre::uint32
unsigned int uint32
Definition: OgrePlatform.h:359
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::ScriptToken::lexeme
String lexeme
This is the lexeme for this token.
Definition: OgreScriptLexer.h:68
Ogre::TID_COLON
Definition: OgreScriptLexer.h:53
Ogre::SharedPtr
Reference-counted shared pointer, used for objects where implicit destruction is required.
Definition: OgrePrerequisites.h:310
Ogre::TID_UNKNOWN
Definition: OgreScriptLexer.h:58
OgreHeaderPrefix.h
Ogre::ScriptToken::file
String file
Definition: OgreScriptLexer.h:68
Ogre::TID_NEWLINE
Definition: OgreScriptLexer.h:57
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58
Ogre::ScriptToken::line
uint32 line
This holds the line number of the input stream where the token was found.
Definition: OgreScriptLexer.h:72
Ogre::TID_QUOTE
Definition: OgreScriptLexer.h:56

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.