新程序员理解的术语解析是什么? [英] What is parsing in terms that a new programmer would understand?

查看:70
本文介绍了新程序员理解的术语解析是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名获得计算机科学学位的大学生.我的很多同学确实没有做很多编程工作.他们已经完成了课堂作业,但是老实说,这些问题并没有真正教会您如何编程.

I am a college student getting my Computer Science degree. A lot of my fellow students really haven't done a lot of programming. They've done their class assignments, but let's be honest here those questions don't really teach you how to program.

我有其他几个学生问我有关如何解析事物的问题,但我不确定如何向他们解释它.最好是开始逐行查找子字符串,或者只是给他们更复杂的讲解,以了解如何使用适当的词法分析等来创建标记,使用BNF以及所有其他东西?当我尝试解释时,他们从不完全了解.

I have had several other students ask me questions about how to parse things, and I'm never quite sure how to explain it to them. Is it best to start just going line by line looking for substrings, or just give them the more complicated lecture about using proper lexical analysis, etc. to create tokens, use BNF, and all of that other stuff? They never quite understand it when I try to explain it.

最好的解释方式是什么,而又不会使他们感到困惑或阻止他们进行实际尝试.

What's the best approach to explain this without confusing them or discouraging them from actually trying.

推荐答案

我将解释解析为将某种数据转换为另一种数据的过程.

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.

例如,转弯

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

进入(C)

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

这篇关于新程序员理解的术语解析是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆