parse in programming

最近在參與gnome項目,在與gnome-logs開發者David King交流時,他說道:"This task involves doing some extra parsing of the systemd catalog"。沒有開發經驗更沒有太多英文專業詞彙的我就搞不懂這裏parse是什麼意思了。有道詞典將該詞翻譯爲解析,可是這樣太寬泛了啊。

最開始沒有去搞懂這個詞的意思,就直接看了bug相關的幾個鏈接。這麼一來,對這個詞有了一定的認識。之後就直接google搜索how to parse && programming。在搜索出來的結果中看到stack overflow的一個解答非常精彩,在此記錄一下。

問題是What's the best way to explain parsing to a new programmer?

答案是這樣的:

I'd explain parsing as the process of turning some kind of data into another kind of data.

In practice, for me this is almost always turning a string, or binary data, into a data structure inside my Program.

For example, turning

":Nick!User@Host PRIVMSG #channel :Hello!"

into (C)

struct irc_line {
    char *nick;
    char *user;
    char *host;
    char *command;
    char **arguments;
    char *message;
} sample = { "Nick", "User", "Host", "PRIVMSG", { "#channel" }, "Hello!" }

stack overflow鏈接:http://stackoverflow.com/questions/2933192/whats-the-best-way-to-explain-parsing-to-a-new-programmer

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章