Hello, I've been having a tough time getting C declarators to parse properly. I'm trying to construct a list of declarators in a type structure and although I...
... An alternative suggestion: parse it with a simple left to right grammar, and treat everything as an operator and apply operator precedence rules? highest...
... Parse the entire language that way? ... How to parenthesis fit into this picture? I've found that parsing declarations with only involve * and [] to be ...
99
Rainer Thonnes
rainer@...
Jan 3, 2003 11:28 am
... I'm pretty sure x is right but y and z are both wrong. AIUI, indexing has higher precedence than indirecting, i.e. if "*x[4]" is an int, then x is not a...
100
Rainer Thonnes
rainer@...
Jan 3, 2003 1:24 pm
... Why not? :-) ... I think this is where the BCM lies. If you start from the premise (which I believe to be false) that precedence at the outer level is...
... x is right, as you say, and this can be quickly verified by thinking of argv. I use "char **argv" in my main() declarations, but *argv[] is valid too. I'm...
... I'd have to write a parser of my own completely from scratch. I could also just do a top-down hand-written parser a la LCC (and most commercial compilers?)...
... with and ... elsewhere in ... odd, but I ... to see ... I have to admit I'd never seen or used that construct either. I suspect the following program might...
104
Rainer Thonnes
rainer@...
Jan 4, 2003 11:13 am
... That's the exact same example I used in reaching my conclusion. ... Don't bother. I forgot to think inside-out here. You were right. ... Um, no, sorry...
105
Rainer Thonnes
rainer@...
Jan 4, 2003 12:16 pm
... I didn't express that very well. Replace the last sentence with: Then, working in, the "y" in (*y) must be a pointer to what (*y) is....
... What he said. Just keep the tree. We haven't discussed casts yet. casts have a pretty obvious interpretation in our data structure: cast / \ type expr ...
You're probably aware of this, but just to get it in writing... int a[10][10] is 10*10*sizeof(int) bytes. It's a 2-d array and there are no pointers involved,...
108
Rainer Thonnes
rainer@...
Jan 4, 2003 4:13 pm
... There would have to be, if there are still any compilers around which use this technique. Nobody would write the parse tables by hand. The Edinburgh...
... the ... grammar ... which ... I think the sort of representation Rainer is talking about is an extended phrase syntax such as this (I'm translating...
... Rainer corrected the error above, and I'd like to repeat what he said with a slightly different take: any time you have a bracketed expression, ask how you...
Hello everyone, Well, I'm back from Maui (with the tan to prove it ;))! It was wonderful, as expected, but now it's time for me to make up for lost coding...
... If you remain consistent with my method, the logic remains the same until you decide to remove the unnecessary bracketing. *(*X)[10] would be equivalent to...
... Interesting program. I've only looked at this man page but I'm going to have to get this program running here so I can play with it. ... This is how it...
... In which situations (if any) will the compiler reject an explicit cast? If it only happens in some really obvious case, couldn't the cast be completely...
115
Rainer Thonnes
rainer@...
Jan 12, 2003 10:36 pm
... I've been waiting for you. ... Well it depends what you mean by "handled first". It's handled first working form the inside out, which is what happens when...
... How would you use a multi-dimensional array with insufficiently defined bounds? You can declare main as: int main(int argc, char argv[][]) But, AFAIK, you...
117
Rainer Thonnes
rainer@...
Jan 12, 2003 10:53 pm
... The thing to remember is that the order of evaluation of a non-declarative expression does not depend on the declaration. The declaration only supplies...
... Oops, I've been thinking about this in a backwards fashion because I wanted to construct the type declarator list by always adding to the front of the ...
... precedence> ... precedence> ... The problem here is this: '*'var_decl | var_decl '[' expr ']' You need an additional layer of grammar in here to ...
... cast? I didn't know it ever did. There's rules about casting lvalues (which GCC extensions break), and about taking the address of register or const data,...
... recognized ... No No No! First of all there is no 'first39;. There is 'higher in the parse tree'. They are not the same thing. Stop thinking about the...
123
Rainer Thonnes
rainer@...
Jan 13, 2003 1:33 pm
... Exactly. On the other hand, if he's trying to do clever stuff like creating linear lists *during* parsing, then he probably does need to know in what...
... The shift/reduce conflict I was talking about :) ... It is. But there is a small advantage in that it simplifies the grammar a bit. yacc and its clones...