FAQ
To be honest, the Go sources would probably stand as a better example than
my own code (see: http://golang.org/pkg/go/). My own toy language was
based around LISP S-Expressions akin to
http://godoc.org/launchpad.net/twik by Gustavo
Niemeyer. I can put my code up on github if you like but I promise you'll
learn more from these other two resources than my own code as I'm still a
novice/student at compiler design.

On Sun, Sep 8, 2013 at 4:32 AM, Archos wrote:

Hi Rob,

I need to build a Go's compiler to be called/used from Rust although I've
no decided whether to write it in C or to use Rust.

Does your compiler is open source? I would like to read it to take
inspiration.
Which language did you use to build it?

El lunes, 5 de agosto de 2013 05:44:56 UTC+1, Rob Thornton escribió:
As part of continuing to grow as a programmer, I decided it was high time
I wrote my own toy language compiler. I have completed a working lexer (I
really enjoyed that part) and a parser which creates an AST. I can evaluate
the generated AST to execute simple expressions like basic math and
assignment. It was pretty amazing to get this far and create an interpreter
but I really would like to take it to what I see as the final step. After
much searching I have found there tends to be only one resolution and
that's to output an intermediate language. Some languages are converted to
bytecode for a VM and others have the AST passed directly into the compiler
back-end like in GCC'S and LLVM's (or is it LLVM IR?) case. One other
solution is to output another high-level language like C which would in
tern be compiled by a C compiler but seems abysmally complicated. From what
I can gather, to create a front-end for GCC I would need to use C or C++
and for LLVM C++ so it doesn't appear I could use my Go front-end but,
again, I could be mistaken.

So, I have a few questions I'm hoping someone would be willing to answer
for me:

1) What would be the simplest way to produce an executable from the state
I'm at? Is it best to attempt to output Go code or some other intermediate
language to be compiled by a secondary compiler? Thereby the 'compiler'
would in effect be a script which executes a two-stage process: i) language
-> intermediate language, ii) intermediate language -> executable?

2) After looking at Go's sources, it seems that the GC generates
assembler instructions. Would it not need an external assembler to compile
the assembly to binary? What stage(s) am I missing to produce the final
executable? Obviously there's the linking stage but there must be more I'm
missing.
--
You received this message because you are subscribed to a topic in the
Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/golang-nuts/QMK8uAOm_D0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 11 of 12 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedAug 5, '13 at 4:45a
activeSep 10, '13 at 10:03p
posts12
users9
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase