[antlr-interest] Writing Delphi Target for Antlr3

Gavin Lambert antlr at mirality.co.nz
Sat May 26 18:24:03 PDT 2007


At 08:06 27/05/2007, Jim Idle wrote:
 >It's been some time since even looked at a Pascal program, but 
does
 >it allow:
 >
 >var
 >  x: Integer;
 >  begin
 >	var
 >	y: Integer;
 >	begin
 >		...
 >	end
 >  end
 >
 >?

The closest you can get to that sort of construct is this:

function Outer(Parm1: Integer): Integer;
var
   x, y: Integer;

   function Inner(Parm2: Integer): Integer;
   var
     z: Integer;
   begin
     // ... implementation of Inner
   end;
begin
   // ... implementation of Outer
end;

Note that this still requires predeclaration, but IIRC the 
variables of the outer function are visible to the inner function 
(but not the reverse), similar to arbitrary blocks in C++ and Java.



More information about the antlr-interest mailing list