This commit is contained in:
Valk Richard Li 2020-07-19 10:54:59 -07:00 committed by GitHub
parent e2cefa124e
commit 352735a843
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 3 deletions

View File

@ -129,7 +129,8 @@ enum parse_error
dynamic_id_not_end,
multi_assign_lack_val,
lack_definition,
lack_loop_iter
lack_loop_iter,
lack_func_content
};
void error_info(int line,int error_type,std::string error_str="")
@ -163,6 +164,7 @@ void error_info(int line,int error_type,std::string error_str="")
case multi_assign_lack_val:detail="multi-assignment lacks value list.";break;
case lack_definition: detail="expected a definition expression here.";break;
case lack_loop_iter: detail="expected an iterator to loop through.";break;
case lack_func_content: detail="expected arguments or expression block here.";break;
}
std::cout<<detail<<std::endl;
return;

View File

@ -370,6 +370,12 @@ nasal_ast nasal_parse::func_gen()
++error;
return node;
}
if(tok_list[ptr].type!=tok_left_curve && tok_list[ptr].type!=tok_left_brace)
{
++error;
error_info(error_line,lack_func_content);
return node;
}
if(tok_list[ptr].type==tok_left_curve)
{
node.add_child(args_list_gen());
@ -531,7 +537,7 @@ nasal_ast nasal_parse::exprs_gen()
{
node.add_child(expr());
++ptr;
if(ptr<tok_list_size || tok_list[ptr].type==tok_semi)
if(ptr<tok_list_size && tok_list[ptr].type==tok_semi)
++ptr;
else if(node.get_children().empty() || need_semi_check(node.get_children().back()))
{
@ -779,7 +785,15 @@ nasal_ast nasal_parse::scalar()
else if(tok_list[ptr].type==tok_identifier)
node=id_gen();
else if(tok_list[ptr].type==tok_func)
{
if(ptr+1<tok_list_size && tok_list[ptr+1].type==tok_identifier)
{
++ptr;
node=id_gen();
}
else
node=func_gen();
}
else if(tok_list[ptr].type==tok_left_bracket)
node=vector_gen();
else if(tok_list[ptr].type==tok_left_brace)