please  help me !

im need  to learn  how to creat  my compiler for any  language programming

AND  need  to  (API) FUNCTION

i need to help !!!!
Posted on 2005-08-28 17:21:55 by mr:programmer
you want to make your own programming language? or you need help on one that already exists?
Posted on 2005-08-28 17:37:35 by Qages
Need this for a uni course? :)

You might want to look at how other people have done - http://www.lua.org comes to mind
Posted on 2005-08-28 18:09:27 by f0dder
thanks

put  i wont  book  include all topic  about creat acompiler ?
Posted on 2005-08-29 01:47:14 by mr:programmer
Hm, I don't understand what you're writing... but if a book about compiler construction is what you want, perhaps look for "the dragon book". It's a heavy mouthful, though.
Posted on 2005-08-29 15:10:35 by f0dder
Hi,

If you want to learn more about  compiler construction, I suggest you to take a look at "the dragon book". It's the best book concearning this topic

But I also will give you a short summary of the diffrent steps during compilation.

1. lexical analyzer
The lexical analyzer tokenizes a codeline and creates a token-stream. For example:
codeline: x=2+3*Val("22")
Token-stream:
"x"=ident
"="=Operand
"2"=factor
"+"=Operand
"3"=factor
"*"=Operand
"Val"=Ident
"("=Parenthesis
""22""=String
")"=Parenthesis

2. creation of a parser-tree
Many compilers creates after the lexical analyse a parser-tree, which represents the precedence of each token. In our example this would be: 2,3,+,"22",Val,*,=,x. With this notation it's easier to create the assembler code, because the parser-tree already represents it.


Push 2
Push 2
call _asmadd
Push _STR1
call Val
call _asmmul
pop eax
mov x, eax

In this example it's important that _asmadd, _asmmul and Val push their result on the stack.

3.syntax analyzer
The syntax analyzer checks if the codeline is conform to the syntaxdefinition of the language.

4.semantic analyzer
The semantic analyzer perfoms a typechecking. So that you can't pass an integer to a procedure, which excepts a string.

5.code creation
Now you create assembler-code out of the token-stream(parser-tree)

6. assembling
After codecreation you can use an assembler to assemble and link your code.

If hope this helps you a bit
 
Posted on 2005-12-31 08:10:59 by Jigo