关键字是如何开发的?
How are keywords developed?
James Gosling 博士是否为 Java 关键字编写了代码?
如果是,
- 如何像查看源代码一样查看Java关键字代码?
- 有什么方法可以创建用户定义的关键字吗?
这是我的猜测:没有Java关键字代码,Java编译器保存了一个关键字列表,这有助于编译器理解代码。
这个猜测是否正确?
Has Dr James Gosling written code for Java keywords?
是的,当他编写第一个 Java 编译器时,他可能编写了处理关键字编译的代码。
How to view Java keywords code like we view source code?
while
或if
等后面没有"Java method",这些是编译器专门处理的语言原语。
Is there any way to create user defined keyword?
不,您不能创建用户定义的关键字。关键字的语义在 Java 语言规范中指定,并由编译器特殊处理。
There is no Java keyword code. Java complier holds list of keywords, which helps the complier to understand code.
是的。差不多就这些了。
来源:我是javac开发者
通常,编写能够将一种语言转换为其他语言的软件的过程是由 "compiler of compilers" 工具通过指定语法来完成的,通常是 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.
如果你想定义自己的关键字,你可以看看Scala,其实Scala中所有的关键字其实都是方法。
这是一个示例,您可以在其中实现一个类似于其他语言中的 'using' 关键字的方法,以显式处理对象,http://blog.omega-prime.co.uk/2007/08/25/implementing-the-disposable-pattern-in-scala/
James Gosling 博士是否为 Java 关键字编写了代码?
如果是,
- 如何像查看源代码一样查看Java关键字代码?
- 有什么方法可以创建用户定义的关键字吗?
这是我的猜测:没有Java关键字代码,Java编译器保存了一个关键字列表,这有助于编译器理解代码。
这个猜测是否正确?
Has Dr James Gosling written code for Java keywords?
是的,当他编写第一个 Java 编译器时,他可能编写了处理关键字编译的代码。
How to view Java keywords code like we view source code?
while
或if
等后面没有"Java method",这些是编译器专门处理的语言原语。
Is there any way to create user defined keyword?
不,您不能创建用户定义的关键字。关键字的语义在 Java 语言规范中指定,并由编译器特殊处理。
There is no Java keyword code. Java complier holds list of keywords, which helps the complier to understand code.
是的。差不多就这些了。
来源:我是javac开发者
通常,编写能够将一种语言转换为其他语言的软件的过程是由 "compiler of compilers" 工具通过指定语法来完成的,通常是 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.
如果你想定义自己的关键字,你可以看看Scala,其实Scala中所有的关键字其实都是方法。
这是一个示例,您可以在其中实现一个类似于其他语言中的 'using' 关键字的方法,以显式处理对象,http://blog.omega-prime.co.uk/2007/08/25/implementing-the-disposable-pattern-in-scala/