Show HN: ShivyC – Hobby C compiler created in Python
1–10 of 13 posts
Re: Show HN: ShivyC – Hobby C compiler created in Python
#2Re: Show HN: ShivyC – Hobby C compiler created in Python
#3https://github.com/ShivamSarodia/ShivyC/blob/master/shivyc/p...
It's been a while since I've had to use the phrase "exception-oriented programming", but it fits that code well. While that might be a useful or even necessary pattern to parse something like C++ which can have almost unbounded ambiguities, AFAIK C can be parsed solely by branching on the next token in the stream except for one tiny case (typedefs).
Re: Show HN: ShivyC – Hobby C compiler created in Python
#4The parser has a somewhat unusual structure: https://github.com/ShivamSarodia/ShivyC/blob/master/shivyc/p... It's been a while since I've had to use the phrase "exception-oriented programming", but it fits that code well. While that might be a useful or even necessary pattern to parse something like C++ which can have almost unbounded ambiguities, AFAIK C can be parsed solely by branching on the next token in the str…
Or you know how to fix it? Then just pull[1] it to 'master' ;-)
Re: Show HN: ShivyC – Hobby C compiler created in Python
#5The parser has a somewhat unusual structure: https://github.com/ShivamSarodia/ShivyC/blob/master/shivyc/p... It's been a while since I've had to use the phrase "exception-oriented programming", but it fits that code well. While that might be a useful or even necessary pattern to parse something like C++ which can have almost unbounded ambiguities, AFAIK C can be parsed solely by branching on the next token in the str…
Re: Show HN: ShivyC – Hobby C compiler created in Python
#6Now, compile CPython in it and you're fully boot strapped.
Re: Show HN: ShivyC – Hobby C compiler created in Python
#7The parser has a somewhat unusual structure: https://github.com/ShivamSarodia/ShivyC/blob/master/shivyc/p... It's been a while since I've had to use the phrase "exception-oriented programming", but it fits that code well. While that might be a useful or even necessary pattern to parse something like C++ which can have almost unbounded ambiguities, AFAIK C can be parsed solely by branching on the next token in the str…
The exceptions seem to be how it signals failure if the token doesn't match, but they aren't being used for unbounded lookahead.
Re: Show HN: ShivyC – Hobby C compiler created in Python
#8The parser has a somewhat unusual structure: https://github.com/ShivamSarodia/ShivyC/blob/master/shivyc/p... It's been a while since I've had to use the phrase "exception-oriented programming", but it fits that code well. While that might be a useful or even necessary pattern to parse something like C++ which can have almost unbounded ambiguities, AFAIK C can be parsed solely by branching on the next token in the str…
That's not an uncommon practice in Python based on its (relatively) fast handling of exceptions. Maybe you could call it "break things and move fast."
Re: Show HN: ShivyC – Hobby C compiler created in Python
#9The parser has a somewhat unusual structure: https://github.com/ShivamSarodia/ShivyC/blob/master/shivyc/p... It's been a while since I've had to use the phrase "exception-oriented programming", but it fits that code well. While that might be a useful or even necessary pattern to parse something like C++ which can have almost unbounded ambiguities, AFAIK C can be parsed solely by branching on the next token in the str…
Re: Show HN: ShivyC – Hobby C compiler created in Python
#10Earlier quoted context omitted.
That's not an uncommon practice in Python based on its (relatively) fast handling of exceptions. Maybe you could call it "break things and move fast."
Using exceptions is totally common, but this seems to raise/catch/log 6 errors each time it tries to parse a `for` statement. I'm a noob when it comes to compilers, but maybe a token -> function dictionary would be a better approach?