News for hackers. Stuff that matters.
Re:One-pass Compiler by stevekemp on Saturday May 23, 2020 @12:01PM (#23284004)
I wrote something very similar recently, also a single-pass, but with a trivial internal representation:

https://github.com/skx/math-compiler

The real difference between the compiler in the example, and mine, is that I handle floating-point operations and also explicitly use printf to show the output. (Because otherwise your return value is limited to an 8bit number.)

Re:One-pass Compiler by tom_mellior on Sunday May 24, 2020 @02:20AM (#23289580)
This is nice. The -debug flag is a cool feature. But if you first build a representation of the whole program in memory, then traverse that representation to generate code, it's not really single-pass.
Re:One-pass Compiler by stevekemp on Sunday May 24, 2020 @05:07AM (#23290250)
Sorry my comment was wrong, I should have said "not a single-pass", that's why I mentiond the trivial internal representation.

Too late to edit now!

Re:One-pass Compiler by userbinator on Saturday May 23, 2020 @10:31PM (#23288602)
Because otherwise your return value is limited to an 8bit number

Only on Linux; Windows lets you use the full 32 bits.

Re:One-pass Compiler by stevekemp on Sunday May 24, 2020 @05:07AM (#23290246)
That's true. Though I guess even there there are limitations, because you can't return non-integers :)