Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


LUA-script gives: unexpected symbol near ' '


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 moboko   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 January 2004 - 12:38 AM

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()

Sponsor:

#2 Ironica   Members   -  Reputation: 128

Like
Likes
Like

Posted 21 January 2004 - 01:05 AM

Change:
#include <iostream.h>
to:
#include <iostream>
maybe?

#3 moboko   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 January 2004 - 01:21 AM

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.


#4 ashleymatheson   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 January 2004 - 01:30 AM

add

using namespace std;

#5 moboko   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 January 2004 - 02:03 AM

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...

#6 ashleymatheson   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 January 2004 - 11:50 AM

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.

#7 moboko   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 January 2004 - 12:01 PM

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...

#8 moboko   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 January 2004 - 01:20 PM

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 :-)....

#9 ashleymatheson   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 January 2004 - 10:12 AM

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]

#10 moboko   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 January 2004 - 12:17 PM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS