Question: 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

 4. When describing the structure of a programming language, we often

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 2 i 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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!