简体   繁体   中英

Terminal symbol and non-terminal symbol

could anyone tell me the difference between Terminal and non-terminal symbol in the case of Java?

Does Terminal mean a Keyword and non-terminal any common string literal?

In grammars, a terminal is some form of token (keyword, identifier, symbol, literal, etc.) whilst a non-terminal reference rules.

So both a keyword and a literal string would be terminals. A statement would be non-terminal.

(That's probably a really bad description. Read the dragon book.)

EDIT (not by original answerer): I'd never heard of the dragon book, so here's a reference .

Your question is rather unclear. Are you talking about the formal grammar which describes the Java language? If so, everything you see in a syntactically valid Java file is (part of) a terminal.

A string is 'in' the language described by some grammar if it can be produced by applying the production rules of the grammar until only terminals remain.

Perhaps you should check out the Java Language Specification ,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM