Computer Science, asked by santspgsk, 6 months ago

write a programming in Java and show the use of all the tokens and highlight the places where you have used the tokens.
Remember to use all the tokens in a single Java programming.
Please answer fast​

Answers

Answered by neerajbansal00123
0

Answer:

Introduction In this lecture we will learn about the lowest level of the Java language: its tokens. We will learn how to recognize and classify every category of token (which is like classifying English words into their parts of speech). Towards this end, we will employ ourly new learned EBNF skilss to write and analyze descriptions for each category of token. In later lectures we will learn about a programming language's higher level structures: phrases (expressions), sentences (statements), paragraphs (blocks/methods), chapters (classes), and books (packages).

The Family History of Java Before going on to study Java, let's take a brief look, through quotes, at the languages on which Java was based, traveling back over 30 years to do so.

Where it starts: C The earliest precursor of Java is C: a language developed by Ken Thompson at Bell Labs in the early 1970s. C was used as a system programming language for the DEC PDP-7. C began achieving its widespread popularity when Bell's Unix operating system was rewritten in C. Unix was the first operating system written in a high-level language; it was distributed to universities for free, where it became popular. Linux is currently a popular (it is still free!) variant of Unix.

"C is a general-purpose programming language which features economy of expression, modern control flow and data structures, and a rich set of operators. C is not a "very high level" language, nor a "big" one, and is not specialized to any particular area of application."

- B. Kernighan/D. Ritchie: The C Programming Language

(Kernighan & Ritchie designed and implemented C)

From C to C++ "A programming language serves two related purposes: it provides a vehicle for the programmer to specify actions to be executed, and it provides a set of concepts for the programmer to use when thinking about what can be done. The first aspect ideally requires a language that is "close to the machine," so that all important aspects of a machine are handled simply and efficiently in a way that is reasonably obvious to the programmer. The C language was primarily designed with this in mind. The second aspect ideally requires a language that is "close to the problem to be solved" so that the concepts of a solution can be expressed directly and concisely. The facilities added to C to create C++ were primarily designed with this in mind"

- B. Stroustrup: The C++ Programming Language (2nd Ed)

(Stroustrup designed and implemented C++)

Java as a Successor to C++ "The Java programming language is a general-purpose, concurrent, class-based, object-oriented language. It is designed to be simple enough that many programmer can achieve fluency in the language. The Java programming language is related to C and C++ but it is organized rather differently, with a number of aspects of C and C++ omitted and a few ideas from other languages included. It is intended to be a production language, not a research language, and so, as C.A.R. Hoare suggested in his classic paper on language design, the design has avoided including new and untested features.

...

The Java programming language is a relatively high-level language, in that details of the machine representation are not available through the language. It includes automatic storage management, typically using a garbage collector, to avoid the safety problems of explicit deallocation (as in C's free or C++'s delete). High-performance garbage-collected implementations can have bounded pauses to support systems programming and real-time applications. The language does not include any unsafe constructs, such as array accesses without index checking, since such unsafe constructs would cause a program to behave in an unspecified way."

- J. Gosling, B. Joy, G. Steele, G. Bracha: The Java Language Specification

Overview of Tokens in Java: The Big 6 In a Java program, all characters are grouped into symbols called tokens. Larger language features are built from the first five categories of tokens (the sixth kind of token is recognized, but is then discarded by the Java compiler from further processing). We must learn how to identify all six kind of tokens that can appear in Java programs. In EBNF we write one simple rule that captures this structure:

token <= identifier | keyword | separator | operator | literal | comment

We will examine each of these kinds of tokens in more detail below, again using EBNF. For now, we briefly describe in English each token type.

Identifiers: names the programmer chooses

Keywords: names already in the programming language

Separators (also known as punctuators): punctuation characters and paired-delimiters

Operators: symbols that operate on arguments and produce results

Literals (specified by their type)

Numeric: int and double

Logical: boolean

Textual: char and String

Reference: null

Comments

Line

Block

Similar questions