diff --git a/bin/hilfe b/bin/hilfe index 3afde322a33e609a159e91793ef9bbeca5f3da04..65c20f3f292b1e4d2fc670eac805c0c09e0ec8eb 100755 --- a/bin/hilfe +++ b/bin/hilfe @@ -21,12 +21,19 @@ /* #define DEBUG */ + mapping variables=([]); string *functions=({}); string *function_names=({}); mapping query_variables() { return variables; } /* do nothing */ +void my_write(mixed x) +{ + write(sprintf("%O",x)); +} + + object eval(string f) { string prog,file; @@ -176,14 +183,14 @@ void cut_buffer(int where) pos-=old-new; if(pos<0) pos=0; eq_pos-=old-new; if(eq_pos<0) eq_pos=-1; #ifdef DEBUG - write("CUT input = "+code_value(input,1)+" pos="+pos+"\n"); + write("CUT input = "+my_write(input)+" pos="+pos+"\n"); #endif } void print_version() { write(version()+ - " Running Hilfe v1.4 (Incremental Pike Frontend)\n"); + " Running Hilfe v1.5 (Incremental Pike Frontend)\n"); } @@ -214,8 +221,8 @@ int do_parse() { first_word=input[0..pos-1]; #ifdef DEBUG - write("First = "+code_value(first_word)+" pos="+pos+"\n"); - write("input = "+code_value(input)+"\n"); + write("First = "+my_write(first_word)+" pos="+pos+"\n"); + write("input = "+my_write(input)+"\n"); #endif switch(first_word) { @@ -370,6 +377,7 @@ mixed parse_function(string fun) case "mixed": case "program": case "function": + case "class": /* parse function */ if(eq_pos!=-1) break; /* it's a variable */ sscanf(fun,first_word+"%s",name); @@ -378,25 +386,20 @@ mixed parse_function(string fun) name=c[0]; c=c[1]; - if(c[0]=='(') + int i; + if((i=member_array(name,function_names))!=-1) { - int i; - if((i=member_array(name,function_names))!=-1) + b=functions[i]; + functions[i]=fun; + if(!eval("")) functions[i]=b; + }else{ + if(eval(fun)) { - b=functions[i]; - functions[i]=fun; - if(!eval("")) functions[i]=b; - }else{ - if(eval(fun)) - { - functions+=({fun}); - function_names+=({name}); - } + functions+=({fun}); + function_names+=({name}); } - return 1; - }else{ - write("Syntax error.\n"); } + return 1; } } @@ -482,6 +485,7 @@ mixed parse_statement(string ex) return 1; default: + if(ex==";") return 1; /* parse expressions */ a="mixed ___Foo4711() { return (mixed)("+ex[0..strlen(ex)-2]+"); }\n"; if(foo=eval(a)) @@ -505,7 +509,7 @@ void stdin(string s) object foo; #ifdef DEBUG - write("input: '"+code_value(s,1)+"'\n"); + write("input: '"+my_write(s)+"'\n"); #endif s=skipwhite(s); @@ -519,11 +523,6 @@ void stdin(string s) // if(!strlen(input)) write("> "); } -void my_write(mixed x) -{ - write(sprintf("%O",x)); -} - void signal_trap(int s) { clean_buffer();