Bug fixed

This commit is contained in:
Valk Richard Li 2019-10-19 19:32:34 +08:00 committed by GitHub
parent b68c15b874
commit ee57994da6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 5 deletions

View File

@ -458,7 +458,7 @@ class nasal_lexer
else if((*i).content=="<=") else if((*i).content=="<=")
(*i).type=__cmp_less_or_equal; (*i).type=__cmp_less_or_equal;
} }
else if(((*i).content==";") || ((*i).content==",") || ((*i).content=="=") || ((*i).content==":") || ((*i).content==".") || ((*i).content=="?") || ((*i).content=="%") || ((*i).content=="$") || ((*i).content=="`") || ((*i).content=="^") || ((*i).content=="@")) else if(((*i).content==";") || ((*i).content==",") || ((*i).content=="=") || ((*i).content==":") || ((*i).content==".") || ((*i).content=="?") || ((*i).content=="|") || ((*i).content=="%") || ((*i).content=="$") || ((*i).content=="`") || ((*i).content=="^") || ((*i).content=="@"))
{ {
char c=(*i).content[0]; char c=(*i).content[0];
switch(c) switch(c)

View File

@ -913,7 +913,7 @@ void nasal_parser::loop_expr()
switch(this_token.type) switch(this_token.type)
{ {
case __var:definition_expr();break; case __var:definition_expr();break;
case __id:calculation_expr();break; case __id:parse.push(this_token);calculation_expr();break;
case __semi:parse.push(this_token);break; case __semi:parse.push(this_token);break;
default: default:
std::cout<<">>[Error] line "<<this_token.line<<": \'"; std::cout<<">>[Error] line "<<this_token.line<<": \'";
@ -1023,7 +1023,7 @@ void nasal_parser::mul_div_operator_expr()
case __left_curve:parse.push(this_token);calculation_expr();break; case __left_curve:parse.push(this_token);calculation_expr();break;
default: default:
++error; ++error;
std::cout<<">>[Error] line "<<this_token.line<<": expect a data after this operator."<<std::endl; std::cout<<">>[Error] line "<<this_token.line<<": expect a data after operator '*' or '/'."<<std::endl;
return; return;
break; break;
} }
@ -1047,7 +1047,7 @@ void nasal_parser::one_operator_expr()
case __left_curve:parse.push(this_token);calculation_expr();break; case __left_curve:parse.push(this_token);calculation_expr();break;
default: default:
++error; ++error;
std::cout<<">>[Error] line "<<this_token.line<<": expect a data after this operator."<<std::endl; std::cout<<">>[Error] line "<<this_token.line<<": expect a data after operator '!' or '-'."<<std::endl;
return; return;
break; break;
} }
@ -1081,7 +1081,7 @@ void nasal_parser::calculation_expr()
else else
{ {
++error; ++error;
std::cout<<">>[Error] line "<<this_token.line<<": expect a scalar at this place."<<std::endl; std::cout<<">>[Error] line "<<this_token.line<<": expect a scalar before operator '+' , '-' , '*' , '/' or '~'."<<std::endl;
return; return;
} }
get_token(); get_token();
@ -1119,6 +1119,10 @@ void nasal_parser::calculation_expr()
} }
break; break;
case __semi:parse.push(this_token);return;break; case __semi:parse.push(this_token);return;break;
case __unknown_operator:
++error;
std::cout<<">>[Error] line "<<this_token.line<<": __unknown_operator '"<<this_token.content<<"'."<<std::endl;
return;break;
default:parse.push(this_token);return;break; default:parse.push(this_token);return;break;
} }
} }
@ -1195,6 +1199,8 @@ void nasal_parser::call_function_expr()
switch(this_token.type) switch(this_token.type)
{ {
case __left_curve: case __left_curve:
case __nor_operator:
case __sub_operator:
case __number: case __number:
case __string: case __string:
case __id:parse.push(this_token);calculation_expr();break; case __id:parse.push(this_token);calculation_expr();break;