Skip to content

Commit

Permalink
Allow msgbuild qualifier to be specified for anonymous function
Browse files Browse the repository at this point in the history
  • Loading branch information
positively-charged committed Dec 9, 2016
1 parent 594ff0b commit 603650e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/parse/dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1853,6 +1853,19 @@ struct func_aspec* alloc_aspec_impl( void ) {
return impl;
}

void p_read_anon_func( struct parse* parse, struct func* func ) {
// Read header.
if ( parse->tk == TK_FUNCTION ) {
p_read_tk( parse );
// Read qualifiers.
if ( parse->tk == TK_MSGBUILD ) {
func->msgbuild = true;
p_read_tk( parse );
}
}
p_read_func_body( parse, func );
}

void p_read_script( struct parse* parse ) {
struct script_reading reading;
init_script_reading( &reading, &parse->tk_pos );
Expand Down
3 changes: 2 additions & 1 deletion src/parse/expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,7 @@ void read_memcpy( struct parse* parse, struct expr_reading* reading ) {
void read_paren( struct parse* parse, struct expr_reading* reading ) {
switch ( p_peek( parse ) ) {
case TK_BRACE_L:
case TK_FUNCTION:
read_anon_func( parse, reading );
break;
default:
Expand All @@ -1346,7 +1347,7 @@ void read_anon_func( struct parse* parse, struct expr_reading* reading ) {
func->type = FUNC_USER;
func->impl = impl;
func->return_spec = SPEC_AUTO;
p_read_func_body( parse, func );
p_read_anon_func( parse, func );
p_test_tk( parse, TK_PAREN_R );
p_read_tk( parse );
func->object.pos = impl->body->pos;
Expand Down
1 change: 1 addition & 0 deletions src/parse/phase.h
Original file line number Diff line number Diff line change
Expand Up @@ -530,5 +530,6 @@ void p_pop_source( struct parse* parse );
void p_create_cmdline_library_links( struct parse* parse );
void p_read_local_using( struct parse* parse, struct list* output );
bool p_read_let( struct parse* parse );
void p_read_anon_func( struct parse* parse, struct func* func );

#endif

0 comments on commit 603650e

Please sign in to comment.