Re: Intermediate forms (again?): worthwhile?

tm <thomas.mertes@gmx.at>
Mon, 24 Jan 2011 23:33:41 -0800 (PST)

          From comp.compilers

Related articles
[13 earlier articles]
Re: Intermediate forms (again?): worthwhile? nospam@myisp.net (Tony) (2011-01-22)
Re: Intermediate forms (again?): worthwhile? bc@freeuk.com (Bartc) (2011-01-23)
Re: Intermediate forms (again?): worthwhile? steshaw@gmail.com (Steven Shaw) (2011-01-24)
Re: Intermediate forms (again?): worthwhile? steshaw@gmail.com (Steven Shaw) (2011-01-24)
Re: Intermediate forms (again?): worthwhile? barry.j.kelly@gmail.com (Barry Kelly) (2011-01-24)
Re: Intermediate forms (again?): worthwhile? nospam@myisp.net (Tony) (2011-01-24)
Re: Intermediate forms (again?): worthwhile? thomas.mertes@gmx.at (tm) (2011-01-24)
Re: Intermediate forms (again?): worthwhile? eh@electrichedgehog.net (Chris Dollin) (2011-01-26)
Re: Intermediate forms (again?): worthwhile? bc@freeuk.com (Bartc) (2011-01-26)
Re: Intermediate forms (again?): worthwhile? cr88192@hotmail.com (BGB) (2011-01-26)
| List of all articles for this month |

From: tm <thomas.mertes@gmx.at>
Newsgroups: comp.compilers
Date: Mon, 24 Jan 2011 23:33:41 -0800 (PST)
Organization: Compilers Central
References: 11-01-045
Keywords: code
Posted-Date: 26 Jan 2011 12:17:51 EST

On 14 Jan., 06:53, "Tony" <nos...@myisp.net> wrote:
> Clarification: I got to here from disenchantment/unenamorment with
> existing HLLs (yep, every one of them). I like the freedom afforded by
> writing to the hardware level for my language's
> initial/prototype/reference output.


Does this mean your language will be close to the hardware or
your compiler will generate code close to the hardware?


The implementation strategy depends on the features of your language.
E.g.: Emitting code directly from the parser is only possible when
your language allows it. Pascal was designed that it can be compiled
that way. Features like type inferencing or using things without or
before the declaration require some intermediate representation. As
John said a tree representation is a good idea.


Besides optimisation considerations the language features may force
you to use more or less complex intermediate representations.


Does you language differ from existing ones by syntactical
differences?
Do you want that statements, declarations, etc. look different and
have slightly other meanings? In this case you could write a
preprocessor for an existing language or modify an existing
compiler. The P4 Pascal compiler is quite simple so a modification is
not too hard (but it does not generate machine code). Maybe an
extensible language like Seed7 could help you. You could define
statements, declaration constructs, operators and other stuff for your
language. This way you can concentrate on the features of your
language and you get an interpreter and a compiler for free. The
features of your language would be defined in an include file. Your
programs would start with including this file and afterwards your
language constructs are available. A short explanation is here:


    http://seed7.sourceforge.net/faq.htm#boot_a_language
This is not the main direction of Seed7 but it can be used that way.
How to define the syntax and semantic of a statement is explained
here:
    http://seed7.sourceforge.net/examples/declstat.htm
Even when you are not interested in implementing your language this
way it still can be helpful to create prototypes. Maybe you can try
out
some of your statements this way. Some time ago somone asked for
a loop with a middle exit. So I did a prototype for it. See:
    http://seed7.sourceforge.net/manual/syntax.htm#The_syntax_of_a_statement


If you have questions, just ask.


Greetings 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.