diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-10-03 20:50:43 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-10-03 20:50:43 +0300 |
commit | 0c6b4cbcc898da9db50f8ef91794c830820a18cf (patch) | |
tree | 331cecabb3d19d026553d6c0ced2e4f63a7b6396 | |
parent | c679c089a018621ad66b59c1fc804f02b1a64f5b (diff) | |
download | mailfromd-0c6b4cbcc898da9db50f8ef91794c830820a18cf.tar.gz mailfromd-0c6b4cbcc898da9db50f8ef91794c830820a18cf.tar.bz2 |
Simplify rules for function vs. procedure call.
* mfd/gram.y (T_BUILTIN_PROC, T_FUNCTION_PROC): Removed.
(proccall): Removed. Use funcall instead.
* /mfd/lex.l (T_BUILTIN_PROC, T_FUNCTION_PROC): Removed.
-rw-r--r-- | mfd/gram.y | 82 | ||||
-rw-r--r-- | mfd/lex.l | 8 |
2 files changed, 24 insertions, 66 deletions
@@ -412,8 +412,8 @@ _create_alias(void *item, void *data) %token <literal> T_STRING "string" %token <literal> T_SYMBOL "MTA macro" T_IDENTIFIER "identifier" %token <number> T_ARG "$n" T_NUMBER "number" T_BACKREF "back reference" -%token <builtin> T_BUILTIN "builtin function" T_BUILTIN_PROC "builtin procedure" -%token <function> T_FUNCTION "function" T_FUNCTION_PROC "void function" +%token <builtin> T_BUILTIN "builtin function" +%token <function> T_FUNCTION "function" %token <type> T_TYPE "data type" T_TYPECAST "typecast" %token <var> T_VARIABLE "variable" %token T_BOGUS @@ -430,11 +430,10 @@ _create_alias(void *item, void *data) %left '+' '-' %left '*' '/' %left T_UMINUS -%left T_BUILTIN T_FUNCTION %type <node> decl stmt condition action sendmail_action header_action if_cond else_cond on_cond atom argref paren_argref - funcall proccall expr maybe_expr maybe_xcode_expr + funcall expr maybe_expr maybe_xcode_expr simp_expr atom_expr asgn catch throw return case_cond autodcl constdecl loopstmt opt_while jumpstmt strval strcat @@ -1020,7 +1019,14 @@ stmt : condition | catch | throw | return - | proccall + | funcall + { + if (node_type($1) != dtype_unspecified) + parse_warning(_("return from %s is ignored"), + $1->type == node_type_builtin ? + $1->v.builtin.builtin->name : + $1->v.call.func->sym.name); + } | constdecl | loopstmt | jumpstmt @@ -1732,6 +1738,10 @@ simp_expr : atom_expr ; atom_expr : funcall + { + if (node_type($1) == dtype_unspecified) + parse_error(_("unspecified value not ignored as it should be")); + } | '(' expr ')' { $$ = $2; @@ -1921,59 +1931,6 @@ funcall : T_BUILTIN '(' arglist ')' } ; -proccall : T_BUILTIN_PROC '(' arglist ')' - { - if (check_builtin_usage($1)) - YYERROR; - if ($3.count < $1->parmcount - $1->optcount) { - parse_error(_("too few arguments in call to `%s'"), - $1->name); - YYERROR; - } else if ($3.count > $1->parmcount) { - parse_error(_("too many arguments in call to `%s'"), - $1->name); - YYERROR; - } else { - $$ = alloc_node(node_type_builtin, get_locus()); - $$->v.builtin.builtin = $1; - $$->v.builtin.args = reverse(cast_arg_list($3.head, - $1->parmcount, - $1->parmtype, - 0)); - } - } - | T_BUILTIN_PROC '(' ')' - { - if (check_builtin_usage($1)) - YYERROR; - if ($1->parmcount - $1->optcount) { - parse_error(_("too few arguments in call to `%s'"), - $1->name); - YYERROR; - } else { - $$ = alloc_node(node_type_builtin, get_locus()); - $$->v.builtin.builtin = $1; - $$->v.builtin.args = NULL; - } - } - | T_FUNCTION_PROC '(' arglist ')' - { - if (check_func_usage($1)) - YYERROR; - $$ = function_call($1, $3.count, $3.head); - if (!$$) - YYERROR; - } - | T_FUNCTION_PROC '(' ')' - { - if (check_func_usage($1)) - YYERROR; - $$ = function_call($1, 0, NULL); - if (!$$) - YYERROR; - } - ; - arglist : expr { $1->next = NULL; @@ -2082,12 +2039,15 @@ return : T_RETURN if (!func) parse_error(_("`return' outside of a function")); else { - if (func->rettype == dtype_unspecified) + $$ = alloc_node(node_type_return, &$1); + if (func->rettype == dtype_unspecified) { parse_error( _("`return' with a value, in function " "returning void")); - $$ = alloc_node(node_type_return, &$1); - $$->v.node = cast_to(func->rettype, $2); + $$->v.node = NULL; + } + else + $$->v.node = cast_to(func->rettype, $2); } } ; @@ -284,7 +284,7 @@ advance_line() tok,top_module->name); \ yyless(0); \ return tok; \ - } \ + } /* Read next input chunk. */ #define YY_INPUT(buf,result,max_size) \ @@ -651,11 +651,9 @@ bye return keyword(T_BYE); state = is_ident; if (state == is_builtin) - return yylval.builtin->rettype == dtype_unspecified ? - T_BUILTIN_PROC : T_BUILTIN; + return T_BUILTIN; else if (state == is_func) - return yylval.function->rettype == dtype_unspecified ? - T_FUNCTION_PROC : T_FUNCTION; + return T_FUNCTION; else { string(yytext, yyleng); return T_IDENTIFIER; |