1

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:

#include<stdio.h>

    funcName()
    {
        printf("Hello World");

    }

as

    hash include left-angle-bracket stdio.h right-angle-bracket
    newline
    camelcase funcName open-paren close-paren
    newline
    open bracket
    newline
    printf open-paren quote-mark Hello World quote-mark close-paren semi-colon
    newline
    close-bracket
George
  • 285
  • 1
  • 7
  • 3
    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... – Evil Sep 17 '17 at 03:53
  • 1
    This is more of a programming exercise. The parsing problem for C has been solved literally decades ago. – Yuval Filmus Sep 17 '17 at 07:23
  • 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++. – Nat Sep 18 '17 at 18:21
  • Actually, as-asked, this seems more like a StackOverflow or even a SuperUser question than a CS question. – Nat Sep 18 '17 at 18:23
  • @nat I would use sed it is a streaming text editor. e.g. sed -r -e 's/\{/open bracket/g' -e … – ctrl-alt-delor Sep 20 '17 at 16:56

0 Answers0