ソースを参照

Working on a new codding style. Im such an idiot

Panagiotis Christopoulos Charitos 16 年 前
コミット
221113d36b

+ 34 - 31
build/debug/Makefile

@@ -5,8 +5,8 @@ PHFLAGS = $(CFLAGS) -x c++-header
 LFLAGS = $(COMMONFLAGS) -rdynamic -L../../../bullet_svn/src/BulletSoftBody -L../../../bullet_svn/src/BulletDynamics -L../../../bullet_svn/src/BulletCollision -L../../../bullet_svn/src/LinearMath -Wl,-Bstatic -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lSDL_image -lGLU -Wl,-Bdynamic -lSDL -lpthread -lGL -ljpeg -lpng -ltiff -lesd -lcaca -laa -ldirectfb -laudio -lpulse-simple
 EXECUTABLE = AnKi.bin
 INCPATH = -I../../src/math/ -I../../src/tokenizer/ -I../../src/uncategorized/ -I../../src/ -I../../src/renderer/ -I../../src/scene/ -I../../src/ui/ -I../../src/resources/ -I../../src/utility/ -I../../src/controllers/ -I../../../bullet_svn/src/ 
-SOURCES = ../../src/tokenizer//scanner.cpp ../../src/uncategorized//input.cpp ../../src/uncategorized//skybox.cpp ../../src/uncategorized//particles.cpp ../../src/uncategorized//memory.cpp ../../src/uncategorized//engine_class.cpp ../../src/uncategorized//collision.cpp ../../src/uncategorized//map.cpp ../../src//main.cpp ../../src/renderer//r_ms.cpp ../../src/renderer//r_pps_hdr.cpp ../../src/renderer//r_pps.cpp ../../src/renderer//r_is_shadows.cpp ../../src/renderer//r_bs.cpp ../../src/renderer//r_ms_earlyz.cpp ../../src/renderer//renderer.cpp ../../src/renderer//r_pps_ssao.cpp ../../src/renderer//r_is.cpp ../../src/renderer//r_dbg.cpp ../../src/renderer//r_pps_lscatt.cpp ../../src/renderer//r_bs2.cpp ../../src/scene//mesh_node.cpp ../../src/scene//skel_node.cpp ../../src/scene//light.cpp ../../src/scene//skel_model_node.cpp ../../src/scene//node.cpp ../../src/scene//camera.cpp ../../src/scene//scene.cpp ../../src/ui//ui.cpp ../../src/resources//material.cpp ../../src/resources//texture.cpp ../../src/resources//skel_anim.cpp ../../src/resources//extension.cpp ../../src/resources//shader_parser.cpp ../../src/resources//skeleton.cpp ../../src/resources//resource.cpp ../../src/resources//light_props.cpp ../../src/resources//mesh.cpp ../../src/resources//shader_prog.cpp ../../src/utility//app.cpp ../../src/utility//common.cpp ../../src/utility//util.cpp ../../src/controllers//controller.cpp ../../src/controllers//skel_anim_ctrl.cpp 
-OBJECTS = scanner.o input.o skybox.o particles.o memory.o engine_class.o collision.o map.o main.o r_ms.o r_pps_hdr.o r_pps.o r_is_shadows.o r_bs.o r_ms_earlyz.o renderer.o r_pps_ssao.o r_is.o r_dbg.o r_pps_lscatt.o r_bs2.o mesh_node.o skel_node.o light.o skel_model_node.o node.o camera.o scene.o ui.o material.o texture.o skel_anim.o extension.o shader_parser.o skeleton.o resource.o light_props.o mesh.o shader_prog.o app.o common.o util.o controller.o skel_anim_ctrl.o 
+SOURCES = ../../src/tokenizer//Scanner.cpp ../../src/uncategorized//input.cpp ../../src/uncategorized//skybox.cpp ../../src/uncategorized//particles.cpp ../../src/uncategorized//memory.cpp ../../src/uncategorized//engine_class.cpp ../../src/uncategorized//collision.cpp ../../src/uncategorized//map.cpp ../../src//main.cpp ../../src/renderer//r_ms.cpp ../../src/renderer//r_pps_hdr.cpp ../../src/renderer//r_pps.cpp ../../src/renderer//r_is_shadows.cpp ../../src/renderer//r_bs.cpp ../../src/renderer//r_ms_earlyz.cpp ../../src/renderer//renderer.cpp ../../src/renderer//r_pps_ssao.cpp ../../src/renderer//r_is.cpp ../../src/renderer//r_dbg.cpp ../../src/renderer//r_pps_lscatt.cpp ../../src/renderer//r_bs2.cpp ../../src/scene//mesh_node.cpp ../../src/scene//skel_node.cpp ../../src/scene//light.cpp ../../src/scene//skel_model_node.cpp ../../src/scene//node.cpp ../../src/scene//camera.cpp ../../src/scene//scene.cpp ../../src/ui//ui.cpp ../../src/resources//material.cpp ../../src/resources//texture.cpp ../../src/resources//skel_anim.cpp ../../src/resources//extension.cpp ../../src/resources//skeleton.cpp ../../src/resources//resource.cpp ../../src/resources//ShaderParser.cpp ../../src/resources//light_props.cpp ../../src/resources//mesh.cpp ../../src/resources//shader_prog.cpp ../../src/utility//app.cpp ../../src/utility//common.cpp ../../src/utility//util.cpp ../../src/controllers//controller.cpp ../../src/controllers//skel_anim_ctrl.cpp 
+OBJECTS = Scanner.o input.o skybox.o particles.o memory.o engine_class.o collision.o map.o main.o r_ms.o r_pps_hdr.o r_pps.o r_is_shadows.o r_bs.o r_ms_earlyz.o renderer.o r_pps_ssao.o r_is.o r_dbg.o r_pps_lscatt.o r_bs2.o mesh_node.o skel_node.o light.o skel_model_node.o node.o camera.o scene.o ui.o material.o texture.o skel_anim.o extension.o skeleton.o resource.o ShaderParser.o light_props.o mesh.o shader_prog.o app.o common.o util.o controller.o skel_anim_ctrl.o 
 PRECOMPILED_HEADERS = 
 
 all: $(PRECOMPILED_HEADERS) $(SOURCES) $(EXECUTABLE)
@@ -16,11 +16,11 @@ $(EXECUTABLE): $(OBJECTS)
 	@$(CXX) $(OBJECTS) $(LFLAGS) -o $(EXECUTABLE)
 	@echo All Done!
 
-scanner.o: ../../src/tokenizer//scanner.cpp \
- ../../src/tokenizer//scanner.h ../../src/utility/common.h \
+Scanner.o: ../../src/tokenizer//Scanner.cpp \
+ ../../src/tokenizer//Scanner.h ../../src/utility/common.h \
  ../../src/uncategorized/memory.h
-	@echo Compiling ../../src/tokenizer//scanner.cpp...
-	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/tokenizer//scanner.cpp -o scanner.o
+	@echo Compiling ../../src/tokenizer//Scanner.cpp...
+	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/tokenizer//Scanner.cpp -o Scanner.o
 
 input.o: ../../src/uncategorized//input.cpp \
  ../../src/uncategorized//input.h ../../src/utility/common.h \
@@ -118,8 +118,8 @@ map.o: ../../src/uncategorized//map.cpp ../../src/uncategorized//map.h \
  ../../src/renderer/vbo.h ../../src/resources/resource.h \
  ../../src/uncategorized/engine_class.h ../../src/utility/util.h \
  ../../src/utility/common.h ../../src/uncategorized/collision.h \
- ../../src/tokenizer/scanner.h ../../src/tokenizer/parser.h \
- ../../src/tokenizer/scanner.h ../../src/resources/resource.h \
+ ../../src/tokenizer/Scanner.h ../../src/tokenizer/parser.h \
+ ../../src/tokenizer/Scanner.h ../../src/resources/resource.h \
  ../../src/scene/camera.h ../../src/scene/node.h
 	@echo Compiling ../../src/uncategorized//map.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/uncategorized//map.cpp -o map.o
@@ -147,7 +147,7 @@ main.o: ../../src//main.cpp ../../src/utility/common.h \
  ../../src/scene/light.h ../../src/scene/camera.h \
  ../../src/resources/material.h ../../src/resources/resource.h \
  ../../src/scene/scene.h ../../src/uncategorized/skybox.h \
- ../../src/tokenizer/scanner.h ../../src/uncategorized/map.h \
+ ../../src/tokenizer/Scanner.h ../../src/uncategorized/map.h \
  ../../src/uncategorized/collision.h ../../src/scene/mesh_node.h \
  ../../src/scene/skel_model_node.h ../../src/scene/mesh_node.h \
  ../../src/resources/skel_anim.h ../../src/controllers/mesh_skel_ctrl.h \
@@ -211,6 +211,12 @@ main.o: ../../src//main.cpp ../../src/utility/common.h \
  ../../../bullet_svn/src/BulletCollision/CollisionShapes/btTriangleMeshShape.h \
  ../../../bullet_svn/src/BulletCollision/CollisionShapes/btOptimizedBvh.h \
  ../../../bullet_svn/src/BulletCollision/BroadphaseCollision/btQuantizedBvh.h \
+ ../../../bullet_svn/src/BulletCollision/CollisionShapes/btTriangleInfoMap.h \
+ ../../../bullet_svn/src/LinearMath/btHashMap.h \
+ ../../../bullet_svn/src/LinearMath/btAlignedObjectArray.h \
+ ../../../bullet_svn/src/LinearMath/btSerializer.h \
+ ../../../bullet_svn/src/LinearMath/btStackAlloc.h \
+ ../../../bullet_svn/src/LinearMath/btHashMap.h \
  ../../../bullet_svn/src/BulletCollision/CollisionShapes/btTriangleMeshShape.h \
  ../../../bullet_svn/src/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h \
  ../../../bullet_svn/src/BulletCollision/CollisionShapes/btCompoundShape.h \
@@ -239,9 +245,6 @@ main.o: ../../src//main.cpp ../../src/utility/common.h \
  ../../../bullet_svn/src/LinearMath/btQuickprof.h \
  ../../../bullet_svn/src/LinearMath/btIDebugDraw.h \
  ../../../bullet_svn/src/LinearMath/btSerializer.h \
- ../../../bullet_svn/src/LinearMath/btStackAlloc.h \
- ../../../bullet_svn/src/LinearMath/btHashMap.h \
- ../../../bullet_svn/src/LinearMath/btAlignedObjectArray.h \
  ../../../bullet_svn/src/btBulletDynamicsCommon.h \
  ../../../bullet_svn/src/btBulletCollisionCommon.h \
  ../../../bullet_svn/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h \
@@ -651,7 +654,7 @@ skel_model_node.o: ../../src/scene//skel_model_node.cpp \
  ../../src/math/m_misc.inl.h ../../src/resources/material.h \
  ../../src/resources/resource.h ../../src/uncategorized/engine_class.h \
  ../../src/utility/util.h ../../src/utility/common.h \
- ../../src/tokenizer/parser.h ../../src/tokenizer/scanner.h \
+ ../../src/tokenizer/parser.h ../../src/tokenizer/Scanner.h \
  ../../src/scene//skel_node.h ../../src/controllers/controller.h \
  ../../src/controllers/mesh_skel_ctrl.h \
  ../../src/controllers/controller.h
@@ -757,8 +760,8 @@ material.o: ../../src/resources//material.cpp \
  ../../src/math/mat4.inl.h ../../src/math/m_misc.h \
  ../../src/math/m_misc.inl.h ../../src/resources//resource.h \
  ../../src/uncategorized/engine_class.h ../../src/utility/util.h \
- ../../src/utility/common.h ../../src/tokenizer/scanner.h \
- ../../src/tokenizer/parser.h ../../src/tokenizer/scanner.h \
+ ../../src/utility/common.h ../../src/tokenizer/Scanner.h \
+ ../../src/tokenizer/parser.h ../../src/tokenizer/Scanner.h \
  ../../src/resources//texture.h ../../src/resources//shader_prog.h \
  ../../src/renderer/renderer.h ../../src/resources/shader_prog.h \
  ../../src/scene/camera.h ../../src/uncategorized/collision.h \
@@ -801,8 +804,8 @@ skel_anim.o: ../../src/resources//skel_anim.cpp \
  ../../src/math/euler.inl.h ../../src/math/mat3.h \
  ../../src/math/mat3.inl.h ../../src/math/mat4.h \
  ../../src/math/mat4.inl.h ../../src/math/m_misc.h \
- ../../src/math/m_misc.inl.h ../../src/tokenizer/scanner.h \
- ../../src/tokenizer/parser.h ../../src/tokenizer/scanner.h
+ ../../src/math/m_misc.inl.h ../../src/tokenizer/Scanner.h \
+ ../../src/tokenizer/parser.h ../../src/tokenizer/Scanner.h
 	@echo Compiling ../../src/resources//skel_anim.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/resources//skel_anim.cpp -o skel_anim.o
 
@@ -814,14 +817,6 @@ extension.o: ../../src/resources//extension.cpp \
 	@echo Compiling ../../src/resources//extension.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/resources//extension.cpp -o extension.o
 
-shader_parser.o: ../../src/resources//shader_parser.cpp \
- ../../src/resources//shader_parser.h ../../src/utility/common.h \
- ../../src/uncategorized/memory.h ../../src/tokenizer/scanner.h \
- ../../src/tokenizer/parser.h ../../src/tokenizer/scanner.h \
- ../../src/utility/util.h ../../src/utility/common.h
-	@echo Compiling ../../src/resources//shader_parser.cpp...
-	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/resources//shader_parser.cpp -o shader_parser.o
-
 skeleton.o: ../../src/resources//skeleton.cpp \
  ../../src/resources//skeleton.h ../../src/utility/common.h \
  ../../src/uncategorized/memory.h ../../src/math/gmath.h \
@@ -836,8 +831,8 @@ skeleton.o: ../../src/resources//skeleton.cpp \
  ../../src/math/mat4.inl.h ../../src/math/m_misc.h \
  ../../src/math/m_misc.inl.h ../../src/resources//resource.h \
  ../../src/uncategorized/engine_class.h ../../src/utility/util.h \
- ../../src/utility/common.h ../../src/tokenizer/scanner.h \
- ../../src/tokenizer/parser.h ../../src/tokenizer/scanner.h
+ ../../src/utility/common.h ../../src/tokenizer/Scanner.h \
+ ../../src/tokenizer/parser.h ../../src/tokenizer/Scanner.h
 	@echo Compiling ../../src/resources//skeleton.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/resources//skeleton.cpp -o skeleton.o
 
@@ -863,6 +858,14 @@ resource.o: ../../src/resources//resource.cpp \
 	@echo Compiling ../../src/resources//resource.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/resources//resource.cpp -o resource.o
 
+ShaderParser.o: ../../src/resources//ShaderParser.cpp \
+ ../../src/resources//ShaderParser.h ../../src/utility/common.h \
+ ../../src/uncategorized/memory.h ../../src/tokenizer/Scanner.h \
+ ../../src/tokenizer/parser.h ../../src/tokenizer/Scanner.h \
+ ../../src/utility/util.h ../../src/utility/common.h
+	@echo Compiling ../../src/resources//ShaderParser.cpp...
+	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/resources//ShaderParser.cpp -o ShaderParser.o
+
 light_props.o: ../../src/resources//light_props.cpp \
  ../../src/resources//light_props.h ../../src/utility/common.h \
  ../../src/uncategorized/memory.h ../../src/resources//resource.h \
@@ -878,7 +881,7 @@ light_props.o: ../../src/resources//light_props.cpp \
  ../../src/math/mat3.inl.h ../../src/math/mat4.h \
  ../../src/math/mat4.inl.h ../../src/math/m_misc.h \
  ../../src/math/m_misc.inl.h ../../src/tokenizer/parser.h \
- ../../src/tokenizer/scanner.h ../../src/resources//texture.h
+ ../../src/tokenizer/Scanner.h ../../src/resources//texture.h
 	@echo Compiling ../../src/resources//light_props.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/resources//light_props.cpp -o light_props.o
 
@@ -900,8 +903,8 @@ mesh.o: ../../src/resources//mesh.cpp ../../src/resources//mesh.h \
  ../../src/uncategorized/collision.h ../../src/renderer/renderer.h \
  ../../src/resources/shader_prog.h ../../src/resources/resource.h \
  ../../src/scene/camera.h ../../src/scene/node.h \
- ../../src/tokenizer/scanner.h ../../src/tokenizer/parser.h \
- ../../src/tokenizer/scanner.h
+ ../../src/tokenizer/Scanner.h ../../src/tokenizer/parser.h \
+ ../../src/tokenizer/Scanner.h
 	@echo Compiling ../../src/resources//mesh.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/resources//mesh.cpp -o mesh.o
 
@@ -922,7 +925,7 @@ shader_prog.o: ../../src/resources//shader_prog.cpp \
  ../../src/math/mat4.inl.h ../../src/math/m_misc.h \
  ../../src/math/m_misc.inl.h ../../src/resources/shader_prog.h \
  ../../src/scene/camera.h ../../src/uncategorized/collision.h \
- ../../src/scene/node.h ../../src/resources//shader_parser.h \
+ ../../src/scene/node.h ../../src/resources//ShaderParser.h \
  ../../src/resources//texture.h
 	@echo Compiling ../../src/resources//shader_prog.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/resources//shader_prog.cpp -o shader_prog.o

+ 1 - 1
src/main.cpp

@@ -18,7 +18,7 @@
 #include "material.h"
 #include "resource.h"
 #include "scene.h"
-#include "scanner.h"
+#include "Scanner.h"
 #include "skybox.h"
 #include "map.h"
 #include "mesh_node.h"

+ 62 - 62
src/resources/shader_parser.cpp → src/resources/ShaderParser.cpp

@@ -1,6 +1,6 @@
 #include <iomanip>
-#include "shader_parser.h"
-#include "scanner.h"
+#include "ShaderParser.h"
+#include "Scanner.h"
 #include "parser.h"
 #include "util.h"
 
@@ -8,7 +8,7 @@
 //=====================================================================================================================================
 // FindShaderVar                                                                                                                      =
 //=====================================================================================================================================
-void shader_parser_t::PrintSourceLines() const
+void ShaderParser::PrintSourceLines() const
 {
 	for( uint i=0; i<source_lines.size(); ++i )
 	{
@@ -20,7 +20,7 @@ void shader_parser_t::PrintSourceLines() const
 //=====================================================================================================================================
 // PrintShaderVars                                                                                                                    =
 //=====================================================================================================================================
-void shader_parser_t::PrintShaderVars() const
+void ShaderParser::PrintShaderVars() const
 {
 	PRINT( "TYPE" << setw(20) << "NAME" << setw(4) << "LOC" );
 	for( uint i=0; i<uniforms.size(); ++i )
@@ -37,9 +37,9 @@ void shader_parser_t::PrintShaderVars() const
 //=====================================================================================================================================
 // FindShaderVar                                                                                                                      =
 //=====================================================================================================================================
-vec_t<shader_parser_t::shader_var_t>::iterator shader_parser_t::FindShaderVar( vec_t<shader_var_t>& vec, const string& name ) const
+vec_t<ShaderParser::ShaderVarPragma>::iterator ShaderParser::FindShaderVar( vec_t<ShaderVarPragma>& vec, const string& name ) const
 {
-	vec_t<shader_var_t>::iterator it = vec.begin();
+	vec_t<ShaderVarPragma>::iterator it = vec.begin();
 	while( it != vec.end() && it->name != name )
 	{
 		++it;
@@ -51,7 +51,7 @@ vec_t<shader_parser_t::shader_var_t>::iterator shader_parser_t::FindShaderVar( v
 //=====================================================================================================================================
 // ParseFileForPragmas                                                                                                                =
 //=====================================================================================================================================
-bool shader_parser_t::ParseFileForPragmas( const string& filename, int id )
+bool ShaderParser::ParseFileForPragmas( const string& filename, int id )
 {
 	// load file in lines
 	vec_t<string> lines = util::GetFileLines( filename.c_str() );
@@ -62,49 +62,49 @@ bool shader_parser_t::ParseFileForPragmas( const string& filename, int id )
 	}
 
 	// scanner
-	scanner_t scanner( false );
-	if( !scanner.LoadFile( filename.c_str() ) ) return false;
-	const scanner_t::token_t* token;
+	Scanner scanner( false );
+	if( !scanner.loadFile( filename.c_str() ) ) return false;
+	const Scanner::Token* token;
 
 	
 	do
 	{
-		token = &scanner.GetNextToken();
+		token = &scanner.getNextToken();
 
-		if( token->code == scanner_t::TC_SHARP )
+		if( token->code == Scanner::TC_SHARP )
 		{
-			token = &scanner.GetNextToken();
-			if( token->code == scanner_t::TC_IDENTIFIER && strcmp(token->value.string, "pragma") == 0 )
+			token = &scanner.getNextToken();
+			if( token->code == Scanner::TC_IDENTIFIER && strcmp(token->value.string, "pragma") == 0 )
 			{
-				token = &scanner.GetNextToken();
-				if( token->code == scanner_t::TC_IDENTIFIER && strcmp(token->value.string, "anki") == 0 )
+				token = &scanner.getNextToken();
+				if( token->code == Scanner::TC_IDENTIFIER && strcmp(token->value.string, "anki") == 0 )
 				{
-					token = &scanner.GetNextToken();
+					token = &scanner.getNextToken();
 /* vert_shader_begins */
-					if( token->code == scanner_t::TC_IDENTIFIER && strcmp(token->value.string, "vert_shader_begins") == 0 )
+					if( token->code == Scanner::TC_IDENTIFIER && strcmp(token->value.string, "vert_shader_begins") == 0 )
 					{
 						// play
 						if( frag_shader_begins.defined_in_line != -1 ) // check if frag shader allready defined
 						{
-							PARSE_ERR( "vert_shader_begins must precede frag_shader_begins defined at " << frag_shader_begins.defined_in_file << 
+							PARSE_ERR( "vert_shader_begins must precede frag_shader_begins defined at " << frag_shader_begins.definedInFile <<
 							           ":" << frag_shader_begins.defined_in_line );
 							return false;
 						}
 						
 						if( vert_shader_begins.defined_in_line != -1 ) // allready defined elseware so throw error
 						{
-							PARSE_ERR( "vert_shader_begins allready defined at " << vert_shader_begins.defined_in_file << ":" << 
+							PARSE_ERR( "vert_shader_begins allready defined at " << vert_shader_begins.definedInFile << ":" <<
 							           vert_shader_begins.defined_in_line );
 							return false;
 						}
-						vert_shader_begins.defined_in_file = filename;
-						vert_shader_begins.defined_in_line = scanner.GetLineNmbr();
+						vert_shader_begins.definedInFile = filename;
+						vert_shader_begins.defined_in_line = scanner.getLineNmbr();
 						vert_shader_begins.global_line = source_lines.size() + 1;
-						source_lines.push_back( string("#line ") + IntToStr(scanner.GetLineNmbr()) + ' ' + IntToStr(id) + " // " + lines[scanner.GetLineNmbr()-1] );
+						source_lines.push_back( string("#line ") + IntToStr(scanner.getLineNmbr()) + ' ' + IntToStr(id) + " // " + lines[scanner.getLineNmbr()-1] );
 						// stop play
 					}
 /* frag_shader_begins */
-					else if( token->code == scanner_t::TC_IDENTIFIER && strcmp(token->value.string, "frag_shader_begins") == 0 )
+					else if( token->code == Scanner::TC_IDENTIFIER && strcmp(token->value.string, "frag_shader_begins") == 0 )
 					{
 						// play
 						if( vert_shader_begins.defined_in_line == -1 )
@@ -115,27 +115,27 @@ bool shader_parser_t::ParseFileForPragmas( const string& filename, int id )
 						
 						if( frag_shader_begins.defined_in_line != -1 ) // if allready defined elseware throw error
 						{
-							PARSE_ERR( "frag_shader_begins allready defined at " << frag_shader_begins.defined_in_file << ":" << 
+							PARSE_ERR( "frag_shader_begins allready defined at " << frag_shader_begins.definedInFile << ":" <<
 							           frag_shader_begins.defined_in_line );
 							return false;
 						}
-						frag_shader_begins.defined_in_file = filename;
-						frag_shader_begins.defined_in_line = scanner.GetLineNmbr();
+						frag_shader_begins.definedInFile = filename;
+						frag_shader_begins.defined_in_line = scanner.getLineNmbr();
 						frag_shader_begins.global_line = source_lines.size() + 1;
-						source_lines.push_back( string("#line ") + IntToStr(scanner.GetLineNmbr()) + ' ' + IntToStr(id) + " // " + lines[scanner.GetLineNmbr()-1] );
+						source_lines.push_back( string("#line ") + IntToStr(scanner.getLineNmbr()) + ' ' + IntToStr(id) + " // " + lines[scanner.getLineNmbr()-1] );
 						// stop play
 					}
 /* include */
-					else if( token->code == scanner_t::TC_IDENTIFIER && strcmp(token->value.string, "include") == 0 )
+					else if( token->code == Scanner::TC_IDENTIFIER && strcmp(token->value.string, "include") == 0 )
 					{
-						token = &scanner.GetNextToken();
-						if( token->code == scanner_t::TC_STRING )
+						token = &scanner.getNextToken();
+						if( token->code == Scanner::TC_STRING )
 						{
 							// play
 							//int line = source_lines.size();
-							source_lines.push_back( string("#line 0 ") + IntToStr(id+1) + " // " + lines[scanner.GetLineNmbr()-1] );
+							source_lines.push_back( string("#line 0 ") + IntToStr(id+1) + " // " + lines[scanner.getLineNmbr()-1] );
 							if( !ParseFileForPragmas( token->value.string, id+1 ) ) return false;
-							source_lines.push_back( string("#line ") + IntToStr(scanner.GetLineNmbr()) + ' ' + IntToStr(id) +  " // end of " + lines[scanner.GetLineNmbr()-1] );
+							source_lines.push_back( string("#line ") + IntToStr(scanner.getLineNmbr()) + ' ' + IntToStr(id) +  " // end of " + lines[scanner.getLineNmbr()-1] );
 							// stop play
 						}
 						else
@@ -145,25 +145,25 @@ bool shader_parser_t::ParseFileForPragmas( const string& filename, int id )
 						}
 					}
 /* uniform */
-					else if( token->code == scanner_t::TC_IDENTIFIER && strcmp(token->value.string, "uniform") == 0 )
+					else if( token->code == Scanner::TC_IDENTIFIER && strcmp(token->value.string, "uniform") == 0 )
 					{
-						token = &scanner.GetNextToken();
-						if( token->code == scanner_t::TC_IDENTIFIER )
+						token = &scanner.getNextToken();
+						if( token->code == Scanner::TC_IDENTIFIER )
 						{
 							string var_name = token->value.string;
-							token = &scanner.GetNextToken();
-							if( token->code == scanner_t::TC_NUMBER && token->type == scanner_t::DT_INT )
+							token = &scanner.getNextToken();
+							if( token->code == Scanner::TC_NUMBER && token->type == Scanner::DT_INT )
 							{
 								// play
-								vec_t<shader_var_t>::iterator uniform = FindShaderVar( uniforms, var_name );
+								vec_t<ShaderVarPragma>::iterator uniform = FindShaderVar( uniforms, var_name );
 								if( uniform != uniforms.end() )
 								{
-									PARSE_ERR( "Uniform allready defined at " << uniform->defined_in_file << ":" << uniform->defined_in_line );
+									PARSE_ERR( "Uniform allready defined at " << uniform->definedInFile << ":" << uniform->defined_in_line );
 									return false;
 								}
 								
-								uniforms.push_back( shader_var_t( filename, scanner.GetLineNmbr(), var_name, token->value.int_ ) );
-								source_lines.push_back( lines[scanner.GetLineNmbr()-1] );
+								uniforms.push_back( ShaderVarPragma( filename, scanner.getLineNmbr(), var_name, token->value.int_ ) );
+								source_lines.push_back( lines[scanner.getLineNmbr()-1] );
 								// stop play
 							}
 							else
@@ -179,25 +179,25 @@ bool shader_parser_t::ParseFileForPragmas( const string& filename, int id )
 						}
 					}
 /* attribute */
-					else if( token->code == scanner_t::TC_IDENTIFIER && strcmp(token->value.string, "attribute") == 0 )
+					else if( token->code == Scanner::TC_IDENTIFIER && strcmp(token->value.string, "attribute") == 0 )
 					{
-						token = &scanner.GetNextToken();
-						if( token->code == scanner_t::TC_IDENTIFIER )
+						token = &scanner.getNextToken();
+						if( token->code == Scanner::TC_IDENTIFIER )
 						{
 							string var_name = token->value.string;
-							token = &scanner.GetNextToken();
-							if( token->code == scanner_t::TC_NUMBER && token->type == scanner_t::DT_INT )
+							token = &scanner.getNextToken();
+							if( token->code == Scanner::TC_NUMBER && token->type == Scanner::DT_INT )
 							{
 								// play
-								vec_t<shader_var_t>::iterator attrib = FindShaderVar( attributes, var_name );
+								vec_t<ShaderVarPragma>::iterator attrib = FindShaderVar( attributes, var_name );
 								if( attrib != attributes.end() )
 								{
-									PARSE_ERR( "Attribute allready defined at " << attrib->defined_in_file << ":" << attrib->defined_in_line );
+									PARSE_ERR( "Attribute allready defined at " << attrib->definedInFile << ":" << attrib->defined_in_line );
 									return false;
 								}
 								
-								attributes.push_back( shader_var_t( filename, scanner.GetLineNmbr(), var_name, token->value.int_ ) );
-								source_lines.push_back( lines[scanner.GetLineNmbr()-1] );
+								attributes.push_back( ShaderVarPragma( filename, scanner.getLineNmbr(), var_name, token->value.int_ ) );
+								source_lines.push_back( lines[scanner.getLineNmbr()-1] );
 								// stop play
 							}
 							else
@@ -218,33 +218,33 @@ bool shader_parser_t::ParseFileForPragmas( const string& filename, int id )
 					}
 				} // end if anki
 				
-				token = &scanner.GetNextToken();
-				if( token->code!=scanner_t::TC_NEWLINE && token->code!=scanner_t::TC_EOF )
+				token = &scanner.getNextToken();
+				if( token->code!=Scanner::TC_NEWLINE && token->code!=Scanner::TC_EOF )
 				{
 					PARSE_ERR_EXPECTED( "newline or end of file" );
 					return false;
 				}
 				
-				if( token->code == scanner_t::TC_EOF )
+				if( token->code == Scanner::TC_EOF )
 					break;
 				
 			} // end if pragma
 		} // end if #
 /* newline */		
-		else if( token->code == scanner_t::TC_NEWLINE )
+		else if( token->code == Scanner::TC_NEWLINE )
 		{
-			source_lines.push_back( lines[ scanner.GetLineNmbr() - 2 ] );
-			//PRINT( lines[ scanner.GetLineNmbr() - 2 ] )
+			source_lines.push_back( lines[ scanner.getLineNmbr() - 2 ] );
+			//PRINT( lines[ scanner.getLineNmbr() - 2 ] )
 		}
 /* EOF */
-		else if( token->code == scanner_t::TC_EOF )
+		else if( token->code == Scanner::TC_EOF )
 		{
-			source_lines.push_back( lines[ scanner.GetLineNmbr() - 1 ] );
-			//PRINT( lines[ scanner.GetLineNmbr() - 1 ] )
+			source_lines.push_back( lines[ scanner.getLineNmbr() - 1 ] );
+			//PRINT( lines[ scanner.getLineNmbr() - 1 ] )
 			break;
 		}
 /* error */
-		else if( token->code == scanner_t::TC_ERROR )
+		else if( token->code == Scanner::TC_ERROR )
 		{
 			return false;
 		}
@@ -258,7 +258,7 @@ bool shader_parser_t::ParseFileForPragmas( const string& filename, int id )
 //=====================================================================================================================================
 // Load                                                                                                                               =
 //=====================================================================================================================================
-bool shader_parser_t::ParseFile( const char* filename )
+bool ShaderParser::ParseFile( const char* filename )
 {
 	// parse master file
 	if( !ParseFileForPragmas( filename ) ) return false;

+ 73 - 0
src/resources/ShaderParser.h

@@ -0,0 +1,73 @@
+#ifndef _SHADERPARSER_H_
+#define _SHADERPARSER_H_
+
+#include <limits>
+#include "common.h"
+
+
+/**
+ * The class fills some of the GLSL spec deficiencies. It adds the include preprocessor directive and the support to have all the
+ * shaders in the same file
+ */
+class ShaderParser
+{
+	protected:
+		/**
+		 * The pragma base class
+		 */
+		struct Pragma
+		{
+			
+			string definedInFile;
+			int    defined_in_line;
+			Pragma(): defined_in_line(-1) {}
+			Pragma( const string& definedInFile_, int defined_in_line_ ):
+				definedInFile(definedInFile_), defined_in_line(defined_in_line_)
+			{}
+		};
+		
+		struct IncludePragma: Pragma
+		{
+			string filename;
+		};
+		
+		struct ShaderVarPragma: Pragma
+		{
+			string name;
+			uint   custom_loc;
+			ShaderVarPragma( const string& defined_in_file_, int defined_in_line_, const string& name_, uint custom_loc_ ):
+				Pragma( defined_in_file_, defined_in_line_ ), name(name_), custom_loc(custom_loc_)
+			{}
+		};
+	
+		struct code_beginning_t: Pragma
+		{
+			int global_line;
+
+			code_beginning_t(): global_line(-1) {}
+		};
+		
+		vec_t<string> source_lines;
+		code_beginning_t vert_shader_begins;
+		code_beginning_t frag_shader_begins;
+		
+		bool ParseFileForPragmas( const string& filename, int id = 0 );
+		vec_t<ShaderVarPragma>::iterator FindShaderVar( vec_t<ShaderVarPragma>& vec, const string& name ) const;
+		void PrintSourceLines() const;  ///< For debugging
+		void PrintShaderVars() const;  ///< For debugging
+
+	public:
+		// the output
+		vec_t<ShaderVarPragma> uniforms;
+		vec_t<ShaderVarPragma> attributes;
+		string vert_shader_source;
+		string frag_shader_source;
+		
+		ShaderParser() {}
+		~ShaderParser() {}
+
+		bool ParseFile( const char* fname ); ///< Parse a file and its includes 
+};
+
+
+#endif

+ 29 - 29
src/resources/light_props.cpp

@@ -8,42 +8,42 @@
 //=====================================================================================================================================
 bool light_props_t::Load( const char* filename )
 {
-scanner_t scanner;
-	if( !scanner.LoadFile( filename ) ) return false;
+Scanner scanner;
+	if( !scanner.loadFile( filename ) ) return false;
 
-	const scanner_t::token_t* token;
+	const Scanner::Token* token;
 
 	do
 	{
-		token = &scanner.GetNextToken();
+		token = &scanner.getNextToken();
 
 		//** DIFFUSE_COL **
-		if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "DIFFUSE_COLOR" ) )
+		if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "DIFFUSE_COLOR" ) )
 		{
 			ParseArrOfNumbers<float>( scanner, true, true, 3, &diffuse_col[0] );
 		}
 		//** SPECULAR_COL **
-		else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "SPECULAR_COLOR" ) )
+		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "SPECULAR_COLOR" ) )
 		{
 			ParseArrOfNumbers<float>( scanner, true, true, 3, &specular_col[0] );
 		}
 		//** RADIUS **
-		else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "RADIUS" ) )
+		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "RADIUS" ) )
 		{
-			token = &scanner.GetNextToken();
-			if( token->code != scanner_t::TC_NUMBER )
+			token = &scanner.getNextToken();
+			if( token->code != Scanner::TC_NUMBER )
 			{
 				PARSE_ERR_EXPECTED( "number" );
 				return false;
 			}
 
-			radius = (token->type == scanner_t::DT_FLOAT) ? token->value.float_ : float(token->value.int_);
+			radius = (token->type == Scanner::DT_FLOAT) ? token->value.float_ : float(token->value.int_);
 		}
 		//** CASTS_SHADOW **
-		else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "CASTS_SHADOW" ) )
+		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "CASTS_SHADOW" ) )
 		{
-			token = &scanner.GetNextToken();
-			if( token->code != scanner_t::TC_NUMBER || token->type != scanner_t::DT_INT )
+			token = &scanner.getNextToken();
+			if( token->code != Scanner::TC_NUMBER || token->type != Scanner::DT_INT )
 			{
 				PARSE_ERR_EXPECTED( "number" );
 				return false;
@@ -52,46 +52,46 @@ scanner_t scanner;
 			casts_shadow = token->value.int_;
 		}
 		//** DISTANCE **
-		else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "DISTANCE" ) )
+		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "DISTANCE" ) )
 		{
-			token = &scanner.GetNextToken();
-			if( token->code != scanner_t::TC_NUMBER )
+			token = &scanner.getNextToken();
+			if( token->code != Scanner::TC_NUMBER )
 			{
 				PARSE_ERR_EXPECTED( "number" );
 				return false;
 			}
 
-			distance = (token->type == scanner_t::DT_FLOAT) ? token->value.float_ : float(token->value.int_);
+			distance = (token->type == Scanner::DT_FLOAT) ? token->value.float_ : float(token->value.int_);
 		}
 		//** FOV_X **
-		else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "FOV_X" ) )
+		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "FOV_X" ) )
 		{
-			token = &scanner.GetNextToken();
-			if( token->code != scanner_t::TC_NUMBER )
+			token = &scanner.getNextToken();
+			if( token->code != Scanner::TC_NUMBER )
 			{
 				PARSE_ERR_EXPECTED( "number" );
 				return false;
 			}
 
-			fov_x = (token->type == scanner_t::DT_FLOAT) ? token->value.float_ : float(token->value.int_);
+			fov_x = (token->type == Scanner::DT_FLOAT) ? token->value.float_ : float(token->value.int_);
 		}
 		//** FOV_Y **
-		else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "FOV_Y" ) )
+		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "FOV_Y" ) )
 		{
-			token = &scanner.GetNextToken();
-			if( token->code != scanner_t::TC_NUMBER )
+			token = &scanner.getNextToken();
+			if( token->code != Scanner::TC_NUMBER )
 			{
 				PARSE_ERR_EXPECTED( "number" );
 				return false;
 			}
 
-			fov_y = (token->type == scanner_t::DT_FLOAT) ? token->value.float_ : float(token->value.int_);
+			fov_y = (token->type == Scanner::DT_FLOAT) ? token->value.float_ : float(token->value.int_);
 		}
 		//** TEXTURE **
-		else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "TEXTURE" ) )
+		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "TEXTURE" ) )
 		{
-			token = &scanner.GetNextToken();
-			if( token->code != scanner_t::TC_STRING )
+			token = &scanner.getNextToken();
+			if( token->code != Scanner::TC_STRING )
 			{
 				PARSE_ERR_EXPECTED( "string" );
 				return false;
@@ -101,7 +101,7 @@ scanner_t scanner;
 			texture->TexParameter( GL_TEXTURE_MAX_ANISOTROPY_EXT, 0 );
 		}
 		// end of file
-		else if( token->code == scanner_t::TC_EOF )
+		else if( token->code == Scanner::TC_EOF )
 		{
 			break;
 		}

+ 58 - 58
src/resources/material.cpp

@@ -1,7 +1,7 @@
 #include <string.h>
 #include "material.h"
 #include "resource.h"
-#include "scanner.h"
+#include "Scanner.h"
 #include "parser.h"
 #include "texture.h"
 #include "shader_prog.h"
@@ -60,22 +60,22 @@ Load
 */
 bool material_t::Load( const char* filename )
 {
-	scanner_t scanner;
-	if( !scanner.LoadFile( filename ) ) return false;
+	Scanner scanner;
+	if( !scanner.loadFile( filename ) ) return false;
 
-	const scanner_t::token_t* token;
+	const Scanner::Token* token;
 
 	do
 	{
-		token = &scanner.GetNextToken();
+		token = &scanner.getNextToken();
 
 		//** SHADER_PROG **
-		if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "SHADER_PROG" ) )
+		if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "SHADER_PROG" ) )
 		{
 			if( shader_prog ) ERROR( "Shader program allready loaded" );
 
-			token = &scanner.GetNextToken();
-			if( token->code != scanner_t::TC_STRING )
+			token = &scanner.getNextToken();
+			if( token->code != Scanner::TC_STRING )
 			{
 				PARSE_ERR_EXPECTED( "string" );
 				return false;
@@ -83,12 +83,12 @@ bool material_t::Load( const char* filename )
 			shader_prog = rsrc::shaders.Load( token->value.string );
 		}
 		/*//** DEPTH_SHADER_PROG **
-		else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "DEPTH_SHADER_PROG" ) )
+		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "DEPTH_SHADER_PROG" ) )
 		{
 			if( depth.shader_prog ) ERROR( "Depth shader program allready loaded" );
 
-			token = &scanner.GetNextToken();
-			if( token->code != scanner_t::TC_STRING )
+			token = &scanner.getNextToken();
+			if( token->code != Scanner::TC_STRING )
 			{
 				PARSE_ERR_EXPECTED( "string" );
 				return false;
@@ -96,12 +96,12 @@ bool material_t::Load( const char* filename )
 			depth.shader_prog = rsrc::shaders.Load( token->value.string );
 		}*/
 		//** DEPTH_MATERIAL **
-		else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "DEPTH_PASS_MATERIAL" ) )
+		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "DEPTH_PASS_MATERIAL" ) )
 		{
 			if( dp_mtl ) ERROR( "Depth material already loaded" );
 
-			token = &scanner.GetNextToken();
-			if( token->code != scanner_t::TC_STRING )
+			token = &scanner.getNextToken();
+			if( token->code != Scanner::TC_STRING )
 			{
 				PARSE_ERR_EXPECTED( "string" );
 				return false;
@@ -109,10 +109,10 @@ bool material_t::Load( const char* filename )
 			dp_mtl = rsrc::materials.Load( token->value.string );
 		}
 		//** BLENDS **
-		else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "BLENDS" ) )
+		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "BLENDS" ) )
 		{
-			token = &scanner.GetNextToken();
-			if( token->code != scanner_t::TC_NUMBER )
+			token = &scanner.getNextToken();
+			if( token->code != Scanner::TC_NUMBER )
 			{
 				PARSE_ERR_EXPECTED( "number" );
 				return false;
@@ -120,10 +120,10 @@ bool material_t::Load( const char* filename )
 			blends = token->value.int_;
 		}
 		//** REFRACTS **
-		else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "REFRACTS" ) )
+		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "REFRACTS" ) )
 		{
-			token = &scanner.GetNextToken();
-			if( token->code != scanner_t::TC_NUMBER )
+			token = &scanner.getNextToken();
+			if( token->code != Scanner::TC_NUMBER )
 			{
 				PARSE_ERR_EXPECTED( "number" );
 				return false;
@@ -131,10 +131,10 @@ bool material_t::Load( const char* filename )
 			refracts = token->value.int_;
 		}
 		//** BLENDING_SFACTOR **
-		else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "BLENDING_SFACTOR" ) )
+		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "BLENDING_SFACTOR" ) )
 		{
-			token = &scanner.GetNextToken();
-			if( token->code != scanner_t::TC_IDENTIFIER )
+			token = &scanner.getNextToken();
+			if( token->code != Scanner::TC_IDENTIFIER )
 			{
 				PARSE_ERR_EXPECTED( "identifier" );
 				return false;
@@ -148,10 +148,10 @@ bool material_t::Load( const char* filename )
 			blending_sfactor = gl_enum;
 		}
 		//** BLENDING_DFACTOR **
-		else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "BLENDING_DFACTOR" ) )
+		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "BLENDING_DFACTOR" ) )
 		{
-			token = &scanner.GetNextToken();
-			if( token->code != scanner_t::TC_IDENTIFIER )
+			token = &scanner.getNextToken();
+			if( token->code != Scanner::TC_IDENTIFIER )
 			{
 				PARSE_ERR_EXPECTED( "identifier" );
 				return false;
@@ -165,10 +165,10 @@ bool material_t::Load( const char* filename )
 			blending_dfactor = gl_enum;
 		}
 		//** DEPTH_TESTING **
-		else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "DEPTH_TESTING" ) )
+		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "DEPTH_TESTING" ) )
 		{
-			token = &scanner.GetNextToken();
-			if( token->code != scanner_t::TC_NUMBER )
+			token = &scanner.getNextToken();
+			if( token->code != Scanner::TC_NUMBER )
 			{
 				PARSE_ERR_EXPECTED( "number" );
 				return false;
@@ -176,10 +176,10 @@ bool material_t::Load( const char* filename )
 			depth_testing = token->value.int_;
 		}
 		//** GRASS_MAP **
-		else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "GRASS_MAP" ) )
+		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "GRASS_MAP" ) )
 		{
-			token = &scanner.GetNextToken();
-			if( token->code != scanner_t::TC_STRING )
+			token = &scanner.getNextToken();
+			if( token->code != Scanner::TC_STRING )
 			{
 				PARSE_ERR_EXPECTED( "string" );
 				return false;
@@ -187,10 +187,10 @@ bool material_t::Load( const char* filename )
 			grass_map = rsrc::textures.Load( token->value.string );
 		}
 		//** WIREFRAME **
-		else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "WIREFRAME" ) )
+		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "WIREFRAME" ) )
 		{
-			token = &scanner.GetNextToken();
-			if( token->code != scanner_t::TC_NUMBER )
+			token = &scanner.getNextToken();
+			if( token->code != Scanner::TC_NUMBER )
 			{
 				PARSE_ERR_EXPECTED( "number" );
 				return false;
@@ -198,10 +198,10 @@ bool material_t::Load( const char* filename )
 			wireframe = token->value.int_;
 		}
 		//** CASTS_SHADOW **
-		else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "CASTS_SHADOW" ) )
+		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "CASTS_SHADOW" ) )
 		{
-			token = &scanner.GetNextToken();
-			if( token->code != scanner_t::TC_NUMBER )
+			token = &scanner.getNextToken();
+			if( token->code != Scanner::TC_NUMBER )
 			{
 				PARSE_ERR_EXPECTED( "number" );
 				return false;
@@ -209,11 +209,11 @@ bool material_t::Load( const char* filename )
 			casts_shadow = token->value.int_;
 		}
 		//** USER_DEFINED_VARS **
-		else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "USER_DEFINED_VARS" ) )
+		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "USER_DEFINED_VARS" ) )
 		{
 			// read {
-			token = &scanner.GetNextToken();
-			if( token->code != scanner_t::TC_LBRACKET )
+			token = &scanner.getNextToken();
+			if( token->code != Scanner::TC_LBRACKET )
 			{
 				PARSE_ERR_EXPECTED( "{" );
 				return false;
@@ -223,16 +223,16 @@ bool material_t::Load( const char* filename )
 			{
 				// read var type
 				user_defined_var_t::type_e type;
-				token = &scanner.GetNextToken();
-				if( token->code == scanner_t::TC_RBRACKET )
+				token = &scanner.getNextToken();
+				if( token->code == Scanner::TC_RBRACKET )
 					break;
-				else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "TEXTURE" ) )
+				else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "TEXTURE" ) )
 					type = user_defined_var_t::VT_TEXTURE;
-				else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "FLOAT" ) )
+				else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "FLOAT" ) )
 					type = user_defined_var_t::VT_FLOAT;
-				else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "VEC3" ) )
+				else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "VEC3" ) )
 					type = user_defined_var_t::VT_VEC3;
-				else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "VEC4" ) )
+				else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "VEC4" ) )
 					type = user_defined_var_t::VT_VEC4;
 				else
 				{
@@ -245,8 +245,8 @@ bool material_t::Load( const char* filename )
 				var.type = type;
 
 				// read the name
-				token = &scanner.GetNextToken();
-				if( token->code == scanner_t::TC_IDENTIFIER )
+				token = &scanner.getNextToken();
+				if( token->code == Scanner::TC_IDENTIFIER )
 					var.name = token->value.string;
 				else
 				{
@@ -259,24 +259,24 @@ bool material_t::Load( const char* filename )
 				{
 					// texture
 					case user_defined_var_t::VT_TEXTURE:
-						token = &scanner.GetNextToken();
-						if( token->code == scanner_t::TC_STRING )
+						token = &scanner.getNextToken();
+						if( token->code == Scanner::TC_STRING )
 						{
 							var.value.texture = rsrc::textures.Load( token->value.string );
 						}
-						else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "IS_FAI" ) )
+						else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "IS_FAI" ) )
 						{
 							var.value.texture = &r::is::fai;
 						}
-						else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "MS_NORMAL_FAI" ) )
+						else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "MS_NORMAL_FAI" ) )
 						{
 							var.value.texture = &r::ms::normal_fai;
 						}
-						else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "MS_DEPTH_FAI" ) )
+						else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "MS_DEPTH_FAI" ) )
 						{
 							var.value.texture = &r::ms::depth_fai;
 						}
-						else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "PPS_FAI" ) )
+						else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "PPS_FAI" ) )
 						{
 							var.value.texture = &r::pps::fai;
 						}
@@ -288,8 +288,8 @@ bool material_t::Load( const char* filename )
 						break;
 					// float
 					case user_defined_var_t::VT_FLOAT:
-						token = &scanner.GetNextToken();
-						if( token->code == scanner_t::TC_NUMBER && token->type == scanner_t::DT_FLOAT )
+						token = &scanner.getNextToken();
+						if( token->code == Scanner::TC_NUMBER && token->type == Scanner::DT_FLOAT )
 							var.value.float_ = token->value.float_;
 						else
 						{
@@ -315,7 +315,7 @@ bool material_t::Load( const char* filename )
 
 		}
 		// end of file
-		else if( token->code == scanner_t::TC_EOF )
+		else if( token->code == Scanner::TC_EOF )
 		{
 			break;
 		}

+ 22 - 22
src/resources/mesh.cpp

@@ -1,7 +1,7 @@
 #include "mesh.h"
 #include "renderer.h"
 #include "resource.h"
-#include "scanner.h"
+#include "Scanner.h"
 #include "parser.h"
 
 
@@ -10,15 +10,15 @@
 //=====================================================================================================================================
 bool mesh_t::Load( const char* filename )
 {
-	scanner_t scanner;
-	if( !scanner.LoadFile( filename ) ) return false;
+	Scanner scanner;
+	if( !scanner.loadFile( filename ) ) return false;
 
-	const scanner_t::token_t* token;
+	const Scanner::Token* token;
 
 
 	//** MATERIAL **
-	token = &scanner.GetNextToken();
-	if( token->code != scanner_t::TC_STRING )
+	token = &scanner.getNextToken();
+	if( token->code != Scanner::TC_STRING )
 	{
 		PARSE_ERR_EXPECTED( "string" );
 		return false;
@@ -26,8 +26,8 @@ bool mesh_t::Load( const char* filename )
 	material_name = token->value.string;
 
 	//** DP_MATERIAL **
-	/*token = &scanner.GetNextToken();
-	if( token->code != scanner_t::TC_STRING )
+	/*token = &scanner.getNextToken();
+	if( token->code != Scanner::TC_STRING )
 	{
 		PARSE_ERR_EXPECTED( "string" );
 		return false;
@@ -36,8 +36,8 @@ bool mesh_t::Load( const char* filename )
 
 	//** VERTS **
 	// verts num
-	token = &scanner.GetNextToken();
-	if( token->code != scanner_t::TC_NUMBER || token->type != scanner_t::DT_INT )
+	token = &scanner.getNextToken();
+	if( token->code != Scanner::TC_NUMBER || token->type != Scanner::DT_INT )
 	{
 		PARSE_ERR_EXPECTED( "integer" );
 		return false;
@@ -52,8 +52,8 @@ bool mesh_t::Load( const char* filename )
 
 	//** FACES **
 	// faces num
-	token = &scanner.GetNextToken();
-	if( token->code != scanner_t::TC_NUMBER || token->type != scanner_t::DT_INT )
+	token = &scanner.getNextToken();
+	if( token->code != Scanner::TC_NUMBER || token->type != Scanner::DT_INT )
 	{
 		PARSE_ERR_EXPECTED( "integer" );
 		return false;
@@ -67,8 +67,8 @@ bool mesh_t::Load( const char* filename )
 
 	//** UVS **
 	// UVs num
-	token = &scanner.GetNextToken();
-	if( token->code != scanner_t::TC_NUMBER || token->type != scanner_t::DT_INT )
+	token = &scanner.getNextToken();
+	if( token->code != Scanner::TC_NUMBER || token->type != Scanner::DT_INT )
 	{
 		PARSE_ERR_EXPECTED( "integer" );
 		return false;
@@ -81,8 +81,8 @@ bool mesh_t::Load( const char* filename )
 	}
 
 	//** VERTEX WEIGHTS **
-	token = &scanner.GetNextToken();
-	if( token->code != scanner_t::TC_NUMBER || token->type != scanner_t::DT_INT )
+	token = &scanner.getNextToken();
+	if( token->code != Scanner::TC_NUMBER || token->type != Scanner::DT_INT )
 	{
 		PARSE_ERR_EXPECTED( "integer" );
 		return false;
@@ -91,8 +91,8 @@ bool mesh_t::Load( const char* filename )
 	for( uint i=0; i<vert_weights.size(); i++ )
 	{
 		// get the bone connections num
-		token = &scanner.GetNextToken();
-		if( token->code != scanner_t::TC_NUMBER || token->type != scanner_t::DT_INT )
+		token = &scanner.getNextToken();
+		if( token->code != Scanner::TC_NUMBER || token->type != Scanner::DT_INT )
 		{
 			PARSE_ERR_EXPECTED( "integer" );
 			return false;
@@ -117,8 +117,8 @@ bool mesh_t::Load( const char* filename )
 		for( uint j=0; j<vert_weights[i].bones_num; j++ )
 		{
 			// read bone id
-			token = &scanner.GetNextToken();
-			if( token->code != scanner_t::TC_NUMBER || token->type != scanner_t::DT_INT )
+			token = &scanner.getNextToken();
+			if( token->code != Scanner::TC_NUMBER || token->type != Scanner::DT_INT )
 			{
 				PARSE_ERR_EXPECTED( "integer" );
 				return false;
@@ -126,8 +126,8 @@ bool mesh_t::Load( const char* filename )
 			vert_weights[i].bone_ids[j] = token->value.int_;
 
 			// read the weight of that bone
-			token = &scanner.GetNextToken();
-			if( token->code != scanner_t::TC_NUMBER || token->type != scanner_t::DT_FLOAT )
+			token = &scanner.getNextToken();
+			if( token->code != Scanner::TC_NUMBER || token->type != Scanner::DT_FLOAT )
 			{
 				PARSE_ERR_EXPECTED( "float" );
 				return false;

+ 0 - 66
src/resources/shader_parser.h

@@ -1,66 +0,0 @@
-#ifndef _SHADER_PARSER_H_
-#define _SHADER_PARSER_H_
-
-#include <limits>
-#include "common.h"
-
-
-class shader_parser_t
-{
-	protected:		
-		struct pragma_t
-		{
-			
-			string defined_in_file;
-			int    defined_in_line;
-			pragma_t(): defined_in_line(-1) {}
-			pragma_t( const string& defined_in_file_, int defined_in_line_ ): 
-				defined_in_file(defined_in_file_), defined_in_line(defined_in_line_)
-			{}
-		};
-		
-		struct include_t: pragma_t
-		{
-			string filename;
-		};
-		
-		struct shader_var_t: pragma_t
-		{
-			string name;
-			uint   custom_loc;
-			shader_var_t( const string& defined_in_file_, int defined_in_line_, const string& name_, uint custom_loc_ ): 
-				pragma_t( defined_in_file_, defined_in_line_ ), name(name_), custom_loc(custom_loc_)
-			{}
-		};
-	
-		struct code_beginning_t: pragma_t
-		{
-			int global_line;
-
-			code_beginning_t(): global_line(-1) {}
-		};
-		
-		vec_t<string> source_lines;
-		code_beginning_t vert_shader_begins;
-		code_beginning_t frag_shader_begins;
-		
-		bool ParseFileForPragmas( const string& filename, int id = 0 );
-		vec_t<shader_var_t>::iterator FindShaderVar( vec_t<shader_var_t>& vec, const string& name ) const;
-		void PrintSourceLines() const;  ///< For debugging
-		void PrintShaderVars() const;  ///< For debugging
-
-	public:
-		// the output
-		vec_t<shader_var_t> uniforms;
-		vec_t<shader_var_t> attributes;
-		string vert_shader_source;
-		string frag_shader_source;
-		
-		shader_parser_t() {}
-		~shader_parser_t() {}
-
-		bool ParseFile( const char* fname ); ///< Parse a file and its includes 
-};
-
-
-#endif

+ 3 - 3
src/resources/shader_prog.cpp

@@ -1,6 +1,6 @@
 #include "shader_prog.h"
 #include "renderer.h"
-#include "shader_parser.h"
+#include "ShaderParser.h"
 #include "texture.h"
 
 
@@ -149,7 +149,7 @@ void shader_prog_t::GetUniAndAttribLocs()
 //=====================================================================================================================================
 // FillTheCustomLocationsVectors                                                                                                      =
 //=====================================================================================================================================
-bool shader_prog_t::FillTheCustomLocationsVectors( const shader_parser_t& pars )
+bool shader_prog_t::FillTheCustomLocationsVectors( const ShaderParser& pars )
 {
 	Bind();
 	uint max = 0;
@@ -230,7 +230,7 @@ bool shader_prog_t::CustomLoad( const char* filename, const char* extra_source )
 		path = util::GetPath( filename );
 	}
 
-	shader_parser_t pars;
+	ShaderParser pars;
 
 	if( !pars.ParseFile( filename ) ) return false;
 

+ 2 - 2
src/resources/shader_prog.h

@@ -6,7 +6,7 @@
 #include "common.h"
 #include "resource.h"
 
-class shader_parser_t;
+class ShaderParser;
 class texture_t;
 
 /// Shader program. Combines a fragment and a vertex shader
@@ -23,7 +23,7 @@ class shader_prog_t: public resource_t
 		map<string,int> attrib_name_to_loc;
 		
 		void GetUniAndAttribLocs();
-		bool FillTheCustomLocationsVectors( const shader_parser_t& pars );
+		bool FillTheCustomLocationsVectors( const ShaderParser& pars );
 		uint CreateAndCompileShader( const char* source_code, const char* preproc, int type ) const; ///< @return Returns zero on falure
 		bool Link();
 		

+ 10 - 10
src/resources/skel_anim.cpp

@@ -1,5 +1,5 @@
 #include "skel_anim.h"
-#include "scanner.h"
+#include "Scanner.h"
 #include "parser.h"
 
 
@@ -8,15 +8,15 @@
 //=====================================================================================================================================
 bool skel_anim_t::Load( const char* filename )
 {
-	scanner_t scanner;
-	if( !scanner.LoadFile( filename ) ) return false;
+	Scanner scanner;
+	if( !scanner.loadFile( filename ) ) return false;
 
-	const scanner_t::token_t* token;
+	const Scanner::Token* token;
 
 
 	// keyframes
-	token = &scanner.GetNextToken();
-	if( token->code != scanner_t::TC_NUMBER || token->type != scanner_t::DT_INT  )
+	token = &scanner.getNextToken();
+	if( token->code != Scanner::TC_NUMBER || token->type != Scanner::DT_INT  )
 	{
 		PARSE_ERR_EXPECTED( "integer" );
 		return false;
@@ -26,8 +26,8 @@ bool skel_anim_t::Load( const char* filename )
 	if( !ParseArrOfNumbers( scanner, false, false, keyframes.size(), &keyframes[0] ) ) return false;
 
 	// bones num
-	token = &scanner.GetNextToken();
-	if( token->code != scanner_t::TC_NUMBER || token->type != scanner_t::DT_INT  )
+	token = &scanner.getNextToken();
+	if( token->code != Scanner::TC_NUMBER || token->type != Scanner::DT_INT  )
 	{
 		PARSE_ERR_EXPECTED( "integer" );
 		return false;
@@ -38,8 +38,8 @@ bool skel_anim_t::Load( const char* filename )
 	for( uint i=0; i<bones.size(); i++ )
 	{
 		// has anim?
-		token = &scanner.GetNextToken();
-		if( token->code != scanner_t::TC_NUMBER || token->type != scanner_t::DT_INT  )
+		token = &scanner.getNextToken();
+		if( token->code != Scanner::TC_NUMBER || token->type != Scanner::DT_INT  )
 		{
 			PARSE_ERR_EXPECTED( "integer" );
 			return false;

+ 16 - 16
src/resources/skeleton.cpp

@@ -1,5 +1,5 @@
 #include "skeleton.h"
-#include "scanner.h"
+#include "Scanner.h"
 #include "parser.h"
 
 
@@ -8,15 +8,15 @@
 //=====================================================================================================================================
 bool skeleton_t::Load( const char* filename )
 {
-	scanner_t scanner;
-	if( !scanner.LoadFile( filename ) ) return false;
+	Scanner scanner;
+	if( !scanner.loadFile( filename ) ) return false;
 
-	const scanner_t::token_t* token;
+	const Scanner::Token* token;
 
 
 	//** BONES NUM **
-	token = &scanner.GetNextToken();
-	if( token->code != scanner_t::TC_NUMBER || token->type != scanner_t::DT_INT )
+	token = &scanner.getNextToken();
+	if( token->code != Scanner::TC_NUMBER || token->type != Scanner::DT_INT )
 	{
 		PARSE_ERR_EXPECTED( "integer" );
 		return false;
@@ -29,8 +29,8 @@ bool skeleton_t::Load( const char* filename )
 		bone.id = i;
 
 		// NAME
-		token = &scanner.GetNextToken();
-		if( token->code != scanner_t::TC_STRING )
+		token = &scanner.getNextToken();
+		if( token->code != Scanner::TC_STRING )
 		{
 			PARSE_ERR_EXPECTED( "string" );
 			return false;
@@ -55,22 +55,22 @@ bool skeleton_t::Load( const char* filename )
 		bone.tsl_skel_space_inv = MAi.GetTranslationPart();
 
 		// parent
-		token = &scanner.GetNextToken();
-		if( (token->code != scanner_t::TC_NUMBER || token->type != scanner_t::DT_INT) &&
-		    (token->code != scanner_t::TC_IDENTIFIER || strcmp( token->value.string, "NULL" )!=0) )
+		token = &scanner.getNextToken();
+		if( (token->code != Scanner::TC_NUMBER || token->type != Scanner::DT_INT) &&
+		    (token->code != Scanner::TC_IDENTIFIER || strcmp( token->value.string, "NULL" )!=0) )
 		{
 			PARSE_ERR_EXPECTED( "integer or NULL" );
 			return false;
 		}
 
-		if( token->code == scanner_t::TC_IDENTIFIER )
+		if( token->code == Scanner::TC_IDENTIFIER )
 			bone.parent = NULL;
 		else
 			bone.parent = &bones[ token->value.int_ ];
 
 		// childs
-		token = &scanner.GetNextToken();
-		if( token->code != scanner_t::TC_NUMBER || token->type != scanner_t::DT_INT )
+		token = &scanner.getNextToken();
+		if( token->code != Scanner::TC_NUMBER || token->type != Scanner::DT_INT )
 		{
 			PARSE_ERR_EXPECTED( "integer" );
 			return false;
@@ -83,8 +83,8 @@ bool skeleton_t::Load( const char* filename )
 		bone.childs_num = token->value.int_;
 		for( int j=0; j<bone.childs_num; j++ )
 		{
-			token = &scanner.GetNextToken();
-			if( token->code != scanner_t::TC_NUMBER || token->type != scanner_t::DT_INT )
+			token = &scanner.getNextToken();
+			if( token->code != Scanner::TC_NUMBER || token->type != Scanner::DT_INT )
 			{
 				PARSE_ERR_EXPECTED( "integer" );
 				return false;

+ 13 - 13
src/scene/skel_model_node.cpp

@@ -6,21 +6,21 @@
 /// Create a skel_node and N mesh_nodes that have a mesh_skel_ctrl
 void skel_model_node_t::Init( const char* filename )
 {
-	scanner_t scanner;
-	if( !scanner.LoadFile( filename ) ) return;
-	const scanner_t::token_t* token;
+	Scanner scanner;
+	if( !scanner.loadFile( filename ) ) return;
+	const Scanner::Token* token;
 
 
 	//** SKELETON **
-	token = &scanner.GetNextToken();
-	if( !(token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "SKELETON" )) )
+	token = &scanner.getNextToken();
+	if( !(token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "SKELETON" )) )
 	{
 		PARSE_ERR_EXPECTED( "identifier SKELETON" );
 		return;
 	}
 	
-	token = &scanner.GetNextToken();
-	if( token->code != scanner_t::TC_STRING )
+	token = &scanner.getNextToken();
+	if( token->code != Scanner::TC_STRING )
 	{
 		PARSE_ERR_EXPECTED( "string" );
 		return;
@@ -31,15 +31,15 @@ void skel_model_node_t::Init( const char* filename )
 	AddChild( skel_node );
 	
 	//** MESHES **
-	token = &scanner.GetNextToken();
-	if( !(token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "MESHES_NUM" )) )
+	token = &scanner.getNextToken();
+	if( !(token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "MESHES_NUM" )) )
 	{
 		PARSE_ERR_EXPECTED( "identifier MESHES_NUM" );
 		return;
 	}
 		
-	token = &scanner.GetNextToken();
-	if( token->code != scanner_t::TC_NUMBER || token->type != scanner_t::DT_INT )
+	token = &scanner.getNextToken();
+	if( token->code != Scanner::TC_NUMBER || token->type != Scanner::DT_INT )
 	{
 		PARSE_ERR_EXPECTED( "integer" );
 		return;
@@ -49,8 +49,8 @@ void skel_model_node_t::Init( const char* filename )
 			
 	for( uint i=0; i<mesh_nodes.size(); ++i )
 	{
-		token = &scanner.GetNextToken();
-		if( token->code != scanner_t::TC_STRING )
+		token = &scanner.getNextToken();
+		if( token->code != Scanner::TC_STRING )
 		{
 			PARSE_ERR_EXPECTED( "string" );
 			return;

ファイルの差分が大きいため隠しています
+ 230 - 230
src/tokenizer/Scanner.cpp


+ 61 - 61
src/tokenizer/scanner.h → src/tokenizer/Scanner.h

@@ -6,13 +6,13 @@
 
 
 //=====================================================================================================================================
-// scanner_t                                                                                                                          =
+// Scanner                                                                                                                          =
 //=====================================================================================================================================
 /**
- * The scanner_t loads a file and returns the tokens. The script must be in C++ format. The class does not make any kind of
+ * The Scanner loads a file and returns the tokens. The script must be in C++ format. The class does not make any kind of
  * memory allocations so it can be fast.
  */
-class scanner_t
+class Scanner
 {
 	//===================================================================================================================================
 	// private stuff                                                                                                                    =
@@ -20,24 +20,24 @@ class scanner_t
 	protected:
 		static const int MAX_SCRIPT_LINE_LEN = 1024; ///< The max allowed length of a script line
 
-		static char eof_char; ///< Special end of file character
+		static char eofChar; ///< Special end of file character
 
-		bool CheckWord();
-		bool CheckComment();
-		bool CheckNumber();
-		bool CheckString();
-		bool CheckChar();
-		bool CheckSpecial();
+		bool checkWord();
+		bool checkComment();
+		bool checkNumber();
+		bool checkString();
+		bool checkChar();
+		bool checkSpecial();
 
-		void GetLine(); ///< Reads a line from the script file
-		char GetNextChar(); ///< Get the next char from the line_txt. If line_txt empty then get new line. It returns '\0' if we are in the end of the line
-		char PutBackChar(); ///< Put the char that scanner_t::GetNextChar got back to the current line
+		void getLine(); ///< Reads a line from the script file
+		char getNextChar(); ///< Get the next char from the line_txt. If line_txt empty then get new line. It returns '\0' if we are in the end of the line
+		char putBackChar(); ///< Put the char that Scanner::GetNextChar got back to the current line
 
 	//===================================================================================================================================
 	// ascii stuff                                                                                                                      =
 	//===================================================================================================================================
 	protected:
-		enum ascii_flags_e
+		enum AsciiFlagsE
 		{
 			AC_ERROR = 0,
 			AC_EOF = 1,
@@ -49,14 +49,14 @@ class scanner_t
 			AC_DOUBLEQUOTE = 64
 		};
 
-		static uint ascii_lookup_table []; ///< The array contains one ascii_code_e for every symbol of the ASCII table
-		/// Initializes the ascii_lookup_table. It runs only once in the construction of the first scanner_t. See scanner_t()
-		static void InitAsciiMap();
+		static uint asciiLookupTable []; ///< The array contains one ascii_code_e for every symbol of the ASCII table
+		/// Initializes the asciiLookupTable. It runs only once in the construction of the first Scanner. See Scanner()
+		static void initAsciiMap();
 
-		/// To save us from typing for example ascii_lookup_table[ (int)'a' ]
-		inline uint AsciiLookup( char ch_ )
+		/// To save us from typing for example asciiLookupTable[ (int)'a' ]
+		inline uint asciiLookup( char ch_ )
 		{
-			return ascii_lookup_table[ (int)ch_ ];
+			return asciiLookupTable[ (int)ch_ ];
 		}
 
 		
@@ -64,8 +64,8 @@ class scanner_t
 	// token types                                                                                                                      =
 	//===================================================================================================================================
 	public:
-		/// The token_code_e is an enum that defines the token_t
-		enum token_code_e
+		/// The TokenCode is an enum that defines the Token
+		enum TokenCode
 		{
 			// general codes
 			TC_ERROR, TC_EOF, TC_COMMENT, TC_NUMBER, TC_CHAR, TC_STRING, TC_IDENTIFIER, TC_NEWLINE,
@@ -88,8 +88,8 @@ class scanner_t
 				TC_ASSIGNOR                                                                                             //36 - 47
 		};
 
-		/// token_data_type_e
-		enum token_data_type_e
+		/// TokenDataType
+		enum TokenDataType
 		{
 			DT_FLOAT,
 			DT_INT,
@@ -97,26 +97,26 @@ class scanner_t
 			DT_STR
 		};
 
-		/// token_data_val_u
-		union token_data_val_u
+		/// TokenDataVal
+		union TokenDataVal
 		{
 			char   char_;
 			ulong  int_;
 			double float_;
-			char*  string; ///< points to token_t::as_string if the token is string
+			char*  string; ///< points to Token::as_string if the token is string
 		};
 
-		/// The token_t class
-		struct token_t
+		/// The Token class
+		struct Token
 		{
-			token_code_e       code;
-			token_data_type_e  type;
-			token_data_val_u   value;
+			TokenCode      code;
+			TokenDataType  type;
+			TokenDataVal   value;
 
 			char as_string[ MAX_SCRIPT_LINE_LEN ];
 
-			token_t(): code( TC_ERROR ) {}
-			token_t( const token_t& b );
+			Token(): code( TC_ERROR ) {}
+			Token( const Token& b );
 		};
 
 	//===================================================================================================================================
@@ -124,55 +124,55 @@ class scanner_t
 	//===================================================================================================================================
 	protected:
 		/// Reserved words like "int" "const" etc. Currently the reserved words list is being populated with dummy data
-		struct res_word_t
+		struct ResWord
 		{
-			const char*  string;
-			token_code_e code;
+			const char* string;
+			TokenCode   code;
 		};
 
-		static res_word_t rw2 [], rw3 [], rw4 [], rw5 [], rw6 [], rw7 []; ///< Groups of res_word_t grouped by the length of the res_word_t::string
-		static res_word_t* rw_table []; ///< The array contains all the groups of res_word_t
+		static ResWord rw2 [], rw3 [], rw4 [], rw5 [], rw6 [], rw7 []; ///< Groups of ResWord grouped by the length of the ResWord::string
+		static ResWord* rw_table []; ///< The array contains all the groups of ResWord
 
 	//===================================================================================================================================
 	// vars                                                                                                                            =
 	//===================================================================================================================================
 	protected:
-		token_t crnt_token; ///< The current token
-		char    line_txt [MAX_SCRIPT_LINE_LEN]; ///< In contains the current line's text
-		char*   pchar; ///< Points to line_txt
-		int     line_nmbr; ///< The number of the current line
-		bool    newlines_as_whitespace; ///< Treat newlines as whitespace. This means that we extract new token for every line
-		/*
+		Token crntToken; ///< The current token
+		char  line [MAX_SCRIPT_LINE_LEN]; ///< In contains the current line's text
+		char* pchar; ///< Points to line_txt
+		int   lineNmbr; ///< The number of the current line
+		bool  newlinesAsWhitespace; ///< Treat newlines as whitespace. This means that we extract new token for every line
+		/**
 		 * Used to keep track of the newlines in multiline comments so we can return the correct number of newlines in case of 
 		 * newlines_as_whitespace is false
 		 */
-		int     commented_lines;  
+		int     commentedLines;
 
 		// input
-		fstream      in_fstream;
-		iostream*    in_stream; ///< Points to either in_fstream or an external std::iostream
-		char         script_name[64]; ///< The name of the input stream. Mostly used for error handling
+		fstream      inFstream;
+		iostream*    inStream; ///< Points to either in_fstream or an external std::iostream
+		char         scriptName[64]; ///< The name of the input stream. Mostly used for error handling
 
 	//===================================================================================================================================
 	// public funcs                                                                                                                     =
 	//===================================================================================================================================
 	public:
-		scanner_t( bool newlines_as_whitespace = true );
-		~scanner_t() { /* The destructor does NOTHING. The class does not make any mem allocations */ }
+		Scanner( bool newlinesAsWhitespace = true );
+		~Scanner() { /* The destructor does NOTHING. The class does not make any mem allocations */ }
 
-		bool LoadFile( const char* filename ); ///< Load a file to extract tokens
-		bool LoadIoStream( iostream* iostream_, const char* script_name_ = "unamed-iostream" ); ///< Load a STL iostream to extract tokens
-		void Unload();
+		bool loadFile( const char* filename ); ///< Load a file to extract tokens
+		bool loadIoStream( iostream* iostream_, const char* scriptName_ = "unamed-iostream" ); ///< Load a STL iostream to extract tokens
+		void unload();
 
-		static void   PrintTokenInfo( const token_t& token ); ///< Print info of the given token
-		static string GetTokenInfo( const token_t& token ); ///< Get a string with the info of the given token
-		       void   GetAllPrintAll();
+		static void   printTokenInfo( const Token& token ); ///< Print info of the given token
+		static string getTokenInfo( const Token& token ); ///< Get a string with the info of the given token
+		       void   getAllPrintAll();
 
-		const token_t& GetNextToken(); ///< Get the next token from the file
-		const token_t& GetCrntToken() const { return crnt_token; } ///< Accessor for the current token
+		const Token& getNextToken(); ///< Get the next token from the file
+		const Token& getCrntToken() const { return crntToken; } ///< Accessor for the current token
 
-		const char* GetScriptName() const { return script_name; } ///< Accessor for member variable
-		int         GetLineNmbr() const { return line_nmbr; } ///< Accessor for member variable
+		const char* getScriptName() const { return scriptName; } ///< Accessor for member variable
+		int         getLineNmbr() const { return lineNmbr; } ///< Accessor for member variable
 };
 
 #endif

+ 18 - 18
src/tokenizer/parser.h

@@ -2,19 +2,19 @@
 #define _PARSER_H_
 
 #include "common.h"
-#include "scanner.h"
+#include "Scanner.h"
 
 /*
 =======================================================================================================================================
 parser macros                                                                                                                         =
 =======================================================================================================================================
 */
-#define PARSE_ERR(x) ERROR( "PARSE_ERR (" << scanner.GetScriptName() << ':' << scanner.GetLineNmbr() << "): " << x )
-#define PARSE_WARN(x) WARNING( "PARSE_WARN (" << scanner.GetScriptName() << ':' << scanner.GetLineNmbr() << "): " << x )
+#define PARSE_ERR(x) ERROR( "PARSE_ERR (" << scanner.getScriptName() << ':' << scanner.getLineNmbr() << "): " << x )
+#define PARSE_WARN(x) WARNING( "PARSE_WARN (" << scanner.getScriptName() << ':' << scanner.getLineNmbr() << "): " << x )
 
 // common parser errors
-#define PARSE_ERR_EXPECTED(x) PARSE_ERR( "Expected " << x << " and not " << scanner_t::GetTokenInfo(scanner.GetCrntToken()) );
-#define PARSE_ERR_UNEXPECTED() PARSE_ERR( "Unexpected token " << scanner_t::GetTokenInfo(scanner.GetCrntToken()) );
+#define PARSE_ERR_EXPECTED(x) PARSE_ERR( "Expected " << x << " and not " << Scanner::getTokenInfo(scanner.getCrntToken()) );
+#define PARSE_ERR_UNEXPECTED() PARSE_ERR( "Unexpected token " << Scanner::getTokenInfo(scanner.getCrntToken()) );
 
 
 /*
@@ -29,15 +29,15 @@ It parses expressions like this one: { 10 -0.2 123.e-10 -0x0FF } and stores the
 @param arr The array that the func returns the numbers
 @return True if the parsing was success or false otherwise
 */
-template <typename type_t> bool ParseArrOfNumbers( scanner_t& scanner, bool paren, bool signs, uint size, type_t* arr )
+template <typename type_t> bool ParseArrOfNumbers( Scanner& scanner, bool paren, bool signs, uint size, type_t* arr )
 {
-	const scanner_t::token_t* token;
+	const Scanner::Token* token;
 
 	// first of all the left bracket
 	if( paren )
 	{
-		token = &scanner.GetNextToken();
-		if( token->code != scanner_t::TC_LBRACKET )
+		token = &scanner.getNextToken();
+		if( token->code != Scanner::TC_LBRACKET )
 		{
 			PARSE_ERR_EXPECTED( "{" );
 			return false;
@@ -47,26 +47,26 @@ template <typename type_t> bool ParseArrOfNumbers( scanner_t& scanner, bool pare
 	// loop to parse numbers
 	for( uint i=0; i<size; i++ )
 	{
-		token = &scanner.GetNextToken();
+		token = &scanner.getNextToken();
 
 
 		// check if there is a sign in front of a number
 		bool sign = 0; // sign of the number. 0 for positive and 1 for negative
 		if( signs )
 		{
-			if( token->code == scanner_t::TC_MINUS )
+			if( token->code == Scanner::TC_MINUS )
 			{
 				sign = 1;
-				token = &scanner.GetNextToken();
+				token = &scanner.getNextToken();
 			}
-			else if( token->code == scanner_t::TC_PLUS )
+			else if( token->code == Scanner::TC_PLUS )
 			{
 				sign = 0;
-				token = &scanner.GetNextToken();
+				token = &scanner.getNextToken();
 			}
 
 			// check if not number
-			if( token->code != scanner_t::TC_NUMBER )
+			if( token->code != Scanner::TC_NUMBER )
 			{
 				PARSE_ERR_EXPECTED( "number" );
 				return false;
@@ -76,7 +76,7 @@ template <typename type_t> bool ParseArrOfNumbers( scanner_t& scanner, bool pare
 		// put the number in the arr and do typecasting from int to float
 		type_t nmbr;
 
-		if( token->type == scanner_t::DT_FLOAT )
+		if( token->type == Scanner::DT_FLOAT )
 			nmbr = static_cast<type_t>( token->value.float_ );
 		else
 			nmbr = static_cast<type_t>( token->value.int_ );
@@ -87,8 +87,8 @@ template <typename type_t> bool ParseArrOfNumbers( scanner_t& scanner, bool pare
 	// the last thing is the right bracket
 	if( paren )
 	{
-		token = &scanner.GetNextToken();
-		if( token->code != scanner_t::TC_RBRACKET )
+		token = &scanner.getNextToken();
+		if( token->code != Scanner::TC_RBRACKET )
 		{
 			PARSE_ERR_EXPECTED( "}" );
 			return false;

+ 7 - 7
src/uncategorized/map.cpp

@@ -1,7 +1,7 @@
 #include <limits>
 #include "map.h"
 #include "mesh.h"
-#include "scanner.h"
+#include "Scanner.h"
 #include "parser.h"
 #include "resource.h"
 #include "camera.h"
@@ -185,16 +185,16 @@ bool map_t::Load( const char* filename )
 {
 	DEBUG_ERR( meshes.size() != 0 ); // meshes vector should be empty
 
-	scanner_t scanner;
-	const scanner_t::token_t* token;
-	if( !scanner.LoadFile( filename ) ) return false;
+	Scanner scanner;
+	const Scanner::Token* token;
+	if( !scanner.loadFile( filename ) ) return false;
 
 	do
 	{
-		token = &scanner.GetNextToken();
+		token = &scanner.getNextToken();
 
 		// strings is what we want in this case... please let it be G-Strings
-		if( token->code == scanner_t::TC_STRING )
+		if( token->code == Scanner::TC_STRING )
 		{
 			mesh_t* mesh = rsrc::meshes.Load( token->value.string );
 			if( !mesh ) return false;
@@ -202,7 +202,7 @@ bool map_t::Load( const char* filename )
 			meshes.push_back( mesh );
 		}
 		// end of file
-		else if( token->code == scanner_t::TC_EOF )
+		else if( token->code == Scanner::TC_EOF )
 		{
 			break;
 		}

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません