nothing changed
This commit is contained in:
parent
ef9b781961
commit
385f0af17e
14
main.cpp
14
main.cpp
|
@ -46,6 +46,7 @@ void logo()
|
||||||
void die(const char* stage,std::string& filename)
|
void die(const char* stage,std::string& filename)
|
||||||
{
|
{
|
||||||
std::cout<<"["<<stage<<"] in <"<<filename<<">: error(s) occurred,stop.\n";
|
std::cout<<"["<<stage<<"] in <"<<filename<<">: error(s) occurred,stop.\n";
|
||||||
|
exit(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,10 +60,7 @@ void execute(std::string& file,std::string& command)
|
||||||
lexer.openfile(file);
|
lexer.openfile(file);
|
||||||
lexer.scanner();
|
lexer.scanner();
|
||||||
if(lexer.get_error())
|
if(lexer.get_error())
|
||||||
{
|
|
||||||
die("lexer",file);
|
die("lexer",file);
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(command=="--lex" || command=="-l")
|
if(command=="--lex" || command=="-l")
|
||||||
{
|
{
|
||||||
lexer.print_token();
|
lexer.print_token();
|
||||||
|
@ -70,10 +68,7 @@ void execute(std::string& file,std::string& command)
|
||||||
}
|
}
|
||||||
parse.main_process(lexer.get_token_list());
|
parse.main_process(lexer.get_token_list());
|
||||||
if(parse.get_error())
|
if(parse.get_error())
|
||||||
{
|
|
||||||
die("parse",file);
|
die("parse",file);
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(command=="--ast" || command=="-a")
|
if(command=="--ast" || command=="-a")
|
||||||
{
|
{
|
||||||
parse.get_root().print_ast(0);
|
parse.get_root().print_ast(0);
|
||||||
|
@ -82,16 +77,10 @@ void execute(std::string& file,std::string& command)
|
||||||
// first used file is itself
|
// first used file is itself
|
||||||
import.link(parse.get_root(),file);
|
import.link(parse.get_root(),file);
|
||||||
if(import.get_error())
|
if(import.get_error())
|
||||||
{
|
|
||||||
die("import",file);
|
die("import",file);
|
||||||
return;
|
|
||||||
}
|
|
||||||
codegen.main_progress(import.get_root(),import.get_file());
|
codegen.main_progress(import.get_root(),import.get_file());
|
||||||
if(codegen.get_error())
|
if(codegen.get_error())
|
||||||
{
|
|
||||||
die("code",file);
|
die("code",file);
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(command=="--code" || command=="-c")
|
if(command=="--code" || command=="-c")
|
||||||
{
|
{
|
||||||
codegen.print_byte_code();
|
codegen.print_byte_code();
|
||||||
|
@ -149,6 +138,7 @@ int main(int argc,const char* argv[])
|
||||||
std::cout
|
std::cout
|
||||||
<<"invalid argument(s).\n"
|
<<"invalid argument(s).\n"
|
||||||
<<"use nasal -h to get help.\n";
|
<<"use nasal -h to get help.\n";
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
import("lib.nas");
|
||||||
|
|
||||||
|
var trait={
|
||||||
|
get:func{return me.val;},
|
||||||
|
set:func(x){me.val=x;}
|
||||||
|
};
|
||||||
|
|
||||||
|
var class={
|
||||||
|
new:func(){
|
||||||
|
return {
|
||||||
|
val:nil,
|
||||||
|
parents:[trait]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var class2={
|
||||||
|
new:func(){
|
||||||
|
return {
|
||||||
|
val:nil,
|
||||||
|
parents:[trait],
|
||||||
|
set:func(x){me.val=typeof(x);}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var class_obj=[];
|
||||||
|
for(var i=0;i<10;i+=1){
|
||||||
|
append(class_obj,class.new());
|
||||||
|
class_obj[i].set(i);
|
||||||
|
}
|
||||||
|
for(var i=0;i<10;i+=1){
|
||||||
|
append(class_obj,class2.new());
|
||||||
|
class_obj[10+i].set(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach(var object;class_obj){
|
||||||
|
println(object.get(),' ',keys(object));
|
||||||
|
}
|
Loading…
Reference in New Issue