Create a compiler

  • Thread starter Thread starter Sebastian
  • Start date Start date
S

Sebastian

Do you have a simple example for creating a simple hello
world compiler in c# or vb.net?
thanks
Sebastian
 
-----Original Message-----
Do you have a simple example for creating a simple hello
world compiler in c# or vb.net?
thanks
Sebastian
.

Are you trying to write your own compiler using VB or C#
or to compile a "Hello World" application using the .Net
language compilers? If you want to compile a hello world
app, use csc.exe or vbc.exe off the command line as
follows:
csc MyCodeFile.cs
if the default flags do not create what you want, use
csc /? to see the available options.

If instead you want to write your own compiler, (assuming
you have a good understanding of compiler construction)
the book: Compiling for the .Net Common Language Runtime
(CLR) by John Gough ISBN 013062296-6 is a good source on
MSIL and the code generation phases for CLR compatible
languages.

Jackson Davis (MSFT)
--

This posting is provided "AS IS" with no warranties, and
confers no rights.
Use of included script samples are subject to the terms
specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all
responses to this
message are best directed to the newsgroup/thread from
which they
originated.
 
yes i am interested to write my own compiler exscuse for
my bad english :D
thanks Jackson for help
bye
Sebastian
 
Your own compiler for your own language? Why?

GP


| yes i am interested to write my own compiler exscuse for
| my bad english :D
| thanks Jackson for help
| bye
| Sebastian
|
| >-----Original Message-----
| >
| >>-----Original Message-----
| >>Do you have a simple example for creating a simple hello
| >>world compiler in c# or vb.net?
| >>thanks
| >>Sebastian
| >>.
| >>
| >
| >Are you trying to write your own compiler using VB or C#
| >or to compile a "Hello World" application using the .Net
| >language compilers? If you want to compile a hello world
| >app, use csc.exe or vbc.exe off the command line as
| >follows:
| >csc MyCodeFile.cs
| >if the default flags do not create what you want, use
| >csc /? to see the available options.
| >
| >If instead you want to write your own compiler, (assuming
| >you have a good understanding of compiler construction)
| >the book: Compiling for the .Net Common Language Runtime
| >(CLR) by John Gough ISBN 013062296-6 is a good source on
| >MSIL and the code generation phases for CLR compatible
| >languages.
| >
| >Jackson Davis (MSFT)
| >--
| >
| >This posting is provided "AS IS" with no warranties, and
| >confers no rights.
| >Use of included script samples are subject to the terms
| >specified at
| >http://www.microsoft.com/info/cpyright.htm
| >
| >Note: For the benefit of the community-at-large, all
| >responses to this
| >message are best directed to the newsgroup/thread from
| >which they
| >originated.
| >
| >.
| >
 
Of course! I think of switching from C# to Sebastian.Net!


GP


"Miha Markic" <miha at rthand com> wrote in message
| Isn't great to have a compiler that generates Hello world?
|
| --
| Miha Markic - RightHand .NET consulting & software development
| miha at rthand com
|
| | > Your own compiler for your own language? Why?
| >
| > GP
| >
| >
| > | > | yes i am interested to write my own compiler exscuse for
| > | my bad english :D
| > | thanks Jackson for help
| > | bye
| > | Sebastian
| > |
| > | >-----Original Message-----
| > | >
| > | >>-----Original Message-----
| > | >>Do you have a simple example for creating a simple hello
| > | >>world compiler in c# or vb.net?
| > | >>thanks
| > | >>Sebastian
| > | >>.
| > | >>
| > | >
| > | >Are you trying to write your own compiler using VB or C#
| > | >or to compile a "Hello World" application using the .Net
| > | >language compilers? If you want to compile a hello world
| > | >app, use csc.exe or vbc.exe off the command line as
| > | >follows:
| > | >csc MyCodeFile.cs
| > | >if the default flags do not create what you want, use
| > | >csc /? to see the available options.
| > | >
| > | >If instead you want to write your own compiler, (assuming
| > | >you have a good understanding of compiler construction)
| > | >the book: Compiling for the .Net Common Language Runtime
| > | >(CLR) by John Gough ISBN 013062296-6 is a good source on
| > | >MSIL and the code generation phases for CLR compatible
| > | >languages.
| > | >
| > | >Jackson Davis (MSFT)
| > | >--
| > | >
| > | >This posting is provided "AS IS" with no warranties, and
| > | >confers no rights.
| > | >Use of included script samples are subject to the terms
| > | >specified at
| > | >http://www.microsoft.com/info/cpyright.htm
| > | >
| > | >Note: For the benefit of the community-at-large, all
| > | >responses to this
| > | >message are best directed to the newsgroup/thread from
| > | >which they
| > | >originated.
| > | >
| > | >.
| > | >
| >
|
|
 
The first step in writing a compiler is to write a parser. You can find a
parser generator (that emits C# code) at
http://www.nongnu.org/grammatica/index.html. That will allow you to define
your source language.

Then you will have to generate executable code from the parse tree. To do
that you need to know the target instruction set. You should consider
targeting the dotNet intermediate language. That way you can get DotNet to
generate the actual code for you. Or, you could have your compiler emit C#
code which you would then compile with the dotNet C# compiler. Or, you
could have the parser execute the parse tree directly, via some sort of
interpreter.

Compilers are a large subject and there are many books on how to write them.
You should probably review one before proceeding.
 
Back
Top