fixed an error in README
This commit is contained in:
parent
9f30f45774
commit
de305d26ad
|
@ -1,7 +1,5 @@
|
|||
# Nasal Script Language
|
||||
|
||||
[TOC]
|
||||
|
||||
## Introduction
|
||||
|
||||
[Nasal](http://wiki.flightgear.org/Nasal_scripting_language) is a script language that used in [FlightGear](https://www.flightgear.org/).
|
||||
|
@ -56,7 +54,7 @@ Use these commands to get version of interpreter:
|
|||
|
||||
> ./nasal -v | -version
|
||||
|
||||
Use these commands to get version of interpreter:
|
||||
Use these commands to get help:
|
||||
|
||||
> ./nasal -h | -help
|
||||
|
||||
|
|
9
main.cpp
9
main.cpp
|
@ -19,6 +19,7 @@ void help_interact()
|
|||
void help_cmd()
|
||||
{
|
||||
std::cout
|
||||
<<"nasal | use interactive interpreter.\n"
|
||||
<<"nasal -h -help | get help.\n"
|
||||
<<"nasal -v -version | get version of nasal interpreter.\n"
|
||||
<<"nasal filename | execute script file.\n";
|
||||
|
@ -153,7 +154,7 @@ int main(int argc,const char* argv[])
|
|||
}
|
||||
else if(argc==2 && (!strcmp(argv[1],"-h") || !strcmp(argv[1],"-help")))
|
||||
help_cmd();
|
||||
else if(argc==2)
|
||||
else if(argc==2 && argv[1][0]!='-')
|
||||
{
|
||||
file=argv[1];
|
||||
command="exec";
|
||||
|
@ -161,6 +162,10 @@ int main(int argc,const char* argv[])
|
|||
return 0;
|
||||
}
|
||||
else
|
||||
help_cmd();
|
||||
{
|
||||
std::cout
|
||||
<<"invalid command.\n"
|
||||
<<"use nasal -h to get help.\n";
|
||||
}
|
||||
return 0;
|
||||
}
|
25
test/bf.nas
25
test/bf.nas
|
@ -151,8 +151,6 @@ var bf=func(program)
|
|||
{
|
||||
var paper=[];
|
||||
setsize(paper,131072);
|
||||
#for(var i=0;i<131072;i+=1)
|
||||
# paper[i]=0;
|
||||
var ptr=0;
|
||||
var s=program;
|
||||
var len=size(s);
|
||||
|
@ -213,8 +211,8 @@ var bf=func(program)
|
|||
return;
|
||||
}
|
||||
var label=pop(stack);
|
||||
append(code,[jt,label]);
|
||||
code[label][1]=size(code)-1;
|
||||
append(code,[jt,label-1]);
|
||||
code[label][1]=size(code)-2;
|
||||
}
|
||||
}
|
||||
if(size(stack))
|
||||
|
@ -227,25 +225,18 @@ var bf=func(program)
|
|||
for(var i=0;i<len;i+=1)
|
||||
{
|
||||
if(code[i][0]==add)
|
||||
{
|
||||
paper[ptr]+=code[i][1];
|
||||
if(paper[ptr]>255)
|
||||
paper[ptr]-=256;
|
||||
elsif(paper[ptr]<0)
|
||||
paper[ptr]+=256;
|
||||
}
|
||||
elsif(code[i][0]==mov)
|
||||
ptr+=code[i][1];
|
||||
elsif(code[i][0]==in)
|
||||
paper[ptr]=input()[0];
|
||||
elsif(code[i][0]==jt and paper[ptr])
|
||||
i=code[i][1];
|
||||
elsif(code[i][0]==jf and !paper[ptr])
|
||||
i=code[i][1];
|
||||
elsif(code[i][0]==out)
|
||||
print(chr(paper[ptr]));
|
||||
elsif(code[i][0]==jt and paper[ptr])
|
||||
i=code[i][1]-1;
|
||||
elsif(code[i][0]==jf and !paper[ptr])
|
||||
i=code[i][1]-1;
|
||||
elsif(code[i][0]==in)
|
||||
paper[ptr]=input()[0];
|
||||
}
|
||||
print('\n');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue