什么是解析/解析? [英] What is Parse/parsing?

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

问题描述

在Java中,解析究竟是什么?为什么使用它们?

In Java, What exactly is Parsing? Why are they used?

例如: Integer.parseInt(...),并解析一个字符串?

For example: Integer.parseInt(...), and parsing a string?

推荐答案

你可以说解析一串字符分析这个字符串来查找令牌或项目,然后从结果创建结构。

在您的示例中,调用 Integer.parseInt 解析此字符串以查找整数

In your example, calling Integer.parseInt on a string is parsing this string to find an integer.

所以,如果你有:

String someString = "123";

然后你调用:

int i = Integer.parseInt( someString );

你告诉java分析123 string并在那里找到一个整数。

You're telling java to analyze the "123" string and find an integer there.

其他示例:

java编译器执行的一个操作,它编译你的源代码是解析.java文件并创建与java语法匹配的标记。

One of the actions the java compiler does, when it compiles your source code is to "parse" your .java file and create tokens that match the java grammar.

当你无法正确编写源代码时(例如忘记在结尾处添加; 语句),它是识别错误的解析器。

When you fail to write the source code properly ( for instance forget to add a ; at the end of a statement ), it is the parser who identifies the error.

以下是更多信息: http://en.wikipedia.org/wiki/Parse

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

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