The document describes a compiler design lab manual. It contains 12 experiments related to compiler design topics like lexical analysis, parsing, syntax analysis, code generation etc. It also lists the program outcomes and program specific outcomes attained through each experiment. The objective of the lab is to provide students hands-on experience with basic compiler construction techniques and tools.
The document discusses compilers and their role in translating high-level programming languages into machine-readable code. It notes that compilers perform several key functions: lexical analysis, syntax analysis, generation of an intermediate representation, optimization of the intermediate code, and finally generation of assembly or machine code. The compiler allows programmers to write code in a high-level language that is easier for humans while still producing efficient low-level code that computers can execute.
This document discusses language processors and their fundamentals. It begins by explaining the semantic gap between how software is designed and implemented, and how language processors help bridge this gap. It then covers different types of language processors like translators, interpreters, and preprocessors. The key activities of language processors - analysis and synthesis - are explained. Analysis includes lexical, syntax and semantic analysis, while synthesis includes memory allocation and code generation. Language specifications using grammars and different binding times are also covered. Finally, common language processing development tools like LEX and YACC are introduced.
Load Balancing In Distributed ComputingRicha Singh
Load Balancing In Distributed Computing
The goal of the load balancing algorithms is to maintain the load to each processing element such that all the processing elements become neither overloaded nor idle that means each processing element ideally has equal load at any moment of time during execution to obtain the maximum performance (minimum execution time) of the system
The document contains summaries of 4 programs written by Ilias Ahmed:
1) A program to add two numbers in C that uses scanf and printf to get user input and display the sum.
2) A program that checks if a user input string is a comment in C by checking for // or /* at the start.
3) A program that checks what operator a user input string represents, such as >, <, =, +, -, etc.
4) Details about Ilias Ahmed's compiler design lab work and qualifications including Oracle OCP, Java certification, and Red Hat Linux certification.
Natural language processing involves parsing text using a lexicon, categorization of parts of speech, and grammar rules. The parsing process involves determining the syntactic tree and label bracketing that represents the grammatical structure of sentences. Evaluation measures for parsing include precision, recall, and F1-score. Ambiguities from multiple word senses, anaphora, indexicality, metonymy, and metaphor make parsing challenging.
This document discusses subprograms (also called subroutines) in programming languages. It covers:
- The basic definitions and characteristics of subprograms, including headers, parameters, and local variables.
- Different parameter passing methods like pass-by-value, pass-by-reference, and their implementation in common languages.
- Additional features of subprograms including overloading, generics, and functions passing subprograms as parameters.
This document presents information on fuzzy arithmetic and operations. It discusses fuzzy numbers, linguistic variables, and arithmetic operations on fuzzy intervals and fuzzy numbers. Some key points:
- Fuzzy numbers are fuzzy sets with certain properties like being normal, having closed interval alpha-cuts, and bounded support.
- Linguistic variables assign linguistic values like "young" or "old" to numerical variables. They are represented as fuzzy sets.
- Arithmetic operations on fuzzy intervals are defined based on the corresponding operations on their alpha-cuts, which are closed intervals. Properties like commutativity and distributivity are discussed.
- Operations on fuzzy numbers are similarly defined based on the alpha-cuts of the resulting fuzzy
The document discusses compilers and their role in translating high-level programming languages into machine-readable code. It notes that compilers perform several key functions: lexical analysis, syntax analysis, generation of an intermediate representation, optimization of the intermediate code, and finally generation of assembly or machine code. The compiler allows programmers to write code in a high-level language that is easier for humans while still producing efficient low-level code that computers can execute.
This document discusses language processors and their fundamentals. It begins by explaining the semantic gap between how software is designed and implemented, and how language processors help bridge this gap. It then covers different types of language processors like translators, interpreters, and preprocessors. The key activities of language processors - analysis and synthesis - are explained. Analysis includes lexical, syntax and semantic analysis, while synthesis includes memory allocation and code generation. Language specifications using grammars and different binding times are also covered. Finally, common language processing development tools like LEX and YACC are introduced.
Load Balancing In Distributed ComputingRicha Singh
Load Balancing In Distributed Computing
The goal of the load balancing algorithms is to maintain the load to each processing element such that all the processing elements become neither overloaded nor idle that means each processing element ideally has equal load at any moment of time during execution to obtain the maximum performance (minimum execution time) of the system
The document contains summaries of 4 programs written by Ilias Ahmed:
1) A program to add two numbers in C that uses scanf and printf to get user input and display the sum.
2) A program that checks if a user input string is a comment in C by checking for // or /* at the start.
3) A program that checks what operator a user input string represents, such as >, <, =, +, -, etc.
4) Details about Ilias Ahmed's compiler design lab work and qualifications including Oracle OCP, Java certification, and Red Hat Linux certification.
Natural language processing involves parsing text using a lexicon, categorization of parts of speech, and grammar rules. The parsing process involves determining the syntactic tree and label bracketing that represents the grammatical structure of sentences. Evaluation measures for parsing include precision, recall, and F1-score. Ambiguities from multiple word senses, anaphora, indexicality, metonymy, and metaphor make parsing challenging.
This document discusses subprograms (also called subroutines) in programming languages. It covers:
- The basic definitions and characteristics of subprograms, including headers, parameters, and local variables.
- Different parameter passing methods like pass-by-value, pass-by-reference, and their implementation in common languages.
- Additional features of subprograms including overloading, generics, and functions passing subprograms as parameters.
This document presents information on fuzzy arithmetic and operations. It discusses fuzzy numbers, linguistic variables, and arithmetic operations on fuzzy intervals and fuzzy numbers. Some key points:
- Fuzzy numbers are fuzzy sets with certain properties like being normal, having closed interval alpha-cuts, and bounded support.
- Linguistic variables assign linguistic values like "young" or "old" to numerical variables. They are represented as fuzzy sets.
- Arithmetic operations on fuzzy intervals are defined based on the corresponding operations on their alpha-cuts, which are closed intervals. Properties like commutativity and distributivity are discussed.
- Operations on fuzzy numbers are similarly defined based on the alpha-cuts of the resulting fuzzy
This slides contains assymptotic notations, recurrence relation like subtitution method, iteration method, master method and recursion tree method and sorting algorithms like merge sort, quick sort, heap sort, counting sort, radix sort and bucket sort.
The document provides an overview of knowledge representation techniques. It discusses propositional logic, including syntax, semantics, and inference rules. Propositional logic uses atomic statements that can be true or false, connected with operators like AND and OR. Well-formed formulas and normal forms are explained. Forward and backward chaining for rule-based reasoning are summarized. Examples are provided to illustrate various concepts.
NETCONF and YANG provide an improved way to manage IoT systems compared to SNMP. NETCONF allows retrieving and manipulating state and configuration data using XML over SSH. YANG defines data models for the configuration and state information. To manage an IoT device, a YANG model is defined, the device is configured to support NETCONF, and a manager can then send NETCONF commands to retrieve data and configure the device.
what is Parsing
different types of parsing
what is parser and role of parser
what is top-down parsing and bottom-up parsing
what is the problem in top-down parsing
design of top-down parsing and bottom-up parsing
examples of top-down parsing and bottom-up parsing
Problem solving
Problem formulation
Search Techniques for Artificial Intelligence
Classification of AI searching Strategies
What is Search strategy ?
Defining a Search Problem
State Space Graph versus Search Trees
Graph vs. Tree
Problem Solving by Search
A compiler is a program that translates a program written in one language into an equivalent target language. The front end checks syntax and semantics, while the back end translates the source code into assembly code. The compiler performs lexical analysis, syntax analysis, semantic analysis, code generation, optimization, and error handling. It identifies errors at compile time to help produce efficient, error-free code.
Compiler Construction | Lecture 1 | What is a compiler?Eelco Visser
This document provides an overview of the CS4200 Compiler Construction course at TU Delft. It discusses the organization of the course into two parts: CS4200-A which covers compiler concepts and techniques through lectures, papers, and homework assignments; and CS4200-B which involves building a compiler for a subset of Java as a semester-long project. Key topics covered include the components of a compiler like parsing, type checking, optimization, and code generation; intermediate representations; and different types of compilers.
An algorithm is a set of steps to solve a problem. Algorithm efficiency describes how fast an algorithm solves problems of different sizes. Time complexity is the most important measure of efficiency, measuring the number of steps an algorithm takes based on the size of the input. Common techniques to analyze time complexity include calculating the number of operations in loops and recursions. Asymptotic notation like Big-O describes the long-term growth rate of an algorithm's running time as the input size increases.
This document provides an introduction to finite automata. It defines key concepts like alphabets, strings, languages, and finite state machines. It also describes the different types of automata, specifically deterministic finite automata (DFAs) and nondeterministic finite automata (NFAs). DFAs have a single transition between states for each input, while NFAs can have multiple transitions. NFAs are generally easier to construct than DFAs. The next class will focus on deterministic finite automata in more detail.
This document discusses hardware and software parallelism in computer systems. It defines hardware parallelism as parallelism enabled by the machine architecture through multiple processors or functional units. Software parallelism refers to parallelism exposed in a program's control and data dependencies. Modern computer architectures require support for both types of parallelism to perform multiple tasks simultaneously. However, there is often a mismatch between the hardware and software parallelism available. For example, a dual-processor system may be able to execute 12 instructions in 6 cycles, but the program's inherent parallelism may only allow completing the instructions in 7 cycles. Achieving optimal parallelism requires coordination between hardware design and software programming.
This document provides an overview of key concepts related to programming languages. It discusses the definition of a programming language and the history and evolution of popular languages from 1951 to present. It covers programming language paradigms like procedural, object-oriented, functional, and logic-based languages. It also discusses factors that influence language design like efficiency, regularity, and issues in language translation. Finally, it summarizes the structure and operation of computers and how different programming models map to underlying computer architectures.
Introduction, Macro Definition and Call, Macro Expansion, Nested Macro Calls, Advanced Macro Facilities, Design Of a Macro Preprocessor, Design of a Macro Assembler, Functions of a Macro Processor, Basic Tasks of a Macro Processor, Design Issues of Macro Processors, Features, Macro Processor Design Options, Two-Pass Macro Processors, One-Pass Macro Processors
Natural language processing (NLP) is introduced, including its definition, common steps like morphological analysis and syntactic analysis, and applications like information extraction and machine translation. Statistical NLP aims to perform statistical inference for NLP tasks. Real-world applications of NLP are discussed, such as automatic summarization, information retrieval, question answering and speech recognition. A demo of a free NLP application is presented at the end.
Very long instruction word or VLIW refers to a processor architecture designed to take advantage of instruction level parallelism
This type of processor architecture is intended to allow higher performance without the inherent complexity of some other approaches.
This document provides information about the CS416 Compiler Design course, including the instructor details, prerequisites, textbook, grading breakdown, course outline, and an overview of the major parts and phases of a compiler. The course will cover topics such as lexical analysis, syntax analysis using top-down and bottom-up parsing, semantic analysis using attribute grammars, intermediate code generation, code optimization, and code generation.
This lecture slide contains:
1. Regular Languages
2. Regular Operations
3. Closure of regular languages
4. Regular expression
5. Precedence of regular operations
6. RE for different languages
7. RE to NFA conversion
8. DFA to GNFA to RE conversion
The document discusses different approaches for concept learning from examples, including viewing it as a search problem to find the hypothesis that best fits the training examples. It also describes the general-to-specific learning approach, where the goal is to find the maximally specific hypothesis consistent with the positive training examples by starting with the most general hypothesis and replacing constraints to better fit the examples. The document also discusses the version space and candidate elimination algorithms for obtaining the version space of all hypotheses consistent with the training data.
This document contains information related to a Networks Laboratory course, including the lab manual, program objectives, outcomes, syllabus, and index. It provides:
1) An overview of the course contents, objectives to learn network commands, socket programming, analyze protocols, and use simulation tools.
2) Details on the program outcomes which focus on applying technical knowledge, lifelong learning, research, and total quality education.
3) A list of 12 experiments that will be conducted in the lab, including implementing various protocols using sockets and simulating protocols using a network simulator.
4) An index table to record details of experiments conducted like date, topic, outcomes and marks.
The document provides an introduction and overview of the COIT29222 Structured Programming course, including information about the textbook, assessments, topics to be covered, and a simple C++ program example. Students are instructed to contact their local lecturer/tutor if they have any problems or questions. Plagiarism is strictly prohibited and assignments must follow a five-step software development process using pseudocode to design programs that will be written and tested in C++, compiling the code using Visual C++.
This slides contains assymptotic notations, recurrence relation like subtitution method, iteration method, master method and recursion tree method and sorting algorithms like merge sort, quick sort, heap sort, counting sort, radix sort and bucket sort.
The document provides an overview of knowledge representation techniques. It discusses propositional logic, including syntax, semantics, and inference rules. Propositional logic uses atomic statements that can be true or false, connected with operators like AND and OR. Well-formed formulas and normal forms are explained. Forward and backward chaining for rule-based reasoning are summarized. Examples are provided to illustrate various concepts.
NETCONF and YANG provide an improved way to manage IoT systems compared to SNMP. NETCONF allows retrieving and manipulating state and configuration data using XML over SSH. YANG defines data models for the configuration and state information. To manage an IoT device, a YANG model is defined, the device is configured to support NETCONF, and a manager can then send NETCONF commands to retrieve data and configure the device.
what is Parsing
different types of parsing
what is parser and role of parser
what is top-down parsing and bottom-up parsing
what is the problem in top-down parsing
design of top-down parsing and bottom-up parsing
examples of top-down parsing and bottom-up parsing
Problem solving
Problem formulation
Search Techniques for Artificial Intelligence
Classification of AI searching Strategies
What is Search strategy ?
Defining a Search Problem
State Space Graph versus Search Trees
Graph vs. Tree
Problem Solving by Search
A compiler is a program that translates a program written in one language into an equivalent target language. The front end checks syntax and semantics, while the back end translates the source code into assembly code. The compiler performs lexical analysis, syntax analysis, semantic analysis, code generation, optimization, and error handling. It identifies errors at compile time to help produce efficient, error-free code.
Compiler Construction | Lecture 1 | What is a compiler?Eelco Visser
This document provides an overview of the CS4200 Compiler Construction course at TU Delft. It discusses the organization of the course into two parts: CS4200-A which covers compiler concepts and techniques through lectures, papers, and homework assignments; and CS4200-B which involves building a compiler for a subset of Java as a semester-long project. Key topics covered include the components of a compiler like parsing, type checking, optimization, and code generation; intermediate representations; and different types of compilers.
An algorithm is a set of steps to solve a problem. Algorithm efficiency describes how fast an algorithm solves problems of different sizes. Time complexity is the most important measure of efficiency, measuring the number of steps an algorithm takes based on the size of the input. Common techniques to analyze time complexity include calculating the number of operations in loops and recursions. Asymptotic notation like Big-O describes the long-term growth rate of an algorithm's running time as the input size increases.
This document provides an introduction to finite automata. It defines key concepts like alphabets, strings, languages, and finite state machines. It also describes the different types of automata, specifically deterministic finite automata (DFAs) and nondeterministic finite automata (NFAs). DFAs have a single transition between states for each input, while NFAs can have multiple transitions. NFAs are generally easier to construct than DFAs. The next class will focus on deterministic finite automata in more detail.
This document discusses hardware and software parallelism in computer systems. It defines hardware parallelism as parallelism enabled by the machine architecture through multiple processors or functional units. Software parallelism refers to parallelism exposed in a program's control and data dependencies. Modern computer architectures require support for both types of parallelism to perform multiple tasks simultaneously. However, there is often a mismatch between the hardware and software parallelism available. For example, a dual-processor system may be able to execute 12 instructions in 6 cycles, but the program's inherent parallelism may only allow completing the instructions in 7 cycles. Achieving optimal parallelism requires coordination between hardware design and software programming.
This document provides an overview of key concepts related to programming languages. It discusses the definition of a programming language and the history and evolution of popular languages from 1951 to present. It covers programming language paradigms like procedural, object-oriented, functional, and logic-based languages. It also discusses factors that influence language design like efficiency, regularity, and issues in language translation. Finally, it summarizes the structure and operation of computers and how different programming models map to underlying computer architectures.
Introduction, Macro Definition and Call, Macro Expansion, Nested Macro Calls, Advanced Macro Facilities, Design Of a Macro Preprocessor, Design of a Macro Assembler, Functions of a Macro Processor, Basic Tasks of a Macro Processor, Design Issues of Macro Processors, Features, Macro Processor Design Options, Two-Pass Macro Processors, One-Pass Macro Processors
Natural language processing (NLP) is introduced, including its definition, common steps like morphological analysis and syntactic analysis, and applications like information extraction and machine translation. Statistical NLP aims to perform statistical inference for NLP tasks. Real-world applications of NLP are discussed, such as automatic summarization, information retrieval, question answering and speech recognition. A demo of a free NLP application is presented at the end.
Very long instruction word or VLIW refers to a processor architecture designed to take advantage of instruction level parallelism
This type of processor architecture is intended to allow higher performance without the inherent complexity of some other approaches.
This document provides information about the CS416 Compiler Design course, including the instructor details, prerequisites, textbook, grading breakdown, course outline, and an overview of the major parts and phases of a compiler. The course will cover topics such as lexical analysis, syntax analysis using top-down and bottom-up parsing, semantic analysis using attribute grammars, intermediate code generation, code optimization, and code generation.
This lecture slide contains:
1. Regular Languages
2. Regular Operations
3. Closure of regular languages
4. Regular expression
5. Precedence of regular operations
6. RE for different languages
7. RE to NFA conversion
8. DFA to GNFA to RE conversion
The document discusses different approaches for concept learning from examples, including viewing it as a search problem to find the hypothesis that best fits the training examples. It also describes the general-to-specific learning approach, where the goal is to find the maximally specific hypothesis consistent with the positive training examples by starting with the most general hypothesis and replacing constraints to better fit the examples. The document also discusses the version space and candidate elimination algorithms for obtaining the version space of all hypotheses consistent with the training data.
This document contains information related to a Networks Laboratory course, including the lab manual, program objectives, outcomes, syllabus, and index. It provides:
1) An overview of the course contents, objectives to learn network commands, socket programming, analyze protocols, and use simulation tools.
2) Details on the program outcomes which focus on applying technical knowledge, lifelong learning, research, and total quality education.
3) A list of 12 experiments that will be conducted in the lab, including implementing various protocols using sockets and simulating protocols using a network simulator.
4) An index table to record details of experiments conducted like date, topic, outcomes and marks.
The document provides an introduction and overview of the COIT29222 Structured Programming course, including information about the textbook, assessments, topics to be covered, and a simple C++ program example. Students are instructed to contact their local lecturer/tutor if they have any problems or questions. Plagiarism is strictly prohibited and assignments must follow a five-step software development process using pseudocode to design programs that will be written and tested in C++, compiling the code using Visual C++.
IP Lab Manual for Kerala University 3 Year UG ProgrammeSAFAD ISMAIL
This document provides a lab manual for programming in C language. It contains the syllabus, objectives, outcomes and details of various experiments to be performed in the lab. The syllabus is divided into two parts - the first part covers basic C programming concepts like data types, operators, control structures etc. through 15 experiments. The second part deals with arrays, pointers, structures, files, functions etc. through various other experiments. It also provides information on setting up the programming environment in Linux using GCC compiler or Turbo C/C++ in Windows and the basic structure of a C program. The objectives are to introduce programming fundamentals and impart writing skills in C. The outcomes include understanding programming logic, writing algorithms, using data structures
This course teaches students to program ARM Cortex M3 microcontrollers in assembly language. Students will learn to interface external devices and I/O with the ARM microcontroller. The course outcomes include being able to develop assembly language programs for different applications and embedded systems. Students will complete labs programming the ARM for tasks like binary operations, displaying messages, and interfacing devices like motors and analog-digital converters. Assessment includes quizzes, exams, homework, and lab work evaluations.
The document discusses the syllabus and objectives for the subject CS6660 - Compiler Design. It outlines 5 units that will be covered: introduction to compilers, lexical analysis, syntax analysis, syntax directed translation and runtime environment, and code optimization and code generation. Each unit defines the concepts and techniques that will be learned. The objectives are for students to understand compiler design principles, parsing techniques, different translation levels, and how to optimize code generation.
CS8461 - Operating System Laboratory Manual prepared for the Engineering graduates admitted under 2017 Regulations, Anna University affiliated institutions of TamilNadu,India
Recent Trends in Translation of Programming Languages using NLP ApproachesIRJET Journal
This document discusses recent approaches to translating programming languages like Java, C, and C++ to Python using natural language processing techniques. It first reviews related work on language translation using various models like statistical machine translation, sequence-to-sequence networks, and tree-based neural networks. It then outlines the motivation for automated language translation in cases where a developer needs to implement Python code without changing the functionality of code originally written in another language. The document concludes by discussing the limitations of existing translation methods and the need for continued research to handle more complex language constructs during the translation process.
vtu data structures lab manual bcs304 pdfLPSChandana
The document contains a preface and index for a lab manual on data structures. It discusses how C programming offers facilities to group data into convenient packages called data structures. The preface emphasizes abstract concepts of data structures and how they are useful for problem solving using structures like queues, arrays, linked lists, stacks, trees and graphs. The index lists 11 programs to be developed related to various data structure operations and applications including strings, stacks, queues, linked lists, polynomials and more.
This document provides an overview of dictionaries and structuring data in Python. It discusses key-value pairs, creating and initializing dictionaries, accessing and modifying dictionary elements, dictionary methods, use cases for dictionaries, other Python data structures like lists and tuples, combining data structures, best practices, and concludes by emphasizing the importance of dictionaries and structured data in Python code.
Lecture 3.2.4 C pointer to Structure.pptxravi2692kumar
Enabling immediate and 24/7 communication
Automating communication
Overcoming geographical barriers
Enabling more effective and real-time collaboration
Increasing transparency
Decentralizing decision making
Agar, J., 2003. Constant Touch: A Global History of the Mobile Phone. Cambridge: Icon Books.
Barry, W., 1999. Networks in the Global Village. Boulder Colo: Westview Press.
Caron, A, & Caronia, L., 2007. Moving cultures: mobile communication in everyday life. Montreal: McGill-Queen’s University Press.
Castells, M., 1996. The Information Age: Economy, Society and Culture, Volume 1.The Rise of the Network Society. Oxford: Blackwell.
Daniel, C., & Rod, M., 2011.The Dictionary of Media and Communications. Oxford: Oxford University Press.
Many of the business processes today involve communications like messaging/chatbots, email marketing, and social media engagement to reach out to the target customers. The growth and widespread adoption of social media platforms, video conferencing tools and emailing platforms have made virtual communication a new normal in the COVID reign
Postman, N., 1992. Technopoly: The surrender of culture to technology. New York: Vintage Books.
Reid, D. J. & Reid F. J. M., 2004. Insights into the Social and Psychological Effects of SMS Text Messaging. Web.
Richard, L., 2004. The Mobile Connection: The Cell Phone’s Impact on Society. San Francisco Morgan: Kaufmann.
Soukup, C., 2008. ‘Magic Screens: Everyday Life in an Era of Ubiquitous and Mobile Media Screens’, presented at 94th annual Convention. San Diego.
Stephen, J., 1997. Interface Culture: How New Technology Transforms the Way We Create and Communicate. San Francisco: Basic Books.
Tofts, D., 1997. ‘The technology within’ in memory trade: A Prehistory of Cyberculture, North Ryde: 21C Books.
This document contains a collection of C programs with solutions to demonstrate programming concepts. It includes programs to find the sum of two numbers, programs to find the area and circumference of a circle, and other basic programs. The document is intended to help students learn C programming concepts through examples. It covers topics like input/output, variables, data types, operators, decision making statements, loops, functions, arrays and strings. The programs are arranged from basic to more advanced concepts to help students build their skills step-by-step.
This document discusses the C programming language and data structures. It covers the basic structure of C programs, including functions, main functions, and sections like documentation, definitions, declarations, and subprograms. It also discusses basic C programs, data types, operators, control structures, arrays, pointers, structures, unions, and file I/O. The document is intended to introduce students to C language concepts and data structures.
C programing for BCA Sem 1. JJ CollegeMUNNAKUMAR89
This document provides an overview of the C programming language. It discusses the structure of C programs, which includes header files, global declarations, the main function, declaration and executable parts, and user-defined functions. It also describes the steps to execute a C program, the C character set, delimiters, keywords, identifiers, constants, variables, and data types in C. The goal is to introduce fundamental C concepts to help readers understand how to write C programs.
This C program allows the user to input two numbers, calculates their sum, and displays the result. It includes header files, declares variables to store the input numbers and sum, uses scanf to input the numbers, calculates the sum, and prints the output using printf.
This document outlines the objectives and topics covered in the course EC8393 - Fundamentals of Data Structures in C. The course aims to teach students about linear and non-linear data structures and their applications using the C programming language. Key topics include implementing various data structure operations in C, choosing appropriate data structures, and modifying existing or designing new data structures for applications. Assessment includes continuous internal assessments, a university exam, and a minimum 80% attendance requirement.
IRJET - Pseudocode to Python Translation using Machine LearningIRJET Journal
This document describes a system that translates pseudocode written in natural language into executable Python code. It uses recurrent neural networks with sequence-to-sequence translation to first convert the pseudocode into an intermediate XML representation, and then recursively parses that XML to produce the final Python code. The system aims to help students learn programming by allowing them to test algorithms written in pseudocode. It was implemented using Keras and trained on a dataset containing pseudocode statements and their Python translations.
The document discusses the C programming language and data structures. It covers the basic structure of C programs, data types, operators, control flow statements, arrays, strings, functions, pointers, structures, unions and file I/O. The chapters are outlined and key concepts like algorithms, flowcharts and program development steps are explained in detail. The history and evolution of C language is presented along with its features, applications and importance. A simple C program example is also provided and analyzed.
The document provides an introduction to C programming. It outlines the course objectives which are to familiarize students with structured programming concepts in C and help students differentiate between various programming structures. It also lists recommended textbooks. The document then discusses what C programming is, its applications like operating systems and databases. It summarizes that C was created in 1972 at Bell Labs and became a standard in 1989. It describes the structure of a basic C program which includes documentation, header files, definitions, global declarations, the main function and subprograms. Finally, it provides a sample program to calculate the area of a circle using functions.
Notes of c programming 1st unit BCA I SEMMansi Tyagi
This document discusses the basics of the C programming language. It covers the structure of a basic C program, which must include a main function with declaration and executable parts. C tokens like keywords, identifiers, constants, operators and strings are also introduced. The document then discusses C program development steps like understanding the problem, planning input/output, designing an algorithm, coding, testing and debugging. It provides a high-level overview of the C language and programming in C.
A Project Based Lab Report On AMUZING JOKEDaniel Wachtel
The document describes a project report on checking if letters from two names can be rearranged to form the original names. It begins with contact information for the students and supervisor. It then includes a certificate confirming the project work, acknowledgements, an abstract describing the hashing algorithm used, and an index of sections. It discusses the aims, advantages and disadvantages of the project. It provides a data flow diagram and algorithms for each module. It also describes the software, hardware, implementation, integration and system testing done for the project. The conclusion summarizes that the program checks if letters can be rearranged to form the original names using arrays and by hashing letters based on their ASCII values.
Physiology and chemistry of skin and pigmentation, hairs, scalp, lips and nail, Cleansing cream, Lotions, Face powders, Face packs, Lipsticks, Bath products, soaps and baby product,
Preparation and standardization of the following : Tonic, Bleaches, Dentifrices and Mouth washes & Tooth Pastes, Cosmetics for Nails.
This presentation includes basic of PCOS their pathology and treatment and also Ayurveda correlation of PCOS and Ayurvedic line of treatment mentioned in classics.
हिंदी वर्णमाला पीपीटी, hindi alphabet PPT presentation, hindi varnamala PPT, Hindi Varnamala pdf, हिंदी स्वर, हिंदी व्यंजन, sikhiye hindi varnmala, dr. mulla adam ali, hindi language and literature, hindi alphabet with drawing, hindi alphabet pdf, hindi varnamala for childrens, hindi language, hindi varnamala practice for kids, https://www.drmullaadamali.com
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
How to Manage Your Lost Opportunities in Odoo 17 CRMCeline George
Odoo 17 CRM allows us to track why we lose sales opportunities with "Lost Reasons." This helps analyze our sales process and identify areas for improvement. Here's how to configure lost reasons in Odoo 17 CRM
How to Build a Module in Odoo 17 Using the Scaffold MethodCeline George
Odoo provides an option for creating a module by using a single line command. By using this command the user can make a whole structure of a module. It is very easy for a beginner to make a module. There is no need to make each file manually. This slide will show how to create a module using the scaffold method.
বাংলাদেশের অর্থনৈতিক সমীক্ষা ২০২৪ [Bangladesh Economic Review 2024 Bangla.pdf] কম্পিউটার , ট্যাব ও স্মার্ট ফোন ভার্সন সহ সম্পূর্ণ বাংলা ই-বুক বা pdf বই " সুচিপত্র ...বুকমার্ক মেনু 🔖 ও হাইপার লিংক মেনু 📝👆 যুক্ত ..
আমাদের সবার জন্য খুব খুব গুরুত্বপূর্ণ একটি বই ..বিসিএস, ব্যাংক, ইউনিভার্সিটি ভর্তি ও যে কোন প্রতিযোগিতা মূলক পরীক্ষার জন্য এর খুব ইম্পরট্যান্ট একটি বিষয় ...তাছাড়া বাংলাদেশের সাম্প্রতিক যে কোন ডাটা বা তথ্য এই বইতে পাবেন ...
তাই একজন নাগরিক হিসাবে এই তথ্য গুলো আপনার জানা প্রয়োজন ...।
বিসিএস ও ব্যাংক এর লিখিত পরীক্ষা ...+এছাড়া মাধ্যমিক ও উচ্চমাধ্যমিকের স্টুডেন্টদের জন্য অনেক কাজে আসবে ...
A review of the growth of the Israel Genealogy Research Association Database Collection for the last 12 months. Our collection is now passed the 3 million mark and still growing. See which archives have contributed the most. See the different types of records we have, and which years have had records added. You can also see what we have for the future.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
This slide is special for master students (MIBS & MIFB) in UUM. Also useful for readers who are interested in the topic of contemporary Islamic banking.
Assessment and Planning in Educational technology.pptxKavitha Krishnan
In an education system, it is understood that assessment is only for the students, but on the other hand, the Assessment of teachers is also an important aspect of the education system that ensures teachers are providing high-quality instruction to students. The assessment process can be used to provide feedback and support for professional development, to inform decisions about teacher retention or promotion, or to evaluate teacher effectiveness for accountability purposes.
Thinking of getting a dog? Be aware that breeds like Pit Bulls, Rottweilers, and German Shepherds can be loyal and dangerous. Proper training and socialization are crucial to preventing aggressive behaviors. Ensure safety by understanding their needs and always supervising interactions. Stay safe, and enjoy your furry friends!
1. COMPILER DESIGN
LAB MANUAL
Subject Code: A50587
Regulations: R13 – JNTUH
Class: III Year I Semester (CSE)
Prepared By
Ms. E Uma Shankari
Assistant Professor, CSE
Ms. G Geetha
Assistant Professor, CSE
Department of Computer Science & Engineering
INSTITUTE OF AERONAUTICAL ENGINEERING
Dundigal – 500 043, Hyderabad
2. INSTITUTE OF AERONAUTICAL ENGINEERING
Dundigal, Hyderabad - 500 043
COMPUTER SCIENCE AND ENGINEERING
Program Outcomes
PO1 Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals,
and an engineering specialization to the solution of complex engineering problems.
PO2 Problem analysis: Identify, formulate, review research literature, and analyze complex engineering
problems reaching substantiated conclusions using first principles of mathematics, natural sciences,
and engineering sciences.
PO3 Design/development of solutions: Design solutions for complex engineering problems and design
system components or processes that meet the specified needs with appropriate consideration for
the public health and safety, and the cultural, societal, and environmental considerations.
PO4 Conduct investigations of complex problems: Use research-based knowledge and research methods
including design of experiments, analysis and interpretation of data, and synthesis of the information
to provide valid conclusions.
PO5 Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities with an
understanding of the limitations.
PO6 The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal,
health, safety, legal and cultural issues and the consequent responsibilities relevant to the
professional engineering practice.
PO7 Environment and sustainability: Understand the impact of the professional engineering solutions in
societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable
development.
PO8 Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of
the engineering practice.
PO9 Individual and team work: Function effectively as an individual, and as a member or leader in diverse
teams, and in multidisciplinary settings.
PO10 Communication: Communicate effectively on complex engineering activities with the engineering
community and with society at large, such as, being able to comprehend and write effective reports
and design documentation, make effective presentations, and give and receive clear instructions.
PO11 Project management and finance: Demonstrate knowledge and understanding of the engineering
and management principles and apply these to one’s own work, as a member and leader in a team, to
manage projects and in multidisciplinary environments.
PO12 Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change.
Program Specific Outcomes
PSO1 Professional Skills: The ability to research, understand and implement computer programs in the
areas related to algorithms, system software, multimedia, web design, big data analytics, and
networking for efficient analysis and design of computer-based systems of varying complexity.
PSO2 Problem-Solving Skills: The ability to apply standard practices and strategies in software project
development using open-ended programming environments to deliver a quality product for business
success.
PSO3 Successful Career and Entrepreneurship: The ability to employ modern computer languages,
environments, and platforms in creating innovative career paths, to be an entrepreneur, and a zest
for higher studies.
3. COMPILER DESIGN LAB SYLLABUS
Sl. No. List of Experiments Page No.
1 Design a lexical analyzer for given language and the lexical analyzer should ignore
redundant spaces, tabs and new lines. It should also ignore comments. Although the
syntax specification states that identifiers can be arbitrarily long, you may restrict the
length to some reasonable value. Simulate the same in C language.
1
2
* Write a C program to identify whether a given line is a comment or not. 4
3
*Write a C program to recognize strings under 'a', 'a*b+', 'abb'. 5
4
*Write a C program to test whether a given identifier is valid or not. 8
5
*Write a C program to simulate lexical analyzer for validating operators. 9
6 Implement the lexical analyzer using JLex, flex or other lexical analyzer generating
tools.
11
7 Write a C program for implementing the functionalities of predictive parser for the mini
language specified in Note 1.
13
8 a) *Write a C program for constructing of LL (1) parsing.
b) *Write a C program for constructing recursive descent parsing.
17
9
Write a C program to implement LALR parsing. 24
10 a) *Write a C program to implement operator precedence parsing.
b) *Write a C program to implement Program semantic rules to calculate the
expression that takes an expression with digits, + and * and computes the value.
32
11 Convert the BNF rules into Yacc form and write code to generate abstract syntax tree
for the mini language specified in Note 1.
39
12 Write a C program to generate machine code from abstract syntax tree generated by the
parser. The instruction set specified in Note 2 may be considered as the target code.
44
*Content beyond the University prescribed syllabi
4. Note 1:
A simple language written in this language is
{int a[3],t1,t2;
T1=2;
A[0]=1;a[1]=2;a[t]=3;
T2=-( a[2]+t1*6)/(a[2]-t1);
If t2>5then
Print(t2)
Else{
Int t3;
T3=99;
T2=25;
Print(-t1+t2*t3);/*this is a comment on 2 lines*/
}endif
}
Comments(zero or more characters enclosed between the standard C/JAVA Style comment brackets/*…*/)can be
inserted .The language has rudimentary support for1-dimenstional array,the declaration int a[3] declares an array of
three elements,referenced as a[0],a[1] and a[2].Note also you should worry about the scopping of names.
Note 2:
Consider the following mini language, a simple procedural high –level language, only operating on integer data, with a
syntax looking vaguely like a simple C crossed with pascal. The syntax of the language is defined by the following
grammar.
<program>::=<block>
<block>::={<variable definition><slist>}
|{<slist>}
<variabledefinition>::=int <vardeflist>
<vardec>::=<identifier>|<identifier>[<constant>]
<slist>::=<statement>|<statement>;<slist>
<statement>::=<assignment>|<ifstament>|<whilestatement>
|<block>|<printstament>|<empty>
<assignment>::=<identifier>=<expression>
|<identifier>[<expression>]=<expression>
<if statement>::=if<bexpression>then<slist>else<slist>endif
|if<bexpression>then<slisi>endif
<whilestatement>::=while<bexpreession>do<slisi>enddo
<printstatement>:;=print(<expression>)
<expression>::=<expression>::=<expression><addingop><term>|<term>|<addingop>
<term>
<bexprssion>::=<expression><relop><expression>
<relop>::=<|<=|==|>=|>|!=
<addingop>::=+|-
<term>::=<term><multop><factor>|<factor>
<Multop>::=*|/
<factor>::=<constant>|<identifier>|<identifier>[<expression>]
|(<expression>)
<constant>::=<digit>|<digit><constant>
6. ATTAINMENT OF PROGRAM OUTCOMES
& PROGRAM SPECIFIC OUTCOMES
Exp.
No.
Experiment
Program
Outcomes
Attained
Program
Specific
Outcomes
Attained
1 Design a lexical analyzer for given language and the lexical analyzer
should ignore redundant spaces, tabs and new lines. It should also
ignore comments. Although the syntax specification states that
identifiers can be arbitrarily long, you may restrict the length to some
reasonable value. Simulate the same in C language.
PO1, PO2, PO3
PSO1
2 * Write a C program to identify whether a given line is a comment or
not.
PO1 PSO1
3
*Write a C program to recognize strings under 'a', 'a*b+', 'abb'. PO1, PO2 PSO1, PSO2
4
*Write a C program to test whether a given identifier is valid or not. PO1 PSO1
5 *Write a C program to simulate lexical analyzer for validating
operators.
PO1, PO2, PO3 PSO1, PSO2
6 Implement the lexical analyzer using JLex, flex or other lexical
analyzer generating tools.
PO1, PO2 PSO1
7 Write a C program for implementing the functionalities of predictive
parser for the mini language specified in Note 1.
PO1, PO2, PO4,
PO5
PSO1
8 a) *Write a C program for constructing of LL (1) parsing.
b) *Write a C program for constructing recursive descent parsing.
PO1, PO2, PO3,
PO4
PSO1, PSO2
9
Write a C program to implement LALR parsing. PO1, PO2, PO4 PSO1
10 a) *Write a C program to implement operator precedence parsing.
b) *Write a C program to implement Program semantic rules to
calculate the expression that takes an expression with digits, +
and * and computes the value.
PO1, PO2 PSO1, PSO2
11 Convert the BNF rules into Yacc form and write code to generate
abstract syntax tree for the mini language specified in Note 1.
PO1, PO2 PSO1
12 Write a C program to generate machine code from abstract syntax tree
generated by the parser. The instruction set specified in Note 2 may be
considered as the target code.
PO1, PO2, PO3,
PO4, PO5
PSO1
*Content beyond the University prescribed syllabi
7. COMPILER DESIGN LABORATORY
OBJECTIVE:
This laboratory course is intended to make the students experiment on the basic techniques of compiler
construction and tools that can used to perform syntax-directed translation of a high-level programming
language into an executable code. Students will design and implement language processors in C by using
tools to automate parts of the implementation process. This will provide deeper insights into the more
advanced semantics aspects of programming languages, code generation, machine independent
optimizations, dynamic memory allocation, and object orientation.
OUTCOMES:
Upon the completion of Compiler Design practical course, the student will be able to:
1. Understand the working of lex and yacc compiler for debugging of programs.
2. Understand and define the role of lexical analyzer, use of regular expression and transition
diagrams.
3. Understand and use Context free grammar, and parse tree construction.
4. Learn & use the new tools and technologies used for designing a compiler.
5. Develop program for solving parser problems.
6. Learn how to write programs that execute faster.
8. 1
EXPERIMENT- 1
1.1 OBJECTIVE:
Design a lexical analyzer for given language and the lexical analyzer should ignore redundant spaces, tabs and
new lines. It should also ignore comments. Although the syntax specification states that identifiers can be
arbitrarily long, you may restrict the length to some reasonable value. Simulate the same in C language.
1.2 RESOURCE:
Turbo C ++
1.3 PROGRAM LOGIC:
1. Read the input Expression
2. Check whether input is alphabet or digits then store it as identifier
3. If the input is is operator store it as symbol
4. Check the input for keywords
1.4 PROCEDURE:
Go to debug -> run or press CTRL + F9 to run the program
1.5 PROGRAM:
#include<string.h>
#include<ctype.h>
#include<stdio.h>
void keyword(char str[10])
{
if(strcmp("for",str)==0||strcmp("while",str)==0||strcmp("do",str)==0||strcmp("int",str)==0||str
cmp("float",str)==0||strcmp("char",str)==0||strcmp("double",str)==0||strcmp("static",str)==0||strcmp("switch",str
)==0||strcmp("case",str)==0)
printf("n%s is a keyword",str);
else
printf("n%s is an identifier",str);
}
main()
{
FILE *f1,*f2,*f3;
char c,str[10],st1[10];
int num[100],lineno=0,tokenvalue=0,i=0,j=0,k=0;
printf("nEnter the c program");/*gets(st1);*/
f1=fopen("input","w");
while((c=getchar())!=EOF)
putc(c,f1);
fclose(f1);
f1=fopen("input","r");
f2=fopen("identifier","w");
f3=fopen("specialchar","w");
while((c=getc(f1))!=EOF) {
if(isdigit(c))
{
tokenvalue=c-'0';
10. 3
}
fclose(f2);
f3=fopen("specialchar","r");
printf("nSpecial characters are");
while((c=getc(f3))!=EOF)
printf("%c",c);
printf("n");
fclose(f3);
printf("Total no. of lines are:%d",lineno);
}
1.6 PRE LAB QUESTIONS
1. What is token?
2. What is lexeme?
3. What is the difference between token and lexeme?
4. Define phase and pass?
5. What is the difference between phase and pass?
6. What is the difference between compiler and interpreter?
1.7 LAB ASSIGNMENT
1. Write a program to recognize identifiers.
2. Write a program to recognize constants.
3. Write a program to recognize keywords and identifiers.
4. Write a program to ignore the comments in the given input source program.
1.8 POST LAB QUESTIONS
1. What is lexical analyzer?
2. Which compiler is used for lexical analyzer?
3. What is the output of Lexical analyzer?
4. What is LEX source Program?
1.9 INPUT & OUTPUT:
Input:
Enter Program $ for termination:
{
int a[3],t1,t2;
t1=2; a[0]=1; a[1]=2; a[t1]=3;
t2=-(a[2]+t1*6)/(a[2]-t1);
if t2>5 then
print(t2);
else {
int t3;
t3=99;
t2=-25;
print(-t1+t2*t3); /* this is a comment on 2 lines */
} endif
}
$
Output:
Variables : a[3] t1 t2 t3
Operator : - + * / >
Constants : 2 1 3 6 5 99 -25
Keywords : int if then else endif
Special Symbols : , ; ( ) { }
Comments : this is a comment on 2 lines
11. 4
EXPERIMENT-2
2.1 OBJECTIVE:
* Write a C program to identify whether a given line is a comment or not.
2.2 RESOURCE:
Turbo C++
2.3 PROGRAM LOGIC:
Read the input string.
Check whether the string is starting with ‘/’ and check next character is ‘/’ or’*’.
If condition satisfies print comment.
Else not a comment.
2.4 PROCEDURE:
Go to debug -> run or press CTRL + F9 to run the program.
2.5 PROGRAM:
#include<stdio.h>
#include<conio.h>
void main() {
char com[30];
int i=2,a=0;
clrscr();
printf("n Enter comment:");
gets(com);
if(com[0]=='/') {
if(com[1]=='/')
printf("n It is a comment");
else if(com[1]=='*') {
for(i=2;i<=30;i++)
{
if(com[i]=='*'&&com[i+1]=='/')
{
printf("n It is a comment");
a=1;
break; }
else
continue; }
if(a==0)
printf("n It is not a comment");
}
else
printf("n It is not a comment");
}
else
printf("n It is not a comment");
getch(); }
2.6 INPUT & OUTPUT:
Input: Enter comment: //hello
Output: It is a comment
Input: Enter comment: hello
Output: It is not a comment
12. 5
EXPERIMENT-3
3.1 OBJECTIVE:
*Write a C program to recognize strings under 'a*', 'a*b+', 'abb'.
3.2 RESOURCE:
Turbo C++
3.3 PROGRAM LOGIC:
By using transition diagram we verify input of the state.
If the state recognize the given pattern rule.
Then print string is accepted under a*/ a*b+/ abb.
Else print string not accepted.
3.4 PROCEDURE:
Go to debug -> run or press CTRL + F9 to run the program.
3.5 PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
void main()
{
char s[20],c;
int state=0,i=0;
clrscr();
printf("n Enter a string:");
gets(s);
while(s[i]!='0')
{
switch(state)
{
case 0: c=s[i++];
if(c=='a')
state=1;
else if(c=='b')
state=2;
else
state=6;
break;
case 1: c=s[i++];
if(c=='a')
state=3;
13. 6
else if(c=='b')
state=4;
else
state=6;
break;
case 2: c=s[i++];
if(c=='a')
state=6;
else if(c=='b')
state=2;
else
state=6;
break;
case 3: c=s[i++];
if(c=='a')
state=3;
else if(c=='b')
state=2;
else
state=6;
break;
case 4: c=s[i++];
if(c=='a')
state=6;
else if(c=='b')
state=5;
else
state=6;
break;
case 5: c=s[i++];
if(c=='a')
state=6;
else if(c=='b')
state=2;
else
state=6;
break;
case 6: printf("n %s is not recognised.",s);
exit(0);
}
}
14. 7
I f(state==1)
printf("n %s is accepted under rule 'a'",s);
else if((state==2)||(state==4))
printf("n %s is accepted under rule 'a*b+'",s);
else if(state==5)
printf("n %s is accepted under rule 'abb'",s);
getch();
}
3.6 INPUT & OUTPUT:
Input :
Enter a String: aaaabbbbb
Output:
aaaabbbbb is accepted under rule 'a*b+'
Enter a string: cdgs
cdgs is not recognized
15. 8
EXPERIMENT-4
4.1 OBJECTIVE:
*Write a C program to test whether a given identifier is valid or not
4.2 RESOURCE:
Turbo C++
4.3 PROGRAM LOGIC:
Read the given input string.
Check the initial character of the string is numerical or any special character except ‘_’ then print it is not a valid
identifier.
Otherwise print it as valid identifier if remaining characters of string doesn’t contains any special characters
except ‘_’.
4.4 PROCEDURE:
Go to debug -> run or press CTRL + F9 to run the program.
4.5 PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
void main()
{
char a[10];
int flag, i=1;
clrscr();
printf("n Enter an identifier:");
gets(a);
if(isalpha(a[0]))
flag=1;
else
printf("n Not a valid identifier");
while(a[i]!='0')
{
if(!isdigit(a[i])&&!isalpha(a[i]))
{
flag=0;
break;
}
i++;
}
if(flag==1)
printf("n Valid identifier");
getch();
}
4.6 INPUT & OUTPUT:
Input: Enter an identifier: first
Output:
Valid identifier
Enter an identifier:1aqw
Not a valid identifier
16. 9
EXPERIMENT-5
5.1 OBJECTIVE:
*Write a C program to simulate lexical analyzer for validating operators.
5.2 RESOURCE:
Turbo C++
5.3 PROGRAM LOGIC :
Read the given input.
If the given input matches with any operator symbol.
Then display in terms of words of the particular symbol.
Else print not a operator.
5.4 PROCEDURE:
Go to debug -> run or press CTRL + F9 to run the program.
5.5 PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
char s[5];
clrscr();
printf("n Enter any operator:");
gets(s);
switch(s[0])
{
case'>': if(s[1]=='=')
printf("n Greater than or equal");
else
printf("n Greater than");
break;
case'<': if(s[1]=='=')
printf("n Less than or equal");
else
printf("nLess than");
break;
case'=': if(s[1]=='=')
printf("nEqual to");
else
printf("nAssignment");
break;
case'!': if(s[1]=='=')
printf("nNot Equal");
else
printf("n Bit Not");
break;
case'&': if(s[1]=='&')
printf("nLogical AND");
else
printf("n Bitwise AND");
break;
case'|': if(s[1]=='|')
printf("nLogical OR");
18. 11
EXPERIMENT-6
6.1 OBJECTIVE:
Implement the lexical analyzer using JLex, flex or other lexical analyzer generating tools.
6.2 RESOURCE:
Linux using Putty
6.3 PROGRAM LOGIC:
Read the input string.
Check whether the string is identifier/ keyword /symbol by using the rules of identifier and keywords using
LEX Tool
6.4 PROCEDURE:
Go to terminal .Open vi editor ,Lex lex.l , cc lex.yy.c , ./a.out
6.5 PROGRAM:
/* program name is lexp.l */
%{
/* program to recognize a c program */
int COMMENT=0;
%}
identifier [a-zA-Z][a-zA-Z0-9]*
%%
#.* { printf("n%s is a PREPROCESSOR DIRECTIVE",yytext);}
int |float |char |double |while |for |do |if |break |continue |void |switch |case |long |struct |const |typedef |return
|else |goto {printf("nt%s is a KEYWORD",yytext);}
"/*" {COMMENT = 1;}
/*{printf("nnt%s is a COMMENTn",yytext);}*/
"*/" {COMMENT = 0;}
/* printf("nnt%s is a COMMENTn",yytext);}*/
{identifier}( {if(!COMMENT)printf("nnFUNCTIONnt%s",yytext);}
{ {if(!COMMENT) printf("n BLOCK BEGINS");}
} {if(!COMMENT) printf("n BLOCK ENDS");}
{identifier}([[0-9]*])? {if(!COMMENT) printf("n %s IDENTIFIER",yytext);}
".*" {if(!COMMENT) printf("nt%s is a STRING",yytext);}
[0-9]+ {if(!COMMENT) printf("nt%s is a NUMBER",yytext);}
{if(!COMMENT) printf("nt");ECHO;printf("n");}
( ECHO;
{if(!COMMENT)printf("nt%s is an ASSIGNMENT OPERATOR",yytext);}
<= |>= |< |== |> {if(!COMMENT) printf("nt%s is a RELATIONAL OPERATOR",yytext);}
%%
int main(int argc,char **argv)
{
if (argc > 1)
{
FILE *file;
file = fopen(argv[1],"r");
if(!file)
{
printf("could not open %s n",argv[1]);
exit(0);
}
yyin = file;
}
yylex();
19. 12
printf("nn");
return 0;
} int yywrap()
{
return 0;
}
6.6 PRE LAB QUESTIONS:
1. List the different sections available in LEX compiler?
2. What is an auxiliary definition?
3. How can we define the translation rules?
4. What is regular expression?
5. What is finite automaton?
6.7 LAB ASSIGNMENT:
1. Write a program that defines auxiliary definitions and translation rules of Pascal tokens?
2. Write a program that defines auxiliary definitions and translation rules of C tokens?
3. Write a program that defines auxiliary definitions and translation rules of JAVA tokens
6.8 POST LAB QUESTIONS:
1. What is Jlex?
2. What is Flex?
3. What is lexical analyzer generator?
4. What is the input for LEX Compiler?
5. What is the output of LEX compiler?
6.6 INPUT & OUTPUT:
Input
$vi var.c
#include<stdio.h>
main()
{
int a,b;
}
Output
$lex lex.l
$cc lex.yy.c
$./a.out var.c
#include<stdio.h> is a PREPROCESSOR DIRECTIVE
FUNCTION
main (
)
BLOCK BEGINS
int is a KEYWORD
a IDENTIFIER
b IDENTIFIER
BLOCK ENDS
20. 13
EXPERIMENT-7
7.1 OBJECTIVE:
Write a C program for implementing the functionalities of predictive parser for the mini language specified in
Note 1.
7.2 RESOURCE:
Turbo C++
7.3 PROGRAM LOGIC:
Read the input string.
By using the FIRST AND FOLLOW values.
Verify the FIRST of non terminal and insert the production in the FIRST value
If we have any @ terms in FIRST then insert the productions in FOLLOW values
Constructing the predictive parser table
7.4 PROCEDURE:
Go to debug -> run or press CTRL + F9 to run the program.
7.5 PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<string.h>
char prol[7][10]={"S","A","A","B","B","C","C"};
char pror[7][10]={"A","Bb","Cd","aB","@","Cc","@"};
char prod[7][10]={"S->A","A->Bb","A->Cd","B->aB","B->@","C->Cc","C->@"};
char first[7][10]={"abcd","ab","cd","a@","@","c@","@"};
char follow[7][10]={"$","$","$","a$","b$","c$","d$"};
char table[5][6][10];
numr(char c)
{
switch(c)
{
case 'S': return 0;
case 'A': return 1;
case 'B': return 2;
case 'C': return 3;
case 'a': return 0;
case 'b': return 1;
case 'c': return 2;
case 'd': return 3;
case '$': return 4;
}
21. 14
return(2);
}
void main()
{
int i,j,k;
clrscr();
for(i=0;i<5;i++)
for(j=0;j<6;j++)
strcpy(table[i][j]," ");
printf("nThe following is the predictive parsing table for the following grammar:n");
for(i=0;i<7;i++)
printf("%sn",prod[i]);
printf("nPredictive parsing table isn");
fflush(stdin);
for(i=0;i<7;i++)
{
k=strlen(first[i]);
for(j=0;j<10;j++)
if(first[i][j]!='@')
strcpy(table[numr(prol[i][0])+1][numr(first[i][j])+1],prod[i]);
}
for(i=0;i<7;i++)
{
if(strlen(pror[i])==1)
{
if(pror[i][0]=='@')
{
k=strlen(follow[i]);
for(j=0;j<k;j++)
strcpy(table[numr(prol[i][0])+1][numr(follow[i][j])+1],prod[i]);
23. 16
7.7 LAB ASSIGNMENT:
1. Write a program to compute FIRST for the following grammar?
E TE'
E'+TE'/î
TFT’
T'*FT'/î
F(E)/i
2. Write a program to compute FIRST for the following grammar?
SiCtSS’
S’eS/ î
3. Write a program to construct predictive parsing table for the following grammar?
SiCtSS’
S’eS/ î
7.8 POST LAB QUESTIONS
1. What is Predictive parser?
2. How many types of analysis can we do using Parser?
3. What is Recursive Decent Parser?
4. How many types of Parsers are there?
5. What is LR Parser?
7.9 INPUT & OUTPUT:
The following is the predictive parsing table for the following grammar:
S->A
A->Bb
A->Cd
B->aB
B->@
C->Cc
C->@
Predictive parsing table is
------------------------------------------------------------------
a b c d $
------------------------------------------------------------------
S S->A S->A S->A S->A
------------------------------------------------------------------
A A->Bb A->Bb A->Cd A->Cd
------------------------------------------------------------------
B B->aB B->@ B->@ B->@
------------------------------------------------------------------
C C->@ C->@ C->@
------------------------------------------------------------------
24. 17
EXPERIMENT-8(a)
8.1 OBJECTIVE:
*Write a C program for constructing of LL (1) parsing.
8.2 RESOURCE:
Turbo C++
8.3 PROGRAM LOGIC:
Read the input string.
Using predictive parsing table parse the given input using stack .
If stack [i] matches with token input string pop the token else shift it repeat the process until it reaches to $.
8.4 PROCEDURE:
Go to debug -> run or press CTRL + F9 to run the program.
8.5 PROGRAM
#include<stdio.h>
#include<conio.h>
#include<string.h>
char s[20],stack[20];
void main()
{
char m[5][6][3]={"tb"," "," ","tb"," "," "," ","+tb"," "," ","n","n","fc"," "," ","fc"," "," "," ","n","*fc"," a
","n","n","i"," "," ","(e)"," "," "};
int size[5][6]={2,0,0,2,0,0,0,3,0,0,1,1,2,0,0,2,0,0,0,1,3,0,1,1,1,0,0,3,0,0};
int i,j,k,n,str1,str2;
clrscr();
printf("n Enter the input string: ");
scanf("%s",s);
strcat(s,"$");
n=strlen(s);
stack[0]='$';
stack[1]='e';
i=1;
j=0;
printf("nStack Inputn");
printf("__________________n");
while((stack[i]!='$')&&(s[j]!='$'))
{
if(stack[i]==s[j])
{
i--;
j++;
25. 18
}
switch(stack[i])
{
case 'e': str1=0;
break;
case 'b': str1=1;
break;
case 't': str1=2;
break;
case 'c': str1=3;
break;
case 'f': str1=4;
break;
}
switch(s[j])
{
case 'i': str2=0;
break;
case '+': str2=1;
break;
case '*': str2=2;
break;
case '(': str2=3;
break;
case ')': str2=4;
break;
case '$': str2=5;
break;
}
if(m[str1][str2][0]=='0')
{
printf("nERROR");
exit(0);
}
else if(m[str1][str2][0]=='n')
i--;
else if(m[str1][str2][0]=='i')
27. 20
EXPERIMENT-8(b)
8.1 OBJECTIVE:
Construction of recursive descent parsing for the following grammar
E->TE'
E'->+TE/@ "@ represents null character"
T->FT'
T`->*FT'/@
F->(E)/ID
8.2 RESOURCE:
Turbo C++
8.3 PROGRAM LOGIC:
Read the input string.
Write procedures for the non terminals
Verify the next token equals to non terminals if it satisfies match the non terminal.
If the input string does not match print error.
8.4 PROCEDURE:
Go to debug -> run or press CTRL + F9 to run the program.
8.5 PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<string.h>
char input[100];
int i,l;
void main()
{
clrscr();
printf("nRecursive descent parsing for the following grammarn");
printf("nE->TE'nE'->+TE'/@nT->FT'nT'->*FT'/@nF->(E)/IDn");
printf("nEnter the string to be checked:");
gets(input);
if(E())
{
if(input[i+1]=='0')
printf("nString is accepted");
else
printf("nString is not accepted");
}
else
printf("nString not accepted");
30. 23
}
else
return(0);
}
8.6 INPUT & OUTPUT:
Recursive descent parsing for the following grammar
E->TE'
E'->+TE'/@
T->FT'
T'->*FT'/@
F->(E)/ID
Enter the string to be checked:(a+b)*c
String is accepted
Recursive descent parsing for the following grammar
E->TE'
E'->+TE'/@
T->FT'
T'->*FT'/@
F->(E)/ID
Enter the string to be checked:a/c+d
String is not accepted
31. 24
EXPERIMENT-9
9.1 OBJECTIVE:
Write a program to Design LALR Bottom up Parser.
9.2 RESOURCE:
TURBO C++
9.3 PROGRAM LOGIC:
Read the input string.
Push the input symbol with its state symbols in to the stack by referring lookaheads
We perform shift and reduce actions to parse the grammar.
Parsing is completed when we reach $ symbol.
9.4 PROCEDURE:
Go to debug -> run or press CTRL + F9 to run the program.
9.5 PROGRAM:
/*LALR PARSER
E->E+T
E->T
T->T*F
T->F
F->(E)
F->i
*/
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
void push(char *,int *,char);
char stacktop(char *);
void isproduct(char,char);
int ister(char);
int isnter(char);
int isstate(char);
void error();
void isreduce(char,char);
char pop(char *,int *);
void printt(char *,int *,char [],int);
void rep(char [],int);
struct action
{
char row[6][5];
};
37. 30
printf("%c",inp[r]);
}
void rep(char t[],int r)
{
char c;
c=t[r];
switch(c)
{
case 'a': printf("0");
break;
case 'b': printf("1");
break;
case 'c': printf("2");
break;
case 'd': printf("3");
break;
case 'e': printf("4");
break;
case 'f': printf("5");
break;
case 'g': printf("6");
break;
case 'h': printf("7");
break;
case 'm': printf("8");
break;
case 'j': printf("9");
break;
case 'k': printf("10");
break;
case 'l': printf("11");
break;
default :printf("%c",t[r]);
break;
}
}
38. 31
9.6 PRE-LAB QUESTIONS
1 Why bottom-up parsing is also called as shift reduce parsing?
2 What are the different types of bottom up parsers?
3 What is mean by LR (0) items?
4 Write the general form of LR(1) item?
5 What is YACC?
9.7 LAB ASSIGNMENT
1 Write a program to compute FOLLOW for the following grammar?
E TE'
E'+TE'/î
TFT’
T'*FT'/î
F(E)/i
2 Write a program to construct LALR parsing table for the following grammar.
SiCtSS’
S’eS/ î
9.8 POST-LAB QUESTIONS:
1. What is LALR parsing?
2. What is Shift reduced parser?
3. What are the operations of Parser?
4. What is the use of parsing table?
5. What is bottom up parsing?
9.9 INPUT & OUTPUT:
Enter the input: i*i+1
Output
Stack input
0 i*i+i$
0i5 *i+i$
0F3 *i+i$
0T2 *i+i$
0T2*7 i+i$
0T2*7i5 +i$
0T2*7i5F10 +i$
0T2 +i$
0E1 +i$
0E1+6 i$
0E1+6i5 $
0E1+6F3 $
0E1+6T9 $
0E1 $
accept the input*/
39. 32
EXPERIMENT-10(a)
10.1 OBJECTIVE:
*Write a C program to implement operator precedence parsing.
10.2 RESOURCE:
Turbo C++
10.3 PROGRAM LOGIC:
Read the arithmetic input string.
Verify the precedence between terminals and symbols
Find the handle enclosed in < . > and reduce it to production symbol.
Repeat the process till we reach the start node.
10.4 PROCEDURE:
Go to debug -> run or press CTRL + F9 to run the program.
10.5 PROGRAM:
#include<stdio.h>
char str[50],opstr[75];
int f[2][9]={2,3,4,4,4,0,6,6,0,1,1,3,3,5,5,0,5,0};
int col,col1,col2;
char c;
swt()
{
switch(c)
{
case'+':col=0;break;
case'-':col=1;break;
case'*':col=2;break;
case'/':col=3;break;
case'^':col=4;break;
case'(':col=5;break;
case')':col=6;break;
case'd':col=7;break;
case'$':col=8;break;
default:printf("nTERMINAL MISSMATCHn");
exit(1);
44. 37
EXPERIMENT-10(b)
10.1 OBJECTIVE:
Program to implement semantic rules to calculate the expression that takes an expression with digits, + and
* and computes the value.
10.2 RESOURCE:
Linux using putty
10.3 PROCEDURE:
Reading an input file
Calculate the sum or multiplication of given expression.
Using expression rule print the result of the given values.
10.4 PROGRAM:
<parser.l>
%{
#include<stdio.h>
#include "y.tab.h"
%}
%%
[0-9]+ {yylval.dval=atof(yytext);
return DIGIT;
}
n|. return yytext[0];
%%
<parser.y>
%{
/*This YACC specification file generates the LALR parser for the program
considered in experiment 4.*/
#include<stdio.h>
%}
%union
{
double dval;
}
%token <dval> DIGIT
%type <dval> expr
%type <dval> term
%type <dval> factor
%%
line: expr 'n' {
46. 39
EXPERIMENT-11
11.1 OBJECTIVE:
Convert The BNF rules into Yacc form and write code to generate abstract syntax tree.
11.2 RESOURCE :
linux using putty
11.3 PROGRAM LOGIC:
Reading an input file line by line.
Convert it in to abstract syntax tree using three address code.
Represent three address code in the form of quadruple tabular form.
11.4 PROCEDURE:
Go to terminal .Open vi editor ,Lex lex.l , cc lex.yy.c , ./a.out
11.5 PROGRAM
<int.l>
%{
#include"y.tab.h"
#include<stdio.h>
#include<string.h>
int LineNo=1;
%}
identifier [a-zA-Z][_a-zA-Z0-9]*
number [0-9]+|([0-9]*.[0-9]+)
%%
main() return MAIN;
if return IF;
else return ELSE;
while return WHILE;
int |
char |
float return TYPE;
{identifier} {strcpy(yylval.var,yytext);
return VAR;}
{number} {strcpy(yylval.var,yytext);
return NUM;}
< |> |>= |<= |== {strcpy(yylval.var,yytext);
return RELOP;}
[ t] ;
n LineNo++;
. return yytext[0];
%%
<int.y>
%{
#include<string.h>
#include<stdio.h>
struct quad{
char op[5];
char arg1[10];
char arg2[10];
char result[10];
}QUAD[30];
struct stack{
int items[100];
int top;
}stk;
int Index=0,tIndex=0,StNo,Ind,tInd;
47. 40
extern int LineNo;
%}
%union{
char var[10];
}
%token <var> NUM VAR RELOP
%token MAIN IF ELSE WHILE TYPE
%type <var> EXPR ASSIGNMENT CONDITION IFST ELSEST WHILELOOP
%left '-' '+'
%left '*' '/'
%%
PROGRAM : MAIN BLOCK
;
BLOCK: '{' CODE '}'
;
CODE: BLOCK
| STATEMENT CODE
| STATEMENT
;
STATEMENT: DESCT ';'
| ASSIGNMENT ';'
| CONDST
| WHILEST
;
DESCT: TYPE VARLIST
;
VARLIST: VAR ',' VARLIST
| VAR
;
ASSIGNMENT: VAR '=' EXPR{
strcpy(QUAD[Index].op,"=");
strcpy(QUAD[Index].arg1,$3);
strcpy(QUAD[Index].arg2,"");
strcpy(QUAD[Index].result,$1);
strcpy($$,QUAD[Index++].result);
}
;
EXPR: EXPR '+' EXPR {AddQuadruple("+",$1,$3,$$);}
| EXPR '-' EXPR {AddQuadruple("-",$1,$3,$$);}
| EXPR '*' EXPR {AddQuadruple("*",$1,$3,$$);}
| EXPR '/' EXPR {AddQuadruple("/",$1,$3,$$);}
| '-' EXPR {AddQuadruple("UMIN",$2,"",$$);}
| '(' EXPR ')' {strcpy($$,$2);}
| VAR
| NUM
;
CONDST: IFST{
Ind=pop();
sprintf(QUAD[Ind].result,"%d",Index);
Ind=pop();
sprintf(QUAD[Ind].result,"%d",Index);
}
| IFST ELSEST
;
IFST: IF '(' CONDITION ')' {
strcpy(QUAD[Index].op,"==");
strcpy(QUAD[Index].arg1,$3);
strcpy(QUAD[Index].arg2,"FALSE");
strcpy(QUAD[Index].result,"-1");
push(Index);
50. 43
else
{
c=a+b;
}
}
11.7 PRE-LAB QUESTIONS
1 What are the functions we use to construct a syntax tree?
2 What is Meta data?
3 How list of identifiers are represented using BNF rules?
4 What is three address code?
5 What are the record structures we use to represent three address code?
11.8 LAB ASSIGNMENT
1 Write YACC for the desktop calculator?
2 Write BNF rules for the following grammar?
EE+T/T
T T*F/F
F(E)/id
11.9 POST-LAB QUESTIONS:
1. What is Abstract Syntax tree?
2. What are BNF Rules?
3. What is DAG representation?
4. How LALR (1) states are generates?
5. In which condition the user has to supply more information to YACC?
11.10 INPUT & OUTPUT:
$lex int.l
$yacc –d int.y
$gcc lex.yy.c y.tab.c –ll –lm$./a.out test.c
OUTPUT
Pos Operator Arg1 Arg2 Result
0 < a b t0
1 == t0 FALSE 5
2 + a b t1
3 == t1 5
4 GOTO
5 < a b t2
6 == t2 FALSE 10
7 + a b t3
8 = t3 a
9 GOTO 5
10 <= a b t4
11 == t4 FALSE 15
12 - a b t5
13 = t5 c
14 GOTO 17
15 + a b t6
16 = t6 c
51. 44
EXPERIMENT-12
12.1 OBJECTIVE:
Write a C program to generate machine code from abstract syntax tree generated by the parser. The instruction
set specified in Note 2 may be considered as the target code.
12.2 RESOURSE:
TURBO C++
12.3 PROGRAM LOGIC:
Read input string
Consider each input string and convert in to machine code instructions
12.4 PROCEDURE:
Go to terminal .Open vi editor ,Lex lex.l , cc lex.yy.c , ./a.out
12.5 PROGRAM:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int label[20];
int no=0;
int main()
{
FILE *fp1,*fp2;
char fname[10],op[10],ch;
char operand1[8],operand2[8],result[8];
int i=0,j=0;
printf("n Enter filename of the intermediate code");
scanf("%s",&fname);
fp1=fopen(fname,"r");
fp2=fopen("target.txt","w");
if(fp1==NULL || fp2==NULL)
{
printf("n Error opening the file");
exit(0);
}
while(!feof(fp1))
{
52. 45
fprintf(fp2,"n"); fscanf(fp1,"%s",op);
i++; if(check_label(i))
fprintf(fp2,"nlabel#%d",i);
if(strcmp(op,"print")==0)
{
fscanf(fp1,"%s",result);
fprintf(fp2,"nt OUT %s",result);
}
if(strcmp(op,"goto")==0)
{
fscanf(fp1,"%s %s",operand1,operand2);
fprintf(fp2,"nt JMP %s,label#%s",operand1,operand2);
label[no++]=atoi(operand2);
}
if(strcmp(op,"[]=")==0)
{
fscanf(fp1,"%s %s %s",operand1,operand2,result);
fprintf(fp2,"nt STORE %s[%s],%s",operand1,operand2,result);
}
if(strcmp(op,"uminus")==0)
{
fscanf(fp1,"%s %s",operand1,result);
fprintf(fp2,"nt LOAD -%s,R1",operand1);
fprintf(fp2,"nt STORE R1,%s",result);
}
switch(op[0])
{
case '*': fscanf(fp1,"%s %s %s",operand1,operand2,result);
fprintf(fp2,"n t
LOAD",operand1);
fprintf(fp2,"n t LOAD
%s,R1",operand2);
fprintf(fp2,"n t MUL R1,R0");
fprintf(fp2,"n t STORE
R0,%s",result); break;
case '+': fscanf(fp1,"%s %s
%s",operand1,operand2,result);
fprintf(fp2,"n t LOAD %s,R0",operand1);
fprintf(fp2,"n t LOAD %s,R1",operand2);
fprintf(fp2,"n t ADD R1,R0");
fprintf(fp2,"n t STORE R0,%s",result);
break;
case '-': fscanf(fp1,"%s %s
%s",operand1,operand2,result); fprintf(fp2,"n
t LOAD %s,R0",operand1); fprintf(fp2,"n t
53. 46
LOAD %s,R1",operand2); fprintf(fp2,"n t
SUB R1,R0");
fprintf(fp2,"n t STORE R0,%s",result);
break;
case '/': fscanf(fp1,"%s %s s",operand1,operand2,result);
fprintf(fp2,"n t LOAD %s,R0",operand1);
fprintf(fp2,"n t LOAD %s,R1",operand2);
fprintf(fp2,"n t DIV R1,R0");
fprintf(fp2,"n t STORE R0,%s",result);
break;
case '%': fscanf(fp1,"%s %s %s",operand1,operand2,result);
fprintf(fp2,"n t LOAD %s,R0",operand1);
fprintf(fp2,"n t LOAD %s,R1",operand2);
fprintf(fp2,"n t DIV R1,R0");
fprintf(fp2,"n t STORE R0,%s",result);
break;
case '=': fscanf(fp1,"%s %s",operand1,result);
fprintf(fp2,"nt STORE %s %s",operand1,result);
break;
case '>': j++;
fscanf(fp1,"%s %s %s",operand1,operand2,result);
fprintf(fp2,"n t LOAD %s,R0",operand1);
fprintf(fp2,"nt JGT %s,label#%s",operand2,result);
label[no++]=atoi(result);
break;
case '<': fscanf(fp1,"%s %s %s",operand1,operand2,result);
fprintf(fp2,"n t LOAD %s,R0",operand1); fprintf(fp2,"nt
JLT %s,label#%d",operand2,result);
label[no++]=atoi(result);
break;
}
}
fclose(fp2); fclose(fp1);
fp2=fopen("target.txt","r");
if(fp2==NULL)
{
printf("Error opening the filen");
exit(0);
}
do
{
ch=fgetc(fp2);
printf("%c",ch);
}while(ch!=EOF);
fclose(fp1);
return 0;
54. 47
}
int check_label(int k)
{
int i;
for(i=0;i<no;i++)
{
if(k==label[i])
return 1;
}
return 0;
}
12.6 PRE-LAB QUESTIONS
1 What are the different forms of object code?
2 What is mean by relocatable object code?
3 What is the cost of register to register operation?
4 What is address descriptor?
5 What is register descriptor?
12.7 LAB ASSIGNMENT
1 Write a program to generate the code for the following three address code statements?
A=B+C
W=X-Y
2 Write a program to generate the code for the following three address code statements?
W=(A+B)*C
12.8 POST-LAB QUESTIONS
1. What is target code?
2. What is machine code?
3. What is Cross compiler?
4. Give the example for cross compiler?
5. What is the difference between syntax & Semantics?
12.9 INPUT & OUTPUT:
$vi int.txt
=t1 2
[]=a 0 1
[]=a 1 2
[]=a 2 3
*t1 6 t2
+a[2] t2 t3
-a[2] t1 t2
/t3 t2 t2
uminus t2 t2
print t2
goto t2 t3
=t3 99
uminus 25 t2
*t2 t3 t3
uminus t1 t1
+t1 t3 t4
print t4
55. 48
Output:
Enter filename of the intermediate code: int.txt
STORE t1,2
STORE a[0],1
STORE a[1],2
STORE a[2],3
LOAD t1,R0
LOAD 6,R1
ADD R1,R0
STORE R0,t3
LOAD a[2],R0
LOAD t2,R1
ADD R1,R0
STORE R0,t3
LOAD a[t2],R0
LOAD t1,R1
SUB R1,R0
STORE R0,t2
LOAD t3,R0
LOAD t2,R1
DIV R1,R0
STORE R0,t2
LOAD t2,R1
STORE R1,t2
LOAD t2,R0
JGT 5,label#11
Label#11: OUT t2
JMP t2,label#13
Label#13: STORE t3,99
LOAD 25,R1
STORE R1,t2
LOAD t2,R0
LOAD t3,R1
MUL R1,R0
STORE R0,t3
LOAD t1,R1
STORE R1,t1
LOAD t1,R0
LOAD t3,R1
ADD R1,R0
STORE R0,t4
OUT t4