OgreScriptLexer.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 
29 #ifndef __ScriptLexer_H_
30 #define __ScriptLexer_H_
31 
32 #include "OgrePrerequisites.h"
33 #include "OgreSharedPtr.h"
34 #include "OgreDataStream.h"
35 #include "OgreStringConverter.h"
36 #include "OgreHeaderPrefix.h"
37 
38 namespace Ogre {
39 
50  enum{
51  TID_LBRACKET = 0, // {
53  TID_COLON, // :
54  TID_VARIABLE, // $...
55  TID_WORD, // *
56  TID_QUOTE, // "*"
57  TID_NEWLINE, // \n
60  };
61 
65  struct ScriptToken
66  {
73  };
77 
79  {
80  public:
81  ScriptLexer();
82  virtual ~ScriptLexer() {}
83 
85  ScriptTokenListPtr tokenize(const String &str, const String &source);
86  private: // Private utility operations
87  void setToken(const String &lexeme, uint32 line, const String &source, ScriptTokenList *tokens);
88  bool isWhitespace(Ogre::String::value_type c) const;
89  bool isNewline(Ogre::String::value_type c) const;
90  };
91 
94 }
95 
96 #include "OgreHeaderSuffix.h"
97 
98 #endif
OgreSharedPtr.h
OgreHeaderSuffix.h
Ogre::TID_UNKNOWN
Definition: OgreScriptLexer.h:58
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::ScriptLexer::~ScriptLexer
virtual ~ScriptLexer()
Definition: OgreScriptLexer.h:82
Ogre::TID_WORD
Definition: OgreScriptLexer.h:55
Ogre::ScriptToken::lexeme
String lexeme
This is the lexeme for this token.
Definition: OgreScriptLexer.h:68
Ogre::ScriptTokenListPtr
SharedPtr< ScriptTokenList > ScriptTokenListPtr
Definition: OgreScriptLexer.h:76
Ogre::ScriptTokenList
vector< ScriptTokenPtr >::type ScriptTokenList
Definition: OgreScriptLexer.h:75
Ogre::TID_VARIABLE
Definition: OgreScriptLexer.h:54
Ogre::uint32
unsigned int uint32
Definition: OgrePlatform.h:359
OgreStringConverter.h
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::ScriptToken
This struct represents a token, which is an ID'd lexeme from the parsing input stream.
Definition: OgreScriptLexer.h:65
Ogre::ScriptTokenPtr
SharedPtr< ScriptToken > ScriptTokenPtr
Definition: OgreScriptLexer.h:74
Ogre::vector::type
std::vector< T, A > type
Definition: OgrePrerequisites.h:494
OgreHeaderPrefix.h
OgrePrerequisites.h
Ogre::TID_COLON
Definition: OgreScriptLexer.h:53
Ogre::ScriptLexer
Definition: OgreScriptLexer.h:78
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
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_NEWLINE
Definition: OgreScriptLexer.h:57
Ogre::TID_RBRACKET
Definition: OgreScriptLexer.h:52
Ogre::SharedPtr
Reference-counted shared pointer, used for objects where implicit destruction is required.
Definition: OgrePrerequisites.h:310
Ogre::TID_END
Definition: OgreScriptLexer.h:59
Ogre::ScriptToken::file
String file
Definition: OgreScriptLexer.h:68
Ogre::TID_QUOTE
Definition: OgreScriptLexer.h:56
Ogre::TID_LBRACKET
Definition: OgreScriptLexer.h:51
OgreDataStream.h
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

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