Live data from Hacker News

Let's make a Teeny Tiny compiler

austinhenley.com

11–20 of 39 posts

Re: Let's make a Teeny Tiny compiler

#12
post #7

I'm sorry to be negative here, but this article, like most articles about compilers, is bike shedding. For those not aware of the bike shedding metaphor, it's the assertion that when discussing the design of a nuclear power plant, everyone will want to discuss the color of the shed where the workers store their bikes because they understand it. Meanwhile, nobody will want to discuss the nuclear reactor itself, becaus…

Part 3 is the emitter that produces C: https://web.eecs.utk.edu/~azh/blog/teenytinycompiler3.html

[deleted]

Re: Let's make a Teeny Tiny compiler

#13
post #7

I'm sorry to be negative here, but this article, like most articles about compilers, is bike shedding. For those not aware of the bike shedding metaphor, it's the assertion that when discussing the design of a nuclear power plant, everyone will want to discuss the color of the shed where the workers store their bikes because they understand it. Meanwhile, nobody will want to discuss the nuclear reactor itself, becaus…

Part 3 is the emitter that produces C: https://web.eecs.utk.edu/~azh/blog/teenytinycompiler3.html

Ah, okay. It looks like you're taking a fairly C-like language and transforming it to C--I'd call this a transpiler rather than a compiler. You're not wrong to call it a compiler, but it's a pretty noncentral example of a compiler.

Congrats on at least having an emitter, but I'm still searching for an article that shows how to emit assembly of any kind.

Re: Let's make a Teeny Tiny compiler

#14

I'm sorry to be negative here, but this article, like most articles about compilers, is bike shedding. For those not aware of the bike shedding metaphor, it's the assertion that when discussing the design of a nuclear power plant, everyone will want to discuss the color of the shed where the workers store their bikes because they understand it. Meanwhile, nobody will want to discuss the nuclear reactor itself, becaus…

so what if it is?

i know what the bike shedding metaphor is and frankly you're stretching it a bit because all this person is trying to do is educate and they're not even saying this is the only way to do it.

seems odd to pull out the bike shed metaphor for every case there's an abundance of technical articles on a subject matter. There's lots of tutorials on for loops in X language. Do you consider that bike shedding?

Re: Let's make a Teeny Tiny compiler

#15
post #11

Earlier quoted context omitted.

I'll believe it when I see it.

I'll take "what is due diligence" for 300, Alex.

I guess I was technically wrong in that it does have an emitter, but I wasn't wrong in that it still doesn't emit assembly. gcc (or whatever you're using to compile your C) is still doing all the nuclear reactor part.

Re: Let's make a Teeny Tiny compiler

#16
post #7

Earlier quoted context omitted.

Part 3 is the emitter that produces C: https://web.eecs.utk.edu/~azh/blog/teenytinycompiler3.html

Ah, okay. It looks like you're taking a fairly C-like language and transforming it to C--I'd call this a transpiler rather than a compiler. You're not wrong to call it a compiler, but it's a pretty noncentral example of a compiler. Congrats on at least having an emitter, but I'm still searching for an article that shows how to emit assembly of any kind.

I used to work on a static analyzer that did taint analysis, model checking, buffer bounds checking, and so on -- a bit like a compiler backend on steroids. If there's a specific topic you'd like an explanation on, I could be convinced to write something up.

My favorite was always context-sensitive, interprocedural points-to analysis. And dataflow analysis in the presence of higher-order controlflow constructs.

Re: Let's make a Teeny Tiny compiler

#18

Earlier quoted context omitted.

This tutorial is multipart, the code emitting is in the 3rd part.

I'll believe it when I see it.

Please don't be a jerk on HN. I'm sure you don't mean to be, but comments like this can really come across the wrong way. That's one reason the site guidelines include: "Please don't post shallow dismissals, especially of other people's work. A good critical comment teaches us something."

https://news.ycombinator.com/newsguidelines.html

Re: Let's make a Teeny Tiny compiler

#19
post #11

Earlier quoted context omitted.

I'll take "what is due diligence" for 300, Alex.

I guess I was technically wrong in that it does have an emitter, but I wasn't wrong in that it still doesn't emit assembly. gcc (or whatever you're using to compile your C) is still doing all the nuclear reactor part.

Very few "commercial" compilers emit assembly directly. They use LLVM or C or some other intermediate language.

Re: Let's make a Teeny Tiny compiler

#20
post #7

Earlier quoted context omitted.

Part 3 is the emitter that produces C: https://web.eecs.utk.edu/~azh/blog/teenytinycompiler3.html

Ah, okay. It looks like you're taking a fairly C-like language and transforming it to C--I'd call this a transpiler rather than a compiler. You're not wrong to call it a compiler, but it's a pretty noncentral example of a compiler. Congrats on at least having an emitter, but I'm still searching for an article that shows how to emit assembly of any kind.

Instead of outputting c, could you not just output the equivalent assembler?

so instead of

    self.emitter.emitLine("printf(\"" + self.curToken.text + "\\n\");")
you do something like

        self.emitter.emitLine("STRING DB " + self.curToken.text + "', '$'")
    ...
    self.emitter.emitLine("LEA DX,STRING")
    self.emitter.emitLine("MOV AH,09H")
    self.emitter.emitLine("INT 21H")
Post reply on HN