This commit is contained in:
John Kerl 2016-09-09 20:59:36 -04:00
parent 2f91d92bc9
commit f11141d2bb
6 changed files with 18 additions and 18 deletions

View file

@ -145,8 +145,8 @@ void mlr_dsl_ast_node_fprint(mlr_dsl_ast_node_t* pnode, FILE* o) {
char* mlr_dsl_ast_node_describe_type(mlr_dsl_ast_node_type_t type) {
switch(type) {
case MD_AST_NODE_TYPE_STATEMENT_LIST: return "statement_list"; break;
case MD_AST_NODE_TYPE_FUNC: return "func"; break;
case MD_AST_NODE_TYPE_SUBR: return "subr"; break;
case MD_AST_NODE_TYPE_FUNC_DEF: return "func_def"; break;
case MD_AST_NODE_TYPE_SUBR_DEF: return "subr_def"; break;
case MD_AST_NODE_TYPE_SUBR_CALLSITE: return "subr_callsite"; break;
case MD_AST_NODE_TYPE_LOCAL: return "local"; break;
case MD_AST_NODE_TYPE_RETURN: return "return"; break;

View file

@ -9,8 +9,8 @@
// ----------------------------------------------------------------
typedef enum _mlr_dsl_ast_node_type_t {
MD_AST_NODE_TYPE_STATEMENT_LIST,
MD_AST_NODE_TYPE_FUNC,
MD_AST_NODE_TYPE_SUBR,
MD_AST_NODE_TYPE_FUNC_DEF,
MD_AST_NODE_TYPE_SUBR_DEF,
MD_AST_NODE_TYPE_SUBR_CALLSITE,
MD_AST_NODE_TYPE_LOCAL,
MD_AST_NODE_TYPE_RETURN,

View file

@ -91,11 +91,11 @@
"func" {
*yyextra = mlr_dsl_ast_node_alloc(yytext, MD_AST_NODE_TYPE_STRIPPED_AWAY);
return MD_TOKEN_FUNC;
return MD_TOKEN_FUNC_DEF;
}
"subr" {
*yyextra = mlr_dsl_ast_node_alloc(yytext, MD_AST_NODE_TYPE_STRIPPED_AWAY);
return MD_TOKEN_SUBR;
return MD_TOKEN_SUBR_DEF;
}
"call" {
*yyextra = mlr_dsl_ast_node_alloc(yytext, MD_AST_NODE_TYPE_STRIPPED_AWAY);

View file

@ -205,12 +205,12 @@ md_statement_not_braced_end(A) ::= MD_TOKEN_CONTINUE(O). {
// * On the "c" we append the next argument to get "anon(a,b,c)".
// * On the "f" we change the function name to get "f(a,b,c)".
md_func_block(C) ::= MD_TOKEN_FUNC
md_func_block(C) ::= MD_TOKEN_FUNC_DEF
MD_TOKEN_NON_SIGIL_NAME(F) MD_TOKEN_LPAREN md_func_args(A) MD_TOKEN_RPAREN
MD_TOKEN_LBRACE md_statement_list(B) MD_TOKEN_RBRACE.
{
A = mlr_dsl_ast_node_set_function_name(A, F->text);
C = mlr_dsl_ast_node_alloc_binary(F->text, MD_AST_NODE_TYPE_FUNC, A, B);
C = mlr_dsl_ast_node_alloc_binary(F->text, MD_AST_NODE_TYPE_FUNC_DEF, A, B);
}
// Need to invalidate "f(10,)" -- use some non-empty-args expr.
md_func_args(A) ::= . {
@ -223,12 +223,12 @@ md_func_args(A) ::= md_func_args(B) MD_TOKEN_COMMA MD_TOKEN_NON_SIGIL_NAME(C). {
A = mlr_dsl_ast_node_append_arg(B, C);
}
md_subr_block(C) ::= MD_TOKEN_SUBR
md_subr_block(C) ::= MD_TOKEN_SUBR_DEF
MD_TOKEN_NON_SIGIL_NAME(F) MD_TOKEN_LPAREN md_subr_args(A) MD_TOKEN_RPAREN
MD_TOKEN_LBRACE md_statement_list(B) MD_TOKEN_RBRACE.
{
A = mlr_dsl_ast_node_set_function_name(A, F->text);
C = mlr_dsl_ast_node_alloc_binary(F->text, MD_AST_NODE_TYPE_SUBR, A, B);
C = mlr_dsl_ast_node_alloc_binary(F->text, MD_AST_NODE_TYPE_SUBR_DEF, A, B);
}
// Need to invalidate "f(10,)" -- use some non-empty-args expr.
md_subr_args(A) ::= . {

View file

@ -341,12 +341,12 @@ mlr_dsl_cst_t* mlr_dsl_cst_alloc(mlr_dsl_ast_t* ptop, int type_inferencing) {
mlr_dsl_ast_node_t* pnode = pe->pvvalue;
switch (pnode->type) {
case MD_AST_NODE_TYPE_FUNC:
case MD_AST_NODE_TYPE_FUNC_DEF:
cst_install_UDF(pnode, pcst, type_inferencing, context_flags);
break;
// xxx MD_AST_NODE_TYPE_SUBR_DEFSITE et al.?
case MD_AST_NODE_TYPE_SUBR:
case MD_AST_NODE_TYPE_SUBR_DEF:
// xxx factor out the struct and lhmsv_put it here ?
// xxx swap order of 1st two args & et als
cst_install_subroutine(pnode, pcst, type_inferencing, context_flags);
@ -601,11 +601,11 @@ static mlr_dsl_cst_statement_t* alloc_cst_statement(mlr_dsl_ast_node_t* pnode,
{
switch(pnode->type) {
case MD_AST_NODE_TYPE_FUNC:
case MD_AST_NODE_TYPE_FUNC_DEF:
fprintf(stderr, "%s: func statements are only valid at top level.\n", MLR_GLOBALS.bargv0);
exit(1);
break;
case MD_AST_NODE_TYPE_SUBR:
case MD_AST_NODE_TYPE_SUBR_DEF:
fprintf(stderr, "%s: subr statements are only valid at top level.\n", MLR_GLOBALS.bargv0);
exit(1);
break;

View file

@ -18,16 +18,16 @@ k impl fmgr::install, and propagate the lhmsv throughout
k hard-coded cst foo -> invoke installer func
k boundvar assigment @ ast/cst
k ast work w/o $/@ prohibits
* split out subr now
k split out subr now
! ast work w $/@ prohibits
! return_value vs. return_void
! subr callsite @ .y
k subr callsite @ .y
* ast-node-type renames
* multiple put -f
* allow locals in if/for/while as well
? func @ filter?
* func/subr -> func_def/subr_def in the grammar? or, subr_call -> call ?
? separate sub & func ?
! disallow reads of unset boundvars
? disallow reads of unset boundvars ?
* kw autodoc mods
* cookbook: