Question

The language generated by the grammar in Figure 7.8 uses the terminal x to introduce the base. Amore common convention is to separate the base from the string of digits by some terminal symbol. Instead of x 8 4 3 1 to represent , a language following the common convention would use 8 x 4 3 1.

(a) Design an LALR(1) grammar for such a language and specify the semantic actions that compute the string’s numeric value. In your solution, allow the absence of a base specification to default to base 10, as in Figure 7.8.

(b) Discuss the tradeoffs of this language and your grammar as compared with the language and grammar of Figure 7.8.
1 Start Digsans call PRINT(ans val) 2 Digs up Digs

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Compiler Design Overview Computers are a balanced mix of software and hardware. Hardware is just a piece of mechanical deviceAssembler Relocatable Machine Code Library files/ Relocatable modules Linker Executable Machine Code Loader Memory The high-lBefore diving straight into the concepts of compilers, we should understand a few other tools that work closely with compilerCross-compiler A compiler that runs on platform (A) and is capable of generating executable code for platform (B) is called aA compiler can have many phases and passes. Pass A pass refers to the traversal of a compiler through the entire program PhasLexical Analyzer Syntax Analyzer Semantic Analyzer Intermediate Code.... Symbol Table Error Handler Generator Machine IndepenLexical Arlaiysis The first phase of scanner works as a text scanner. This phase scans the source code as a stream of charactalphabets, i.e. a string of zero length is known as an empty string and is denoted by E (epsilon) Special Symbols A typical hRegular expressions have the capability to express finite languages by defining a pattern for finite strings of symbols. ThePrecedence and Associativity a, concatenation (.), and (pipe sign) are left associative a*has the highest precedence ConcatenThe only problem left with the lexical analyzer is how to verify the validity of a regular expression used in specifying theFinite Automata Construction Let L(r) be a regular language recognized by some finite automata (FA) a States States of FA areExample We assume FA accepts any three digit binary value ending in digit 1 1 qo Of start final 0 Longest Match Rule When theWe have seen that a lexical analyzer can identify tokens with the help of regular expressions and pattern rules. But a lexicadenote sets of strings. The non-terminals define sets of strings that help define the language generated by the grammar set oSyntax Analyzers A syntax analyzer or parser takes the input from a lexical analyzer in the form of token streams. The parserRight-most Derivation If we scan and replace the input with production rules, from right to left, it is known as right-most d

Add a comment
Know the answer?
Add Answer to:
The language generated by the grammar in Figure 7.8 uses the terminal x to introduce the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT