Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to know How compiler interprets java keywords, ex throw and throws
Posted
Comments
Mehdi Gholam 31-Oct-14 9:23am    
You have to read about compiler theory and abstract syntax trees which is not a topic that can be covered here.
Richard MacCutchan 31-Oct-14 13:01pm    
It reads them, compares them with entries in a table, and takes actions according to the information in the table. However, this question is not really easy to answer in a Quick Answers forum.
Sergey Alexandrovich Kryukov 31-Oct-14 13:27pm    
Do you want some of us to write a whole book on this topic? This is not a suitable question for Quick Questions & Answers. You can read on the theory of compilers, about scanners, analyzers, optimizers, code generators, etc. Or you can dig into some open-source Java implementation, but you will also need to learn how JVM works, JIT-compilation...
—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
 
Share this answer
 
v3
Comments
Maciej Los 31-Oct-14 14:33pm    
+5!
Sergey Alexandrovich Kryukov 31-Oct-14 14:34pm    
Thank you, Maciej.
—SA
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[^]
 
Share this answer
 
v3
Comments
Maciej Los 31-Oct-14 14:33pm    
+5!
[no name] 31-Oct-14 14:52pm    
Thank you for this Maciej. Regards, Bruno

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900