Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need asnwer for D and E only 4. When describing the structure of a programming language, we often use the formalisms of regular languages (to

Need asnwer for D and E only

image text in transcribed

4. When describing the structure of a programming language, we often use the formalisms of regular languages (to represent legal tokens) and context-free languages (to represent legal structures built up of these tokens). However, the formal machines that recognize these language families (finite-state automata and push-down automata) aren't immediately useful for scanning and parsing, respectively. Answer the following questions concerning how these machines are adapted for use in a compiler: (a) (2 points) To start off, the automata are recognizers: they simply say whether a string is in the language or not. What additional actions are needed for the tasks of scanning and parsing? (b) (2 points) A program usually consists of more than one token, and yet a finite-state automaton only recognizes a single string. How can a compiler use a finite state automaton? (c) (2 points) Tokens are often not self-delimiting. For example, the string a 2i could be a single identifier token or could be three tokens (the identifier a followed by the number 2 followed by the identifier i). How is this ambiguity resolved in a compiler? PhD (Day 2) Qualifying Exam (d) (2 points) The grammar used for parsing a language is usually not convenient for describing program structure to the rest of the compiler. Give an example grammar for arithmetic expressions with addition and multiplication that is acceptable to a top-down (that is, predictive or LL) parser, but which does not give the "true" structure of the language. Explain why the need for the grammar to be top-downparseable prevents it from intuitively describing the structure of expressions. (e) (2 points) Given a parser-generator such as yacc or bison, how do we handle the situation that the grammar used for parsing is not convenient for performing static semantic checking

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

More Books

Students also viewed these Databases questions

Question

4a+2b=20 15+5b=60 how to solve step by step

Answered: 1 week ago

Question

1. Write down two or three of your greatest strengths.

Answered: 1 week ago

Question

What roles have these individuals played in your life?

Answered: 1 week ago

Question

2. Write two or three of your greatest weaknesses.

Answered: 1 week ago