1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
pishuonlain [190]
3 years ago
5

1. Write a CFG to generate identifiers (IDs) in the Java Programming Language. An ID in Java is a string of characters consistin

g of letters (upper-level or lower-level), digits, underscore _ , or dollar sign $. It cannot start with a digit.

Computers and Technology
1 answer:
nordsb [41]3 years ago
3 0

Answer:

Explanation:

From the given condition in the question, An ID in Java is a string of characters consisting of letters (upper-level or lower-level), digits, underscore _ , or dollar sign $. It cannot start with a digit. Let C be a sequence of characters consisting of letters (upper-level or lower-level), digits, underscore _ , or dollar sign $ with no restriction on starting character. We can observe that it is the ID except first character. So, ID can be defined as $ followed by C, _ followed by C, digits followed by C and alphabets followed by C. Let N be a digit, and A be an alphabet, we define ID as  follows

S ------> $C / _C   / AC

N ------->0/1/2/3/4/5/6/7/8/9

A -------->a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z

We need to define C also, which is nothing but the string of character consisting of letters (upper-level or lower-level), digits, underscore _ , or dollar sign $. So, C can be defined as

C --------> $C / _C  /  NC  / AC / N / A

Hence our grammar for ID in java is:

S ------> $C / _C   / AC

C --------> $C / _C  /  NC  / AC / N / A

N ------->0/1/2/3/4/5/6/7/8/9

A -------->a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z

In a leftmost derivation, we start with the start symbol and put the value of Non terminal that appers in the leftmost position and move gradually to right.

Here is the leftmost derivation of string $$_1uP

S

$C ...........using S--->$C

$$C ............using C---->$C

$$_C .........using C------->_C

$$_NC ........using C------->NC

$$_1C ........using N----->1

$$_1AC ........using C----->AC

$$_1uC .......using A------>u

$$_1uA ......using C----->A

$$_1uP ........using A----->P

You might be interested in
Outside of a C program, a file is identified by its ________while inside a C program, a file is identified by a(n) ________. fil
Alexxandr [17]

Answer: name, file stream object

Explanation:

4 0
3 years ago
In a relational database, the three basic operations used to develop useful sets of data are:
lesya692 [45]
<span>Which is not a component of a database that describes how data is stored?</span>
6 0
4 years ago
When you tell an acquaintance your telephone number, you do not recite the digits one by one at a constant rate, as in "3, 3, 7,
yKpoI14uk [10]

Answer:

chunking and short-term is the correct answer of this question.

Explanation:

chunking is a strategy to enhance a short-term memory.

Chunking is an method used to separate larger numbers that can not be psychologically separated.Chunking is the grouping of words in one sentence into short, important phrases. A chunk is the material segment that is used in many graphical formats, such as PNG etc.

Short-term memory is the knowledge a person is considering or is conscious of. This is also called healthy or main memory.

3 0
4 years ago
What is star topology
Alexxx [7]
Every node connects to a central network device. like a hub, switch, or computer.
4 0
3 years ago
Read 2 more answers
What defines which part of the IP address is the Network ID and the Host ID?
Brilliant_brown [7]

Answer:

Subnet Mask

Explanation:

Literally the answer.

5 0
3 years ago
Read 2 more answers
Other questions:
  • design aDesign a queue abstract data type for float elements in a language that you know, including operations for enqueue, dequ
    10·1 answer
  • What is a benefit of the Name Manager feature?​
    12·2 answers
  • Project: Math Tutor Program with Error Handling
    9·2 answers
  • What are the advantages of customer relationship managment​
    10·1 answer
  • Which of the following ""invisible"" marks represents an inserted tab?
    10·1 answer
  • How many string object are in 128,55 in python
    7·2 answers
  • Which of the following best explains what happens when a new device is connected to the Internet?
    9·1 answer
  • Sample outputs with inputs 9 5 2 -1 in python.
    8·1 answer
  • Spreadsheets are sometimes credited with legitimizing the personal computer as a business tool. Why do you think they had such a
    13·1 answer
  • The field of ____ is concerned with the technical issues involved in information display. computer science
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!