fixed an error in README

This commit is contained in:
Valk Richard Li 2021-06-12 01:23:06 +08:00
parent 9f30f45774
commit de305d26ad
3 changed files with 16 additions and 22 deletions

View File

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

View File

@ -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;
}

View File

@ -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;
}