Or How To Think of Every Edge Case Ever.
Currently taking a compiler class and on the semantic analysis stage. I have this here Abstract Syntax Tree based on some code I have determined to be syntactically correct. Now I get to see if the author of said code was a dumbass. We're using a subset of C, C- (C-, that's one minus) which is C with a bunch of crap stripped out so one could hope to get a working compiler done in a semester (well, and work full time).
Essentially you have integers and void, no pointer arithmetic, global/local/parameter variables, no prototypes, main must be the last function in a file, so on and so forth. It's relatively trivial to add code to check for things that are stupid, but then there are things you don't think about.
For example, it is syntactically correct to do void z[10];, but it makes no sense. Ten voids? What?
The best part is there isn't an actual list of semantics, well in list form. The textbook has a little discussion on each part of the BNF, but left to my own imagination I think of nonsense like the above.
When this is all said and done I feel a loooooong post on compilation coming up. If you're contemplating taking a compiler course, you should totally do it! The material is fascinating.
Currently taking a compiler class and on the semantic analysis stage. I have this here Abstract Syntax Tree based on some code I have determined to be syntactically correct. Now I get to see if the author of said code was a dumbass. We're using a subset of C, C- (C-, that's one minus) which is C with a bunch of crap stripped out so one could hope to get a working compiler done in a semester (well, and work full time).
Essentially you have integers and void, no pointer arithmetic, global/local/parameter variables, no prototypes, main must be the last function in a file, so on and so forth. It's relatively trivial to add code to check for things that are stupid, but then there are things you don't think about.
For example, it is syntactically correct to do void z[10];, but it makes no sense. Ten voids? What?
The best part is there isn't an actual list of semantics, well in list form. The textbook has a little discussion on each part of the BNF, but left to my own imagination I think of nonsense like the above.
When this is all said and done I feel a loooooong post on compilation coming up. If you're contemplating taking a compiler course, you should totally do it! The material is fascinating.
0 Comments On This Entry
← January 2022 →
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | 31 |
Tags
My Blog Links
Recent Entries
Recent Comments
Search My Blog
20 user(s) viewing
20 Guests
0 member(s)
0 anonymous member(s)
0 member(s)
0 anonymous member(s)



Leave Comment









|