Is there a way to convert, i.e., C code into English? The purpose would be to convert source code into a Text-To-Speech converter which would enable someone to "listen" to source code.

EDIT: An alternative idea would be to parse C code to be more "listenable", for example parse:


        printf("Hello World");



    hash include left-angle-bracket stdio.h right-angle-bracket
    camelcase funcName open-paren close-paren
    open bracket
    printf open-paren quote-mark Hello World quote-mark close-paren semi-colon
  • 3
    $\begingroup$ Yes, the second idea seems like standard substitution. Just replace the occurences. With camelCase it would also require to check the tokens. The first one - it depends what you mean by converting into English. Please keep in mind that you do not need to put "Edit" into the text, there is revisions history available. I think you can do better than tokenizing, it would be possible to say "string" and ignore quotemarks, say that some standard library is included without reading #< .h>, but for now it is not fully clear what do you expect. Also listening to "newline" seems redundant... $\endgroup$ – Evil Sep 17 '17 at 3:53
  • 1
    $\begingroup$ This is more of a programming exercise. The parsing problem for C has been solved literally decades ago. $\endgroup$ – Yuval Filmus Sep 17 '17 at 7:23
  • $\begingroup$ The title sounded like you wanted a program that'd describe C code in native English, but your actual question's a lot simpler. You could really just use a regex command to do those replacements in a common text editor, e.g. in Notepad++. $\endgroup$ – Nat Sep 18 '17 at 18:21
  • $\begingroup$ Actually, as-asked, this seems more like a StackOverflow or even a SuperUser question than a CS question. $\endgroup$ – Nat Sep 18 '17 at 18:23
  • $\begingroup$ @nat I would use sed it is a streaming text editor. e.g. sed -r -e 's/\{/open bracket/g' -e … $\endgroup$ – ctrl-alt-delor Sep 20 '17 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.