aboutsummaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-03-01 17:23:43 +0100
committertomsmeding <tom.smeding@gmail.com>2017-03-01 17:23:43 +0100
commit0e7a419f55dfed12fd60a0cd41be324a398673f9 (patch)
treefc582be239eb94573dc3451c8cc01fa8e0db0d39 /main.cpp
parentfe009c64ef688dc0342752e728c011c855daeaca (diff)
Execute some instructions!
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/main.cpp b/main.cpp
index ce93d37..a4c8714 100644
--- a/main.cpp
+++ b/main.cpp
@@ -63,8 +63,13 @@ void lowercase(string &str){
Argument parseArgument(const string &str,const unordered_map<string,Location> &labels,Location ip){
if(str[0]=='#'||str[0]=='%'){
bool remote=str[0]=='%';
- if(isdigit(str[1]))return {arg_t::var,remote,atoi(str.data()+1),{}};
- else return {arg_t::name,remote,0,str.substr(1)};
+ if(isdigit(str[1])){
+ int num=atoi(str.data()+1);
+ assert(num>=1&&num<=20);
+ return {arg_t::var,remote,num,{}};
+ } else {
+ return {arg_t::name,remote,0,str.substr(1)};
+ }
} else if(str[0]=='@'){
if(labels.find(str.substr(1))==labels.end()){
return {arg_t::undeflabel,false,0,str.substr(1)};
@@ -220,6 +225,7 @@ int main(int argc,char **argv){
Robot &r=world.create(&t,2,t.banks.size(),false);
for(int i=0;i<(int)t.banks.size();i++){
r.load(i,t.banks[i]);
+ r.active=1;
}
}