This commit is contained in:
Valk Richard Li 2019-09-21 03:26:30 -05:00 committed by GitHub
parent a3d44d47f6
commit c874f9cd19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 3 deletions

View File

@ -325,6 +325,24 @@ void nasal_parser::list_search_expr()
std::cout<<"\" in list call."<<std::endl;
break;
}
get_token();
if(this_token.type!=__right_bracket)
{
if(this_token.type==__semi)
parse.push(this_token);
++error;
std::cout<<">>[Error] line "<<this_token.line<<": expect a \']\' when calling a list."<<std::endl;
return;
}
get_token();
switch(this_token.type)
{
case __left_bracket:list_search_expr();break;
case __dot:hash_search_expr();break;
default:
parse.push(this_token);
break;
}
return;
}
void nasal_parser::hash_search_expr()
@ -339,8 +357,8 @@ void nasal_parser::hash_search_expr()
get_token();
switch(this_token.type)
{
case __left_curve:break;
case __left_bracket:break;
case __left_curve:call_function_expr();break;
case __left_bracket:list_search_expr();break;
case __dot:hash_search_expr();break;
case __semi:parse.push(this_token);break;
default:
@ -387,6 +405,15 @@ void nasal_parser::call_function_expr()
std::cout<<">>[Error] line "<<this_token.line<<": expect a \')\'."<<std::endl;
return;
}
get_token();
switch(this_token.type)
{
case __left_bracket:list_search_expr();break;
case __dot:hash_search_expr();break;
default:
parse.push(this_token);
break;
}
return;
}
void nasal_parser::identifier_begin_expr()

View File

@ -9,4 +9,7 @@ var id;
var id=[1,2,3,4];
var id={id:"str"};
id();
id.id();
id.id();
id.id.id();
id[0].id.id(id,"str",1,2,3,4).id[10];
id(0)[1];