Ss Lab Viva Questions

April 4, 2018 | Author: Charlie Choco | Category: Parsing, Regular Expression, Theoretical Computer Science, Linguistics, Grammar


Comments



Description

[Type the document title] Viva Questions 1. What is lex? What is the input to it? What is its output? 2. What is Yacc? What is the input to it? What is its output? 3. What are regular expressions? 4. What is a grammar? 5. What does y.tab.h do? 6. What does lex.yy.c. do? 7. Explain this regular expression [^ tn]+ (Anything can be asked) 8. Give the regular expression to recognize a word. (Anything can be asked) 9. Explain the code. (Any statement can be asked to be explained…ex: yywrap, yylex, yyin…etc) 10. What is the functionality of input() and output() functions? 11. How do you parse a command line using lex? 12. What are token definitions? Certain Basic Concepts and Definitions: 1. What is a Parser? A Parser for a Grammar is a program which takes in the Language string as it's input and produces either a corresponding Parse tree or an Error. 2. What is the Syntax of a Language? The Rules which tells whether a string is a valid Program or not are called the Syntax. 3. What is the Semantics of a Language? The Rules which gives meaning to programs are called the Semantics of a Language. 4. What are tokens? When a string representing a program is broken into sequence of substrings, such that each substring represents a constant, identifier, operator , keyword etc of the language, these substrings are called the tokens of the Language. 5. What is the Lexical Analysis? The Function of a lexical Analyzer is to read the input stream representing the Source program, one character ata a time and to translate it into valid tokens 6. How can we represent a token in a language? The Tokens in a Language are represented by a set of Regular Expressions. A regular expression specifies a set of strings to be matched. It contains text characters and operator characters.The Advantage of using regular expression is that a recognizer can be automatically generated. Dept. Of CSE, AciT-Bangalore Page 1 the "^" which takes there special meaning. 8.E are:* An operator character may be turned into a text character by enclosing it in quotes. Are Lexical Analysis and Parsing two different Passes ? These two can form two different passes of a Parser. 9. 1 if the end of the input has been reached. It is generally used to print a summary of lexical analysis or to open another file for reading. *ab?c matches abc and ac * Within the square brackets most operators lose their special meanings except "" and "-". However it is more convenient to have the lexical Analyzer as a coroutine or a subroutine which the Parser calls whenever it requires a token. How are the tokens recognized? The tokens which are represented by an Regular Expressions are recognized in an input string by means of a state transition Diagram and Finite Automata. *a/b matches "a" but only if followed by b (the b is not matched) *a$ matches "a" only if "a" occurs at the end of a line *^a matches "a" only if "a" occurs at the beginning of a line *[abc] matches any charcter that is an "a". 10. "b" and "c". The Lexical analysis can store all the recognized tokens in an intermediate file and give it to the Parser as an input. What are regular expression? The following are the most general notations used for expressing a R. AciT-Bangalore Page 2 . Of CSE.m} n-m Occurrences Suppose we want to express the 'C' identifiers as a regular Expression:identifier=letter(letter|digit)* The Rules for writting R.[Type the document title] 7. or by preceding it with a (backslash). Dept.E. Symbol Description | OR (alternation) () Group of Subexpression * 0 or more Occurrences ? 0 or 1 Occurrence + 1 or more Occurrences {n. What is the significance of the yywrap() function ? The yywrap() function is executed when the lexical analyzer reaches the end of the input file. The yywrap() function should return 0 if it has arranged for additional input. "b" or "c" *[^abc] matches any charcter but "a". Declarations 2.Subroutines In Declarations apart from the legal 'C' declarations there are few Yacc specific declarations which begin with a %sign. 4.E for the input string . YACC-Yet Another Compiler-Compiler Yacc is the Utility which generates the function 'yyparse' which is indeed the Parser. A token can also have type associated with it for good type checking and syntax directed translation. %prec Changes the precedence level associated with a particular rule to that of the following token name or literal.GrammarRules 3. use \n. If you want to match the character "" followed by "n".H.S non-terminal symbol of a production rule which should be taken as the starting point of the grammar rules. If there is no R. Of CSE. 8. 7. 1. A type of a token can be specified as %token <stack member> tokenName. LALR(1) grammar and supports both bottom-up and top-down parsing. The general format for the YACC file is very similar to that of the Lex file. 5. The format is %type <stack member> non-terminal. %start Specifies the L. it will be copied to the standard output. Things to remember: 1.%left Specifies the left associativity of aTerminal Symbol 6. 3.%type The type of a non-terminal symbol in the Grammar rule can be specified with this. All the matched expressions are contained in yytext whose length is yyleng. The Lex resolves the ambiguity in case of matching by choosing the longest match first or by choosing the rule given first. 2.[Type the document title] * "n" always matches newline.%noassoc Specifies that there is no associativity of a terminal symbol.%token These are the terminals returned by the yylex function to the yacc.%union It defines the Stack type for the Parser. %right Specifies the right associativity of a Terminal Symbol. Yacc describes a context free . 3. It is a union of various datas/structures/ objects. AciT-Bangalore Page 3 . 1. 2. with or without the quotes. Dept. Documents Similar To Ss Lab Viva QuestionsSkip carouselcarousel previouscarousel nextViva QuestionsVTU 4TH SEM CSE COMPUTER ORGANIZATION NOTES 10CS46Dbms Viva QuestionsSS and OS Lab Manual 2013(VTU)Ada Lab Manual-rvceDAA ADA Viva QuestionsVTU 4TH SEM CSE MICROPROCESSORS NOTES 10CS45VTU 5TH SEM CSE SOFTWARE ENGINEERING NOTES 10CS51dbmsAshok Kumar Java NotesCSE Course Viva Questions55229925 System Software Lab ManualWeb Viva Questions & AnswersVTU 5TH SEM CSE DBMS NOTESOS Lab Manual VTUSystem Software Question Bank 2012 With Part-B AnswersVTU 7TH SEM CSE/ISE DATA WAREHOUSING & DATA MINING NOTES 10CS755/10IS74 Viva Voce Questions With AnswersComputer Network Lab Viva Questions3rd Sem CS & is Electronic Circuits Notes(5 Chapters).VTU 6TH SEM CSE COMPUTER NETWORKS 2 NOTES 10CS64VTU 5TH SEM CSE DBMS NOTESDbms Viva Questions Viva Questions for Java Labjava unit7 vtuComputer Graphics Mini Project DESIGN AND ANALYSIS OF ALGORITHMS LABORATORY 10CSL47System Software Lab ManualNetwork Viva Questions and AnswersVTU CSE Notes for All SemestersFooter MenuBack To TopAboutAbout ScribdPressOur blogJoin our team!Contact UsJoin todayInvite FriendsGiftsLegalTermsPrivacyCopyrightSupportHelp / FAQAccessibilityPurchase helpAdChoicesPublishersSocial MediaCopyright © 2018 Scribd Inc. .Browse Books.Site Directory.Site Language: English中文EspañolالعربيةPortuguês日本語DeutschFrançaisTurkceРусский языкTiếng việtJęzyk polskiBahasa indonesiaSign up to vote on this titleUsefulNot usefulMaster your semester with Scribd & The New York TimesSpecial offer for students: Only $4.99/month.Master your semester with Scribd & The New York TimesRead Free for 30 DaysCancel anytime.Read Free for 30 DaysYou're Reading a Free PreviewDownloadClose DialogAre you sure?This action might not be possible to undo. Are you sure you want to continue?CANCELOK
Copyright © 2024 DOKUMEN.SITE Inc.