Hi wlievens, fair call, but there are two possibilities: get your mates to pledge $20 each till the pledges reach say $300, or write it “for love” like a true open sourcer and come away with honour, glory, and at least $65 as a bonus. :-)
A hint for implementors: if you do this as a source-to-source translator (which is the objective, as I see it) you can use the #line and #file directives to maintain correct source references in the compiler transcripts.
Ben, I have already started. At first I was going to code the program in python until I read your first comment.
Now I have aquainted myself with lex and yacc. You wrote that you did not want to actually parse C - so I thought parsing might actually be a good idea.
Sounds good. Coding it in Python would certainly be a good start – shouldn’t be too hard to convert it to C from there. Heading the lex/yacc direction sounds a bit complicated, but then again, I’ve never used ‘em, so that may just be me. :-)
Lex/Yacc are probably the way to go. You’re defining a new language here (C with Python blocks) and having a formal yacc/bison grammar for it would provide a solid definition of that language.
Sinc you want to go both ways, you’d also want to try to find an open-source C grammar that you can use to generate the C-with-Python-blocks code.
The C code generated by lexx/flex and yacc/bison could be part of the distribution if you want people with only a C compiler to be able to use it, though many/most Unix systems include them (including Mac OS X).
harold, you’re right that it’s a “new language”, but I’m still in two minds about lex/yacc, and suspect they might actually make things more complicated, but I’m willing to leave that up to developer (mattihas). A working solution is a pretty good solution. :-)
The reason I think it might make it more complicated: wouldn’t you need to have the entire language grammar, which, especially for C++, might be quite large/icky? Probably grammars for C and C++ are readily available, and you could just hack one of those, but it might well be harder than just have a couple of simple rules to parse comments and strings (I suspect those are the only hard things). The other reason, as mattihas hinted at, is that you’ll need more tools/dependencies to make it.
mattihas, you could certainly distribute the generated source code in the package (good idea, in fact), but you’ll need to distribute the original source as well.
Ben, perhaps you are right about the complexities of C++ (and even C may prove to complex).
P.S. The above sentence only serves as a justification for this comment as I wanted to say that my name is Matthias and I just introduced a typo into my user. But I could not figure out, yet, how to change it.
About your username, Matthias: heh, I wondered whether that was the case. I’d never heard of a Mattihas before. :-) We haven’t allowed users to change their user names, mainly because it’s used for their user page and if it changed you’d get link rot. It’s also used for sign-in, so it might be confusing if it changed. But I’ve emailed you more detail about this issue.
16 comments (oldest first)
Oh yes, I forgot to mention: it should probably be written in C, so that people who only have C installed (and not Python) can easily use it.
I’d love doing this; but not for $100 :-)
Hi wlievens, fair call, but there are two possibilities: get your mates to pledge $20 each till the pledges reach say $300, or write it “for love” like a true open sourcer and come away with honour, glory, and at least $65 as a bonus. :-)
A hint for implementors: if you do this as a source-to-source translator (which is the objective, as I see it) you can use the #line and #file directives to maintain correct source references in the compiler transcripts.
I am not doing it for the $$$. ;) Just don’t tell anyone that I would probably have done a version for free.
Just wondering how you’re going on this, Matthias?
Ben, I have already started. At first I was going to code the program in python until I read your first comment.
Now I have aquainted myself with lex and yacc. You wrote that you did not want to actually parse C - so I thought parsing might actually be a good idea.
Sounds good. Coding it in Python would certainly be a good start – shouldn’t be too hard to convert it to C from there. Heading the lex/yacc direction sounds a bit complicated, but then again, I’ve never used ‘em, so that may just be me. :-)
Lex/Yacc are probably the way to go. You’re defining a new language here (C with Python blocks) and having a formal yacc/bison grammar for it would provide a solid definition of that language.
Sinc you want to go both ways, you’d also want to try to find an open-source C grammar that you can use to generate the C-with-Python-blocks code.
The C code generated by lexx/flex and yacc/bison could be part of the distribution if you want people with only a C compiler to be able to use it, though many/most Unix systems include them (including Mac OS X).
I agree, Harold.
Too all: I’ve been busy with my math studies lately. I will go back to nobraces, as soon as possible.
Edit: Would just distributing the source code generated by lex/yacc work? As far as I know you need special libraries for the linking..
harold, you’re right that it’s a “new language”, but I’m still in two minds about lex/yacc, and suspect they might actually make things more complicated, but I’m willing to leave that up to developer (mattihas). A working solution is a pretty good solution. :-)
The reason I think it might make it more complicated: wouldn’t you need to have the entire language grammar, which, especially for C++, might be quite large/icky? Probably grammars for C and C++ are readily available, and you could just hack one of those, but it might well be harder than just have a couple of simple rules to parse comments and strings (I suspect those are the only hard things). The other reason, as mattihas hinted at, is that you’ll need more tools/dependencies to make it.
mattihas, you could certainly distribute the generated source code in the package (good idea, in fact), but you’ll need to distribute the original source as well.
Ben, perhaps you are right about the complexities of C++ (and even C may prove to complex).
P.S. The above sentence only serves as a justification for this comment as I wanted to say that my name is Matthias and I just introduced a typo into my user. But I could not figure out, yet, how to change it.
About your username, Matthias: heh, I wondered whether that was the case. I’d never heard of a Mattihas before. :-) We haven’t allowed users to change their user names, mainly because it’s used for their user page and if it changed you’d get link rot. It’s also used for sign-in, so it might be confusing if it changed. But I’ve emailed you more detail about this issue.
I would suggest Antlr v3 over lex/yacc. It’s much more modern, in a good way, and has more attractive input and output. Anyway, that’s my $20 worth.
Sorry for being overdue. I have some things to do and did not prioritize nobraces high enough.
Expect gradual progress in the next few weeks.
Good stuff, Matthias. Looking forward to it. :-)
Add a comment
Before you add a comment you must be signed up – it takes about 30 seconds. Sign up now.