Thursday, July 19, 2007

Smalltalk YX to compile itself

Hello,
lately i've been working on a compiler for Syx in Smalltalk. Actually, it's mostly a plain translation of the C one, but works pretty nice. This is an example without using intermediate shortcuts:

$ syx
> | text lexer parser method context |
> text := 'message ^123+32'.
> lexer := CompilerLexer on: text.
> parser := CompilerParser on: text for: nil class.
> parser parse.
> method := CompiledMethod fromParser: parser.
> context := MethodContext on: method parent: thisContext receiver: nil arguments: #().
> ^Processor enter: context!
155
> EOF

Eventough it's still missing features such as cascading and optimized blocks, i hope to release 0.1.3 version very soon. The purpose is to use this compiler for the console and for files instead of the C one.

Stay tuned, bye!

No comments: