编译器如何解释java关键字 [英] How compiler interprets java keywords

查看:88
本文介绍了编译器如何解释java关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道编译器如何解释java关键字,ex throw和throws

I want to know How compiler interprets java keywords, ex throw and throws

推荐答案

请参阅我对该问题的评论,其他评论。以任何实际合理的方式回答这个问题是不可行的。



但是,我可以正式解决这个问题。从这个角度来看,答案是: Java编译器并没有真正解释那些单词。在扫描和解析(优化等)之后,它只是将代码编译为Java 字节码,非常正式。编译器不知道代码的语义。编译的Java源代码不是机器代码,它是跨平台的字节码。 下一步由JIT编译器完成

http:// en。 wikipedia.org/wiki/Java_bytecode [ ^ ],

http://en.wikipedia.org/wiki/Just-in-time_compilation [ ^ ]。



另请参阅: http://en.wikipedia.org/wiki/Bytecode [ ^ ]。



-SA
Please see my comment to the question, other comments. It's not feasible to answer this question in any practically sensible way.

However, I can formally work around the situation. From that standpoint, the answer is: the Java compiler does not really "interpret" those words. After scanning and parsing (optimization, etc), it merely compiles the code to Java bytecode, pretty formally. A compiler does not "know" the semantic of the code. Compiled Java source code is not a machine code, it is a cross-platform bytecode. Next step is done by a JIT compiler:
http://en.wikipedia.org/wiki/Java_bytecode[^],
http://en.wikipedia.org/wiki/Just-in-time_compilation[^].

See also: http://en.wikipedia.org/wiki/Bytecode[^].

-SA


在尝试使用编译器之前,我建议先尝试理解解析器。在理解解析器时,至少知道什么语法和语义是什么。在你理解了这两个人之后,一个很难的方法是在你面前编译,例如解析器树到机器语言。

例如Niklaus Wirth先生已经发表了很多关于这个主题的文章(是的,非常古老,但也有许多基础知识,它们仍然有效)。他是数据隐藏的发明者之一,我的观点是oop的基础知识之一。



http://en.wikipedia.org/wiki/Niklaus_Wirth [ ^ ]



直接解析的最爱之一: .NET的计算引擎 [ ^ ]
Before trying to go for compiler I suggest first to try to understand parsers. When understanding parser at least you know what syntax is and what semantic is. After you understand these twos a hard way is in front of you to compile e.g. the parser tree down to machine language.
e.g. Mr. Niklaus Wirth has published a lot about this topic (yes, very old but also lot of very basics, which are still valid). He was one of the "inventor" for data hiding, which for my Point of view is one of the Basics for oop.

http://en.wikipedia.org/wiki/Niklaus_Wirth[^]

One of my favorites for straight Forward parsing: A Calculation Engine for .NET[^]


这篇关于编译器如何解释java关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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