In line 0, Expression expected Error (Nand2tetris CPU-emulator) - nand2tetris

This is not a duplicate of this one, as I don't have any syntax error -- I only got two lines of code, so I am certain!
Note:
I did remember to save BasicLoop.asm before attempting to load it.
I can change the .asm code to whatever I like, the error persists.

Try deleting the file BasicLoop.asm and then create a new one without using any VM-Translator.
I tried reproducing the error, but it never occured.
The following might be useful if you are developing VM-Translator:
I too got stuck on somewhat similar error saying:
end of line expected. '0' is found
While examining my CodeWriter, I found that it wrote #0, #{0} and on someplaces it combined 2 seperate codes as 0;JMP0 or 0;JMP D=A
Hope it helps.

It happened to me a number of times as well. The first thing to recognize is that the line 0 reference is meaningless. The problem may be anywhere in your assembly code.
You should look through every line of your assembly code, check that there are no compound commands like:
#SPD=M
when it should be
#SP
D=M
Also, make sure you don't have (#LABEL) instead of just (LABEL). That could do it as well.

Related

TCL stack trace not showing desired error line number

The -errorline element of the return options dictionary for the following TCL script is "2":
puts [info patchlevel]
try {
error "this is an error"
} trap {} {result ropts} {
puts $result
puts $ropts
}
How do I get the stacktrace to display the line number in the source file where the error was actually raised (ie. line 4 instead of 2) ?
Example screenshot:
Tcl often has that information available, but doesn't use it.
It has the information available because you have a chance to retrieve it with info frame and getbytecode (which is in the tcl::unsupported namespace, mostly because we reserve the right to change how the bytecodes themselves work at any time). I'm not quite sure if that would work in your specific case, but if you put your test code in a procedure then it definitely would. (There are complexities here with fragility that I don't fully understand.)
It doesn't use it because, for backward-compatibility with existing tooling, it uses the line numbers it was using prior to the creation of the machinery to support info frame. Those line numbers are relative to the local script fragment (which is whatever reports the line number in the error info trace first); in this case, that is the body of the try.
I don't like that it works like that at all. However, changing things is a bit tricky because we'd need to also figure out what else to report and what to do in the cases where the information genuinely isn't available (such as for automatically-generated code where things are assembled from many strings from many lines).

Arduino and STL

I know this has been posted all over the place but I can not find what I need. I have a Arduino project that I must have vector or another way of allocating a dynamic array safely. I am trying to get the "StandardCplusplus" library to compile but I am getting an error
'Starting combiner'
"C:\Eclipse\eclipse\arduinoPlugin\tools\arduino\avr-gcc\4.8.1-arduino5/bin/avr-gcc" -Os -Wl,--gc-sections,--relax -mmcu=atmega2560 -o "D:/Development/MegaTesting/Release/MegaTesting.elf" ./.ino.cpp.o ./libraries/StandardCplusplus/algorithm.cpp.o ./libraries/StandardCplusplus/associative_base.cpp.o ./libraries/StandardCplusplus/bitset.cpp.o ./libraries/StandardCplusplus/char_traits.cpp.o ./libraries/StandardCplusplus/complex.cpp.o ./libraries/StandardCplusplus/del_op.cpp.o ./libraries/StandardCplusplus/del_opnt.cpp.o ./libraries/StandardCplusplus/del_opv.cpp.o ./libraries/StandardCplusplus/del_opvnt.cpp.o ./libraries/StandardCplusplus/deque.cpp.o ./libraries/StandardCplusplus/eh_alloc.cpp.o ./libraries/StandardCplusplus/eh_globals.cpp.o ./libraries/StandardCplusplus/exception.cpp.o ./libraries/StandardCplusplus/fstream.cpp.o ./libraries/StandardCplusplus/func_exception.cpp.o ./libraries/StandardCplusplus/iomanip.cpp.o ./libraries/StandardCplusplus/ios.cpp.o ./libraries/StandardCplusplus/iostream.cpp.o ./libraries/StandardCplusplus/istream.cpp.o ./libraries/StandardCplusplus/iterator.cpp.o ./libraries/StandardCplusplus/limits.cpp.o ./libraries/StandardCplusplus/list.cpp.o ./libraries/StandardCplusplus/locale.cpp.o ./libraries/StandardCplusplus/map.cpp.o ./libraries/StandardCplusplus/new_handler.cpp.o ./libraries/StandardCplusplus/new_op.cpp.o ./libraries/StandardCplusplus/new_opnt.cpp.o ./libraries/StandardCplusplus/new_opv.cpp.o ./libraries/StandardCplusplus/new_opvnt.cpp.o ./libraries/StandardCplusplus/numeric.cpp.o ./libraries/StandardCplusplus/ostream.cpp.o ./libraries/StandardCplusplus/queue.cpp.o ./libraries/StandardCplusplus/set.cpp.o ./libraries/StandardCplusplus/sstream.cpp.o ./libraries/StandardCplusplus/stack.cpp.o ./libraries/StandardCplusplus/stdexcept.cpp.o ./libraries/StandardCplusplus/streambuf.cpp.o ./libraries/StandardCplusplus/string.cpp.o ./libraries/StandardCplusplus/support.cpp.o ./libraries/StandardCplusplus/typeinfo.cpp.o ./libraries/StandardCplusplus/utility.cpp.o ./libraries/StandardCplusplus/valarray.cpp.o ./libraries/StandardCplusplus/vector.cpp.o arduino.ar "-LD:/Development/MegaTesting/Release" -lm
arduino.ar(new.cpp.o): In function `operator new[](unsigned int)':
C:/Eclipse/eclipse/arduinoPlugin/packages/arduino/hardware/avr/1.6.10/cores/arduino/new.cpp:26: multiple definition of `operator new[](unsigned int)'
./libraries/StandardCplusplus/new_opv.cpp.o:C:/Eclipse/eclipse/arduinoPlugin/packages/arduino/hardware/avr/1.6.10/libraries/StandardCplusplus/new_opv.cpp:24: first defined here
c:/eclipse/eclipse/arduinoplugin/tools/arduino/avr-gcc/4.8.1-arduino5/bin/../lib/gcc/avr/4.8.1/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions
arduino.ar(new.cpp.o): In function `operator new(unsigned int)':
C:/Eclipse/eclipse/arduinoPlugin/packages/arduino/hardware/avr/1.6.10/cores/arduino/new.cpp:22: multiple definition of `operator delete[](void*)'
makefile:83: recipe for target 'MegaTesting.elf' failed
./libraries/StandardCplusplus/del_opv.cpp.o:C:/Eclipse/eclipse/arduinoPlugin/packages/arduino/hardware/avr/1.6.10/libraries/StandardCplusplus/del_opv.cpp:25: first defined here
collect2.exe: error: ld returned 1 exit status
make: *** [MegaTesting.elf] Error 1
06:23:57 Build Finished (took 21s.666ms)
I have searched here and online and there seems to be a bunch of fixes but none of them work. There was some mention of including a pnew.cpp in one of your files but this file is not in the library anywhere.
All my code contains that I am trying to compile is
#include "StandardCplusplus.h"
#include "Arduino.h"
void setup(void) {
Serial.begin(57600);
}
void loop(void) {
}
There are a couple of versions of this library out there and I have tried the two main forks that I can find and both of them generate this error.
Also I am using Eclipse with the Arduino AVR plugin to compile.
Edit
I thought that commenting out the lines did work until I tried to use a vector. Once I did the StandardCplusplus library got really mad saying that the function new was not defined.
I think that there needs to be something done to the StandardCplusplus library like in new/new_opv delete/delete_opv files? Or is there a better way?
Edit - 2
Alright so I went into the files:
StandardCplusplus/new_opv.h
StandardCplusplus/del_opv.h
And commented out the bodies for the functions and everything seems to be happy. I did a simple test and everything looks like it is working but now I am concerned that I might of removed something that something else in the library might need, can anyone tell me if my changes will hurt anything?
Edit - 3
Well the last fix didn't work so I tried going to another library all together and I am allot closer. I Downloaded this STL-AVR library and had to make a minor edit to vector.h now I am having problems with the pnew.cpp file. Looks like the template is calling a "new" function that is now defined in arduino but if I try to comment out this body I get that it is not defined. I am sure this is some sort of order of the includes or missing one can anyone help?
Those STL like libary versions you have were put together before operator new was added to the Arduino core. Now they are in the core you are getting a multiple definition error.
You can go into your core and comment out the bits causing the multiple definition error.
You can probably just get away with commenting out the function definitions in the .cpp:
C:/Eclipse/eclipse/arduinoPlugin/packages/arduino/hardware/avr/1.6.10/cores/arduino/new.cpp
If you still get the errors, also comment out the function declarations in new.h, but you shouldn't need to as multiple declarations are allowed, only definitions must be unique.

Invalid method when method is valid

I have just started a new version of my Crysis Wars Server Side Modification called InfinityX. For better management, I have put the functions inside tables as it looks neater and I can group functions together (like Core.PlayerHandle:GetIp(player)), but I have ran into a problem.
The problem is that the specified method to get the players' name, player:GetName() is being seen as an invalid method, when the method actually is completely valid.
I would like to know if using the below structure is causing a problem and if so, how to fix it. This is the first time I've used this structure for functions, but it is already proving easier than the old method I was using.
The Code:
Event =
{
PlayerConnect = function(player)
Msg.All:CenteredConsole("$4Event$8 (Connect)$9: $3"..player:GetName().." on channel "..player.actor:GetChannel());
System.LogAlways(Default.Tag.."Incoming Connect on Channel "..player.actor:GetChannel());
Event:Log("Connect", player);
end;
};
The below code works when I bypass the function and put the code directly where it's needed:
Msg.All:CenteredConsole("$4Event$8 (Connect)$9: $3"..player:GetName().." on channel "..player.actor:GetChannel());
System.LogAlways(Default.Tag.."Incoming Connect on Channel "..player.actor:GetChannel());
The Error:
[Warning] [Lua Error] infinityx/main/core.events.lua:23: attempt to call method 'GetName' (a nil value)
PlayerConnect, (infinityx/main/core.events.lua: 23)
ConnectScript, (infinityx/main/core.main.lua: 52)
OnClientEnteredGame, (scripts/gamerules/instantaction.lua: 511)
(null) (scripts/gamerules/teaminstantaction.lua: 520)
Any clarification would be appreciated.
Thanks :)
Well, as PlayerConnect is inside the table Event, and you are calling with a ":", add self as first arg in the function, like:
PlayerConnect = function(self, player)
Clearly, player in the first block of code is not the same as player in the second block of code. The problem must be that the caller of Event.PlayerConnect is not passing the same value.
To test that your Event.PlayerConnect function works, try this in the same place as your second block of code:
Event.PlayerConnect(player)
That should work as you expect.
So, the problem comes down to how Event.PlayerConnect is called without the second block of code. I'm not familiar with that game engine so I don't know how it is done. Perhaps reviewing the documentation and/or debugging that area would help. If you print(player) or call the equivalent log function in both cases, you should see they are different. If you can't run in a debugger, you can still get a stack trace with print(debug.traceback("Accessing player, who's value is: "..player)). If there is indeed some kind of table-based player object in both cases, you can try comparing their fields to see how they are different. You might need to write a simple dumping function to help with that.

Why does $my_item->save fail with Rose::DB::Object?

I am trying to do a simple addition of data to a database table (PostgreSQL). At first, I couldn't even get a simple
$my_item = $_item_class->new(...);
to work. I discovered I had spelled a field differently in my code from what I had in my "model" code.
But, now, this is working, but when I try:
$my_item->save;
it seems an exception is thrown. All this is occurring in an eval {...} structure and I would like to catch the exception and see what is going wrong, but I don't know how to do that.
Why would something like the "save" be failing here? I have checked everything, and all seems right (of course!).
And, how do I catch the exception that seems to be being thrown?
Thank you!
I figured all this out myself. It was simple. I had duplicated a field in my class somehow when I had done an edit to it. That was all. The class just had two identically named fields specified in the hash table in the class, both with identical characteristics. When I removed one of these, the code worked.
With regard to my second question about how to catch the exception, I had to learn how to have an
if ($#) {
.
.
.
}
right after my "eval {...}" structure. Because I am new to Perl, I didn't understand that. But, it was actually pretty easy to figure out. My problem was that I was working from some code as a model for me that didn't do that but named specific exceptions that were thrown in its "eval {...}" code. So, I thought that I had to have the names of exceptions that could be thrown by Rose::DB::Object calls, but I couldn't find any such exceptions in the documentation. When I learned about "if ($#) {...}", I was able to print out the reported exception in $# and from that I was able to see the problem with the duplicate field I mentioned above.
That was all there was to it. Everything is working just fine now.

Bada exceptions on RemoveAllControls call

What's the deal with this, it's driving me crazy?
I run this piece of code;
if(GetControlCount() > 0)
{
RemoveAllControls();
}
And as soon as I step over the RemoveAllControls(); line I get the following exceptions;
12557.709,EXCEPTION,P44,T00,A174,Osp::Ui::Container::GetControlAt (392) > [E_OBJ_NOT_FOUND] Unable to find the specified control.
12557.709,EXCEPTION,P44,T00,A174,Osp::Ui::Container::RemoveControl (247) > [E_OBJ_NOT_FOUND] Propagated.
If the problem is that there are no controls, surely my check should be solving this? So what's the deal?
I have also tried naming the controls individually, null checking them an then removing them if they are not null, but again, I get these exceptions.
12557.709,EXCEPTION,P44,T00,A174,Osp::Ui::Container::GetControlAt (392) > [E_OBJ_NOT_FOUND] Unable to find the specified control.
12557.709,EXCEPTION,P44,T00,A174,Osp::Ui::Container::RemoveControl (247) > [E_OBJ_NOT_FOUND] Propagated.
Is it possible that these are being flagged from a different place in your code? You should try and catch the result to make doubly sure it is coming from where you think. There are several variations of Control::Remove and the AppLog doesn't exactly match the ones you call so perhaps you call other, similarly named ones elsewhere and you are seeing their internal implementation(s) throwing exceptions.