LUA-script gives: unexpected symbol near ' '
Hello,
I am new to Lua and when I run the following code, I always get the same errormessage saying: "test.lua:1: unexpected symbol near '' '' ".. Am I forgeting something?.. Here is my samplecode:
#include <iostream.h>
extern "C"
{
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
}
#include <luabind/luabind.hpp>
using namespace luabind;
class CTest
{
public:
CTest(){};
void Boo(){ cout << "LLaP"; }
};
int main( int argc , char* argv [])
{
lua_State* luaVM = lua_open();
luabind::open( luaVM);
module( luaVM)
[
class_("Test")
.def(constructor<>())
.def("Boo", &CTest::Boo)
];
lua_dofile( luaVM, "test.lua");
lua_close( luaVM);
cin.get();
return 0;
}
*----- test.lua -----*
T = Test()
T:Boo()
I changed it in #include <iostream> but when I do that I''ll get compiler-errors :
error C2065: ''cout'' : undeclared identifier
error C2297: ''<<'' : illegal, right operand has type ''char [5]''
error C2065: ''cin'' : undeclared identifier
error C2228: left of ''.get'' must have class/struct/union type
Error executing cl.exe.
error C2065: ''cout'' : undeclared identifier
error C2297: ''<<'' : illegal, right operand has type ''char [5]''
error C2065: ''cin'' : undeclared identifier
error C2228: left of ''.get'' must have class/struct/union type
Error executing cl.exe.
Of course... using namespace std!
I changed it and it compiled but I still get the former error:
test.lua:1: unexpected symbol near '' '' ... I don''t understand why...
I changed it and it compiled but I still get the former error:
test.lua:1: unexpected symbol near '' '' ... I don''t understand why...
quote: Original post by moboko
Of course... using namespace std!
I changed it and it compiled but I still get the former error:
test.lua:1: unexpected symbol near '' '' ... I don''t understand why...
I can''t really take a peek at the code just yet to see what''s going on. I''m in the midst of a move right now across the country and my home gear is still in transit. I''ll take a peek at the problem here in the next couple of days (when my stuff lands), unless you get a fix before hand.
Humble,Yet l33t
Okay, thx for the effort Ashley Matheson... good luck with your "translation" through the country.... I''ll have cleaned and rebuild the Lua5.0 and the luabind-b6 libs. Tomorrow I''ll test them and see if I''ll get the same error...
Aaaah.... I solved the problem... I used notepad and/or wordpad to edit my scriptfiles, these editors set extra control-characters in the files invisible to the eye, but visible to
the lua-interpreter... using my plain old dos-edit solves the problem :-)....
the lua-interpreter... using my plain old dos-edit solves the problem :-)....
quote: Original post by moboko
Aaaah.... I solved the problem... I used notepad and/or wordpad to edit my scriptfiles, these editors set extra control-characters in the files invisible to the eye, but visible to
the lua-interpreter... using my plain old dos-edit solves the problem :-)....
Really? I've never had that problem with lua. Even older version.
And it's Ash.
[edited by - ashleymatheson on January 23, 2004 5:13:38 PM]
Humble,Yet l33t
So You didn''t have this problem I had with the control-chars Mr. Ashley?.... hmmm, that sounds strange indeed... I noticed by accident that the filesize was different between 2 lua-scripts that looked apparently the "same"... So I opened the file that had a bigger size and saw a couple of extra control-chars in it.... The only thing I noticed aside from this was when I used "setlocale( LC_ALL, NULL);" before the lua_dofile... the lua_dofile returned a different error-code.... maybe it has something to do with the language and region settings but I am not familiar with that, so it remains a guess to me... thanks for your reactions and have a nice time on your new location Mr. Ashley.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement