Re: Converting Pascal to C++, C# or VB

Marco van de Voort <marcov@stack.nl>
9 Apr 2006 17:25:00 -0400

          From comp.compilers

Related articles
[6 earlier articles]
Re: Converting Pascal to C++, C# or VB gneuner2@comcast.net (George Neuner) (2006-04-08)
Re: Converting Pascal to C++, C# or VB martin@gkc.org.uk (Martin Ward) (2006-04-08)
Re: Converting Pascal to C++, C# or VB neelk@cs.cmu.edu (Neelakantan Krishnaswami) (2006-04-08)
Re: Converting Pascal to C++, C# or VB thompgc@gmail.com (thompgc@gmail.com) (2006-04-08)
Re: Converting Pascal to C++, C# or VB marcov@stack.nl (Marco van de Voort) (2006-04-09)
Re: Converting Pascal to C++, C# or VB marcov@stack.nl (Marco van de Voort) (2006-04-09)
Re: Converting Pascal to C++, C# or VB marcov@stack.nl (Marco van de Voort) (2006-04-09)
Re: Converting Pascal to C++, C# or VB DrDiettrich@compuserve.de (Hans-Peter Diettrich) (2006-04-10)
Re: Converting Pascal to C++, C# or VB gneuner2@comcast.net (George Neuner) (2006-04-10)
Re: Converting Pascal to C++, C# or VB englere.geo@yahoo.com (Eric) (2006-04-12)
Re: Converting Pascal to C++, C# or VB hebisch@math.uni.wroc.pl (Waldek Hebisch) (2006-04-12)
Re: Converting Pascal to C++, C# or VB oliver@first.in-berlin.de (Oliver Bandel) (2006-04-14)
| List of all articles for this month |

From: Marco van de Voort <marcov@stack.nl>
Newsgroups: comp.compilers
Date: 9 Apr 2006 17:25:00 -0400
Organization: Stack Usenet News Service
References: 06-04-017 06-04-040
Keywords: Pascal, translator

On 2006-04-08, George Neuner <gneuner2@comcast.net> wrote:


> Nested Routines:
> Simulating nested routines is fairly simple - you turn the top level
> function or procedure into a C++ "function" object - that is an object
> that overloads the call operator "()". You convert the shared local
> variables and top level parameters to member variables and any nested
> routines into member functions [or recursively, into member function
> objects]. See example below.


I quickly looked over it, but I don't fully get it. Is this supposed
to be a general solution (e.g. also for call pattern that might be
more complicated than parent ->1st level child -> 2nd level child) ?


I've seen complete recursive descent parsers as nested procedures.


> Records: Simple records can be mapped irectly to structs or public
> classes. Variant records can be simulated using tagged unions or with a
> class heirarchy depending on your needs.


Variable size instantiation of pointers to variant records might be fun :-)


new (x,true,false)


will create a ptr to a record with size that matches when the "true" branch
of the first level of the unit is taken, and the "false" branch nested in
there. Note that this ISO feature doesn't exist in the Borland lineage.


> Your equivalents of PUT will need to recognize an object and store the
> object type and data in a way that allows the object to be
> reconstructed on the fly when GET reads it back. This is called
> "serialization" and in C++ it requires "run time type information"
> [RTTI] and some fairly advanced coding techniques.


(note that serialisation can also be done using simple inheritance and
writing each field individually. RTTI is only necessary if you want to avoid
spelling out the fields, and don't need the extra control to specify the
fileformat)


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.