Spaces in file name causes compilition issue

Monkey Forums/Monkey Bug Reports/Spaces in file name causes compilition issue

therevills(Posted 2016) [#1]
When trying to compile the follow with a file called "test file.monkey", it generates an error:



Error output:
../main.cpp:4584:22: error: expected initializer before 'file_x'
 extern Float bb_test file_x;
                      ^
../main.cpp: In member function 'virtual int c_Game::p_OnUpdate()':
../main.cpp:4699:2: error: 'bb_test' was not declared in this scope
  bb_test file_x=bb_test file_x+FLOAT(1.0);
  ^
../main.cpp:4699:10: error: expected ';' before 'file_x'
  bb_test file_x=bb_test file_x+FLOAT(1.0);
          ^
../main.cpp: In member function 'virtual int c_Game::p_OnRender()':
../main.cpp:4710:23: error: 'bb_test' was not declared in this scope
  bb_graphics_DrawRect(bb_test file_x,Float(bb_app_DeviceHeight()/2),FLOAT(10.0),FLOAT(10.0));
                       ^
../main.cpp: At global scope:
../main.cpp:6416:15: error: expected initializer before 'file_x'
 Float bb_test file_x;
               ^
../main.cpp: In function 'int bbInit()':
../main.cpp:6481:2: error: 'bb_test' was not declared in this scope
  bb_test file_x=FLOAT(.0);
  ^
../main.cpp:6481:10: error: expected ';' before 'file_x'
  bb_test file_x=FLOAT(.0);
          ^
make: *** [build/Debug/main.o] Error 1
makefile:55: recipe for target 'build/Debug/main.o' failed
TRANS FAILED: Error executing 'make CCOPTS=" -O0" OUT="Debug/MonkeyGame"', return code=2
Abnormal program termination.
 Exit code: -1



Derron(Posted 2016) [#2]
Mark's default "mung(blubb)" wont work here ... unless he replaces spaces (and things like umlauts) with something "useable as variable name".

Normally you would think, doing Replace("_","__").Replace(" ","_") should do ... but this isn't absolutely true as you have to take care of not munging filenames when it comes to output (binary files, asset links...). Else you end up patching things you might not are allowed to (eg. dev wants the " " to be kept in the output names). So it depends on how Mark handles filenames - if there is one "mungFileName"-property it should be easily done, if not, he might have to run through the code replacing fileName with the munged one on certain spots.

Ah... and once you (Mark) fix the issue, you might think about handling unicode or simple "non 'AZaz09_-' characters" ... you need to cleanup such things too, or warn the user of the filenames containing invalid characters (think of a "löve2d.monkey" which might lead to some trouble - eg if "lve2d.monkey" exists too).

Suggestion: invalid character found: give the user a hint instead of blind compilation tries.


bye
Ron


marksibly(Posted 2016) [#3]
From the docs:


The name of the module scope is the same as the name of the file (minus the directory path and file extension), so the names of Monkey source files must also be valid Monkey identifiers.



The main problem is that even if you mung the filepaths up correctly in the output code, monkey code still needs to be able to reference modules using a valid monkey identifier for use with import, or in 'modname.blah' expressions.

The error message could probably be clearer though...


therevills(Posted 2016) [#4]
The error message could probably be a clearer though...

Yeah that would be good, this was found by a new user over on bb.com.