I've gone a different path. Should I return and continue developing on this, or should I continue lexical analysis? Basically, instead of merging multiple...
... I didn't reply right away because I wanted to think about this for a little first. I want to encourage you to work on parts of your compiler that you're...
I've suspended lexer development. I've seperated the parsing functionality into several functions like parse_operator, is_operator, is_whitespace, etc. At this...
... is prompt ... under ... Ok so I decided to give this a go as well. I have a little background knowledge already (read the dragon book a couple years back...
... assumption that compiling is a 3rd or 4th year subject whereas I think you can usefully start learning the subject pretty much as soon as you've mastered ...
On Sun, Mar 2, 2008 at 5:51 PM, compiler_builder ... We're not looking at operator precedence here, just a simple left to right evaluation with the added twist...
... code ... This is based on the first version of 'simple.c' that you posted: #include <stdio.h> #include <string.h> int get_expression(char *expression, int...
... Depending on how simple you're willing to accept, you could have something that you could call a compiler within a week or two (and by that I mean just...
... I'd hope my programming is good enough given I do it for a living. I'd read your previous advice not to use complicated data structures and language...
These are the modifications I made. Old line: if ((ch == '\0') || (strchr(terminators, ch) != NULL)) { New line: if ((ch == '\0') || (strchr(terminators, ch)...
... You got it. Now modify this code so that instead of performing the calculation on the fly, you output instructions for what someone would key on a...
... terminators); Exactly. Now instead of a calculator whose only purpose is "get_expression", if you handle other language features the same way, eg...
PS this was my version of the same code that I was holding off posting until you came up with the recursive parsing solution for yourself. It's almost...
Your mission, if you choose to accept it, is to explain how to calculate an expression which contains operators of different precedences. So following the...
... Ok, so this one was pretty easy until i hit the parentheses which caused me some dramas, but it seems to work nice now. At this point I'm kinda wondering...
... How do I know which function should I trigger? ... It's a deal. :-) ... Should this be something like (not literally): if (ch == '=') variable['x'] =...
You take an expression and start reading it from left to right. Each time you encounter a * or a / you take a number immediately left and immediately right of...
... And you thought compiler writing was difficult :-) You guys are getting ahead of me a little! I'll need to spend some time working out where we go next...
On Mon, Mar 10, 2008 at 2:47 AM, compiler_builder ... In this style of parsing, you start with a top-level procedure that accepts the entire program, and it in...
On Mon, Mar 10, 2008 at 12:47 PM, compiler_builder ... So if I have 1 + 2 + 3 * 4 * 5, you're saying I stop when I get to the "* 4" and replace 3 * 4 with 12,...
On Mon, Mar 10, 2008 at 12:47 PM, compiler_builder ... Here's a totally equivalent problem but phrased differently. It might suggest a different solution or...
... Defer that decision until you get in trouble. Two reasons. 1) you haven't written enough yet that you should even care if you have to throw it away; and...
... Both, i've had needs several times for a particular compiler for some task. At the moment I have some spare time and really want to get the theory into my...
... not so ... quite an ... There's a fairly good book I'ld recommend that specialises in interpreters, called "Writing Interactive Compilers and Interpreters"...
... not so ... quite an ... Virtual machines (in the sense of a bytecode definition, rather than the vmware sort of emulation) raise some interesting issues. ...
... Ok so i have a bit more background theory so i skipped the step of trying to trying to explain to kids how to work operator precedence. Thinking about how...
... Ok so I added another precedence level just to make sure I had the right of it, and things seem to be working nicely. So next step is identifiers, which I...
Last update for today, I added assignments, so you can have something like : a = 5 * 9 ^ 6 Then of course you can have identifiers in expressions like: b = 8 /...
I'm getting too old for late nighters! It looks good but I'll read it more closely tomorrow. btw would you start posting the compiler output now along with...
... From: Graham Toal To: compilers101@yahoogroups.com Sent: Wednesday, March 12, 2008 3:55 PM Ok so I gave some thought to the theoretical problem i had with...