Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How are keywords developed?

Has Dr James Gosling written code for the Java keywords?

If yes,

  • How can I view Java keywords code like we view source code?
  • Is there any way to create a user defined keyword?

Here's what I would guess: There is no Java keyword code, the Java compiler holds a list of keywords, which helps the compiler to understand code.

Is this guess correct?

like image 505
Premraj Avatar asked May 11 '15 08:05

Premraj


2 Answers

Has Dr James Gosling written code for Java keywords?

Yes, when he wrote the first Java compiler he probably wrote code to handle compilation of keywords.

How to view Java keywords code like we view source code?

There is no "Java method" behind while or if etc. These are language primitives handled specially by the compiler.

Is there any way to create user defined keyword?

No, you can't create user defined keywords. The semantics of the keywords are specified in the Java Language Specification and treated specially by the compiler.

There is no Java keyword code. Java complier holds list of keywords, which helps the complier to understand code.

Yes. That's pretty much it.

Source: I'm a javac developer

like image 80
aioobe Avatar answered Oct 30 '22 08:10

aioobe


Usually the process of writing a software able to turning a language in something else is done by "compiler of compilers" tools by specifying a grammar, typically a BNF form is used. The first usable version of the language are in many case used to create the compiler itself, in order to prove the language effectiveness. If you want to extend java by changing the keywords and adding different ones, you should create a new language, maybe starting from the Java Grammar itself.

like image 44
Felice Pollano Avatar answered Oct 30 '22 10:10

Felice Pollano