Prof. Abimbola A. Olowofoyeku (The African Chief) wrote:
Also with my patch Writeln (); is still rejected (builtin functions/procedures are handled differently then user defined ones).
Delphi rejects "Writeln ()" as well. AFAICS, the empty brackets are only allowed for parameter-less routines. Since Writeln can take parameters, that code should be rejected.
If calls to built-ins with empty parethesis are illegal, than the task is easier. The patch below (add 13 lines) should work. With the patch in: a() := 5; `a()' is treated as a call, and rejected just like `a(5)'. In var a: procedure; a := bar(); assignment is rejected (since we do not allow procedural return values). On the other hand, the following works: var a: procedure; .... a := foo; a (); So I hope that the implementation is reasonably complete. --- gpc-20030830/p/parse.y 2004-04-17 04:39:59.000000000 +0200 +++ gpc-20030830/p/parse.y 2004-04-18 01:10:51.000000000 +0200 @@ -2509,6 +2509,19 @@ { $$ = build_pascal_pointer_reference ($1); } | variable_or_routine_access_no_parentheses '[' index_expression_list ']' { $$ = build_pascal_array_ref ($1, $3); } + | variable_or_routine_access_no_builtin_function '(' rpar + { + chk_dialect ("empty parenthesis as parameter are", BORLAND_DELPHI); + if ($1 && TREE_CODE ($1) == TYPE_DECL) + { + error ("type cast expects one expression argument"); + $$ = error_mark_node; + } + else if (CALL_METHOD ($1)) + $$ = call_method ($1, NULL_TREE); + else + $$ = build_routine_call ($1, NULL_TREE); + } | variable_or_routine_access_no_builtin_function '(' { $<itype>2 = allow_function_calls (0); } actual_parameter_list rpar_or_error In case, I have put genereted C files on web page: http://www.math.uni.wroc.pl/~hebisch/gpc -- Waldek Hebisch hebisch@math.uni.wroc.pl