Re: Best language for implementing compilers?

mertesthomas@gmail.com
Tue, 12 Mar 2019 10:40:02 -0700 (PDT)

          From comp.compilers

Related articles
[22 earlier articles]
Re: Best language for implementing compilers? DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2019-03-10)
Re: Best language for implementing compilers? gneuner2@comcast.net (George Neuner) (2019-03-10)
Re: Best language for implementing compilers? gneuner2@comcast.net (George Neuner) (2019-03-10)
Re: Best language for implementing compilers? christopher.f.clark@compiler-resources.com (Christopher F Clark) (2019-03-11)
Re: Best language for implementing compilers? christopher.f.clark@compiler-resources.com (Christopher F Clark) (2019-03-11)
Re: Best language for implementing compilers? DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2019-03-12)
Re: Best language for implementing compilers? mertesthomas@gmail.com (2019-03-12)
Re: Best language for implementing compilers? bc@freeuk.com (Bart) (2019-03-13)
| List of all articles for this month |

From: mertesthomas@gmail.com
Newsgroups: comp.compilers
Date: Tue, 12 Mar 2019 10:40:02 -0700 (PDT)
Organization: Compilers Central
References: 19-02-002
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="57346"; mail-complaints-to="abuse@iecc.com"
Keywords: design, practice
Posted-Date: 12 Mar 2019 21:12:54 EDT

Am Freitag, 8. Februar 2019 16:55:48 UTC+1 schrieb Costello, Roger L.:
> Best language for implementing compilers?


There are language features, which make programming easier.
This is independent of the type of program.


Compilers are big programs. Compilation speed and/or run-time
performance of the generated program can be a goal. But also the
effort (time) to write a compiler must be taken into account. The
cost to maintain a compiler is also an important factor. Therefore
the decision for a compiler language is not so easy.


I have written scanners and parsers in C, C++, Java and Seed7. I have
used C for the scanner and parser of the Seed7 interpreter. I have
also written scanner, parser and preprocessor for C in Seed7. The
code generator of the Seed7 compiler is written in Seed7. My Basic
interpreter, which tokenizes Basic lines, is written is Seed7.


So I have some experience in writing compiler parts in higher (Seed7)
and lower (C) level languages.


Higher level features like memory management help a lot. E.g.: The
Seed7 compiler generates C code. All this C code snippets are held in
strings. The are concatenated and assigned several times, before they
are written out. Doing this in C with manual memory management would
have been a hard task.


So if you want to create a compiler in a reasonable time I suggest you
prefer a higher level language.


If compilation speed is the criteria number one you will probably need
to use C (to squeze every cycle out of the machine). This is what I
did, when implementing the front end of the Seed7 interpreter.


I designed some language features of Seed7, to support scanning and
parsing. E.g.: Every file in Seed7 has a bufferChar. A bufferChar is
just a single character attached to the file. If you use LL(1)
parsing for tokens you read a character and assign it to the
bufferChar. Then, depending on the bufferChar, you decide what to do
next. If the bufferChar is a digit you will read a number. If the
bufferChar is a letter you will read an identifier. Etc. Examples of
such scanner functions can be found in the library scanfile.s7i.


Regards,
Thomas Mertes


--
Seed7 Homepage: http://seed7.sourceforge.net
Seed7 - The extensible programming language: User defined statements
and operators, abstract data types, templates without special
syntax, OO with interfaces and multiple dispatch, statically typed,
interpreted or compiled, portable, runs under linux/unix/windows.


Post a followup to this message

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