This document discusses Lex and Yacc, which are tools used to generate lexical analyzers and parsers. Lex reads input specifying a lexical analyzer and outputs C code implementing it. Yacc reads a grammar and generates a C parser. The document provides examples of Lex and Yacc code and explains how they are linked and used together, with Lex generating tokens that are passed to a Yacc parser. Key aspects covered include the structure and sections of Lex and Yacc programs, and how they are compiled and linked to recognize formal languages.
Prof. Chethan Raj C, BE, M.Tech (Ph.D) Dept. of CSE. System Software & Operat...Prof Chethan Raj C
Prof. Chethan Raj C, BE, M.Tech (Ph.D) Dept. of CSE. System Software & Operating System Lab Manual.
1) To make students familiar with Lexical Analysis and Syntax Analysis phases of Compiler Design and implement programs on these phases using LEX & YACC tools and/or C/C++/Java.
2) To enable students to learn different types of CPU scheduling algorithms used in Operating system.
3) To make students able to implement memory management - page replacement and deadlock handling algorithms.
Prof. Chethan Raj C, BE, M.Tech (Ph.D) Dept. of CSE. System Software & Operat...Prof Chethan Raj C
Prof. Chethan Raj C, BE, M.Tech (Ph.D) Dept. of CSE. System Software & Operating System Lab Manual.
1) To make students familiar with Lexical Analysis and Syntax Analysis phases of Compiler Design and implement programs on these phases using LEX & YACC tools and/or C/C++/Java.
2) To enable students to learn different types of CPU scheduling algorithms used in Operating system.
3) To make students able to implement memory management - page replacement and deadlock handling algorithms.
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdffxintegritypublishin
Advancements in technology unveil a myriad of electrical and electronic breakthroughs geared towards efficiently harnessing limited resources to meet human energy demands. The optimization of hybrid solar PV panels and pumped hydro energy supply systems plays a pivotal role in utilizing natural resources effectively. This initiative not only benefits humanity but also fosters environmental sustainability. The study investigated the design optimization of these hybrid systems, focusing on understanding solar radiation patterns, identifying geographical influences on solar radiation, formulating a mathematical model for system optimization, and determining the optimal configuration of PV panels and pumped hydro storage. Through a comparative analysis approach and eight weeks of data collection, the study addressed key research questions related to solar radiation patterns and optimal system design. The findings highlighted regions with heightened solar radiation levels, showcasing substantial potential for power generation and emphasizing the system's efficiency. Optimizing system design significantly boosted power generation, promoted renewable energy utilization, and enhanced energy storage capacity. The study underscored the benefits of optimizing hybrid solar PV panels and pumped hydro energy supply systems for sustainable energy usage. Optimizing the design of solar PV panels and pumped hydro energy supply systems as examined across diverse climatic conditions in a developing country, not only enhances power generation but also improves the integration of renewable energy sources and boosts energy storage capacities, particularly beneficial for less economically prosperous regions. Additionally, the study provides valuable insights for advancing energy research in economically viable areas. Recommendations included conducting site-specific assessments, utilizing advanced modeling tools, implementing regular maintenance protocols, and enhancing communication among system components.
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxR&R Consult
CFD analysis is incredibly effective at solving mysteries and improving the performance of complex systems!
Here's a great example: At a large natural gas-fired power plant, where they use waste heat to generate steam and energy, they were puzzled that their boiler wasn't producing as much steam as expected.
R&R and Tetra Engineering Group Inc. were asked to solve the issue with reduced steam production.
An inspection had shown that a significant amount of hot flue gas was bypassing the boiler tubes, where the heat was supposed to be transferred.
R&R Consult conducted a CFD analysis, which revealed that 6.3% of the flue gas was bypassing the boiler tubes without transferring heat. The analysis also showed that the flue gas was instead being directed along the sides of the boiler and between the modules that were supposed to capture the heat. This was the cause of the reduced performance.
Based on our results, Tetra Engineering installed covering plates to reduce the bypass flow. This improved the boiler's performance and increased electricity production.
It is always satisfying when we can help solve complex challenges like this. Do your systems also need a check-up or optimization? Give us a call!
Work done in cooperation with James Malloy and David Moelling from Tetra Engineering.
More examples of our work https://www.r-r-consult.dk/en/cases-en/
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdffxintegritypublishin
Advancements in technology unveil a myriad of electrical and electronic breakthroughs geared towards efficiently harnessing limited resources to meet human energy demands. The optimization of hybrid solar PV panels and pumped hydro energy supply systems plays a pivotal role in utilizing natural resources effectively. This initiative not only benefits humanity but also fosters environmental sustainability. The study investigated the design optimization of these hybrid systems, focusing on understanding solar radiation patterns, identifying geographical influences on solar radiation, formulating a mathematical model for system optimization, and determining the optimal configuration of PV panels and pumped hydro storage. Through a comparative analysis approach and eight weeks of data collection, the study addressed key research questions related to solar radiation patterns and optimal system design. The findings highlighted regions with heightened solar radiation levels, showcasing substantial potential for power generation and emphasizing the system's efficiency. Optimizing system design significantly boosted power generation, promoted renewable energy utilization, and enhanced energy storage capacity. The study underscored the benefits of optimizing hybrid solar PV panels and pumped hydro energy supply systems for sustainable energy usage. Optimizing the design of solar PV panels and pumped hydro energy supply systems as examined across diverse climatic conditions in a developing country, not only enhances power generation but also improves the integration of renewable energy sources and boosts energy storage capacities, particularly beneficial for less economically prosperous regions. Additionally, the study provides valuable insights for advancing energy research in economically viable areas. Recommendations included conducting site-specific assessments, utilizing advanced modeling tools, implementing regular maintenance protocols, and enhancing communication among system components.
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxR&R Consult
CFD analysis is incredibly effective at solving mysteries and improving the performance of complex systems!
Here's a great example: At a large natural gas-fired power plant, where they use waste heat to generate steam and energy, they were puzzled that their boiler wasn't producing as much steam as expected.
R&R and Tetra Engineering Group Inc. were asked to solve the issue with reduced steam production.
An inspection had shown that a significant amount of hot flue gas was bypassing the boiler tubes, where the heat was supposed to be transferred.
R&R Consult conducted a CFD analysis, which revealed that 6.3% of the flue gas was bypassing the boiler tubes without transferring heat. The analysis also showed that the flue gas was instead being directed along the sides of the boiler and between the modules that were supposed to capture the heat. This was the cause of the reduced performance.
Based on our results, Tetra Engineering installed covering plates to reduce the bypass flow. This improved the boiler's performance and increased electricity production.
It is always satisfying when we can help solve complex challenges like this. Do your systems also need a check-up or optimization? Give us a call!
Work done in cooperation with James Malloy and David Moelling from Tetra Engineering.
More examples of our work https://www.r-r-consult.dk/en/cases-en/
Explore the innovative world of trenchless pipe repair with our comprehensive guide, "The Benefits and Techniques of Trenchless Pipe Repair." This document delves into the modern methods of repairing underground pipes without the need for extensive excavation, highlighting the numerous advantages and the latest techniques used in the industry.
Learn about the cost savings, reduced environmental impact, and minimal disruption associated with trenchless technology. Discover detailed explanations of popular techniques such as pipe bursting, cured-in-place pipe (CIPP) lining, and directional drilling. Understand how these methods can be applied to various types of infrastructure, from residential plumbing to large-scale municipal systems.
Ideal for homeowners, contractors, engineers, and anyone interested in modern plumbing solutions, this guide provides valuable insights into why trenchless pipe repair is becoming the preferred choice for pipe rehabilitation. Stay informed about the latest advancements and best practices in the field.
Student information management system project report ii.pdfKamal Acharya
Our project explains about the student management. This project mainly explains the various actions related to student details. This project shows some ease in adding, editing and deleting the student details. It also provides a less time consuming process for viewing, adding, editing and deleting the marks of the students.
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)MdTanvirMahtab2
This presentation is about the working procedure of Shahjalal Fertilizer Company Limited (SFCL). A Govt. owned Company of Bangladesh Chemical Industries Corporation under Ministry of Industries.
Saudi Arabia stands as a titan in the global energy landscape, renowned for its abundant oil and gas resources. It's the largest exporter of petroleum and holds some of the world's most significant reserves. Let's delve into the top 10 oil and gas projects shaping Saudi Arabia's energy future in 2024.
Cosmetic shop management system project report.pdfKamal Acharya
Buying new cosmetic products is difficult. It can even be scary for those who have sensitive skin and are prone to skin trouble. The information needed to alleviate this problem is on the back of each product, but it's thought to interpret those ingredient lists unless you have a background in chemistry.
Instead of buying and hoping for the best, we can use data science to help us predict which products may be good fits for us. It includes various function programs to do the above mentioned tasks.
Data file handling has been effectively used in the program.
The automated cosmetic shop management system should deal with the automation of general workflow and administration process of the shop. The main processes of the system focus on customer's request where the system is able to search the most appropriate products and deliver it to the customers. It should help the employees to quickly identify the list of cosmetic product that have reached the minimum quantity and also keep a track of expired date for each cosmetic product. It should help the employees to find the rack number in which the product is placed.It is also Faster and more efficient way.
Water scarcity is the lack of fresh water resources to meet the standard water demand. There are two type of water scarcity. One is physical. The other is economic water scarcity.
Immunizing Image Classifiers Against Localized Adversary Attacksgerogepatton
This paper addresses the vulnerability of deep learning models, particularly convolutional neural networks
(CNN)s, to adversarial attacks and presents a proactive training technique designed to counter them. We
introduce a novel volumization algorithm, which transforms 2D images into 3D volumetric representations.
When combined with 3D convolution and deep curriculum learning optimization (CLO), itsignificantly improves
the immunity of models against localized universal attacks by up to 40%. We evaluate our proposed approach
using contemporary CNN architectures and the modified Canadian Institute for Advanced Research (CIFAR-10
and CIFAR-100) and ImageNet Large Scale Visual Recognition Challenge (ILSVRC12) datasets, showcasing
accuracy improvements over previous techniques. The results indicate that the combination of the volumetric
input and curriculum learning holds significant promise for mitigating adversarial attacks without necessitating
adversary training.
1. By
Dr. Prem Nath
Associate Professor
Computer Science & Engineering Department,
H N B Garhwal University
(A Central University)
Lex And Yacc
1
2. Outline
▪ Lex:
▪ Theory
▪ Execution
▪ Example
▪ Yacc:
▪ Theory
▪ Description
▪ Example
▪ Lex & Yacc linking.
2
3. Lex
Lex is a Programming Language or Tool that generates lexical
analyzers, (widely used on Unix with vi editor).
It is mostly used with Yacc parser generator.
Written by Eric Schmidt and Mike Lesk.
It reads the input stream (specifying the lexical analyzer ) and
outputs source code implementing the lexical analyzer in the C
programming language.
Lex will read patterns (regular expressions) then produces C
code.
3
4. 4
LEX…
A Language for Specifying Lexical Analyzers
• Not only a table generator, but also allows “actions”
to associate with RE’s.
• Lex is widely used in the Unix community
• Lex is not efficient enough for production
compilers, however.
5. Lex…
Dr. Prem Nath 5
General Information:
• Input is stored in a file with *.l extension
• File consists of three main sections
• lex generates C function stored in lex.yy.c
Using Lex:
1) Specify words to be used as tokens (Extension of regular
expressions)
2) Run the lex utility on the source file to generate yylex( ),
a C function
3) Declares global variables char* yytext and int yyleng
9. Lex…
A simple pattern: letter(letter|digit)*
Regular expressions are translated by Lex to a computer program that
mimics an FA.
This pattern matches a string of characters that begins with a single
letter followed by zero or more letters or digits.
9
10. Lex…
Some limitations, Lex cannot be used to recognize nested structures such
as parentheses, since it only has states and transitions between states.
So, Lex is good at pattern matching, while Yacc is for more challenging
tasks.
10
14. Lex…
Whitespace must separate the defining term and the associated expression.
Code in the definitions section is simply copied as-is to the top of the generated C file and
must be bracketed with “%{“ and “%}” markers.
substitutions in the rules section are surrounded by braces ({letter}) to distinguish them
from literals.
14
15. Lex…
/* Lex Program to Recognize Id, Keywords, and Number
%{ #include<stdio.h>
letter [a-z A-Z]
digit [0-9] %}
%%
id {letter}({letter}I{letter})*
number {digit}+(.{digit})+?(E[+, -]?{digit})+
%%
/* Auxiliary Functions
{id} {printf(“%s is an Identifier”, yytext);}
{if} {printf(“%s is a Keyword”, yytext);}
{number} {printf(“%s is a Number”, yytext);}
Dr. Prem Nath 15
16. Yacc
➢ Yacc reads the grammar and generate C code for a
parser .
➢ Parser Generator (Compiler to Compiler)
➢ Files are with .y extension
◦ Grammars written in Backus Naur Form (BNF)
◦ BNF grammar used to express context-free languages .
◦ e.g. to parse an expression , do reverse operation(
reducing the expression)
◦ LALR(1) Parser (Look Ahead Left to Right One)
◦ Using stack for storing (LIFO)
◦ Written by Stefen C Johnson
16
17. Yacc…
Input to Yacc is divided into three sections.
... definitions ...
%%
... rules ...
%%
... subroutines ...
17
18. Yacc…
The definitions section consists of:
◦ token declarations .
◦ C code bracketed by “%{“ and “%}”.
◦ the rules section consists of:
BNF grammar .
the subroutines section consists of:
◦ user subroutines .
18
20. 20
Linking lex and Yacc…
Yacc
Compiler
Lex
a.out
parse.y
y.tab.c
(yyparse)
scan.l
source
program
output
C
Compiler
lex.yy.c
a.out
Included
21. Linking lex and Yacc…
21
• yyval: Vallue Associated With Token
• yytext: Pointer to Input String
22. Linking lex and Yacc…
22
$$: First Symbol of the Body
$i: ith Symbol of the Body
23. Linking lex and Yacc…
❑Construct a Lexical Analyzer and Parser for
Language L={anbn: n ≥1}.
/* Lex Tool ab.l
%{
#include<y.tab.h>
%}
%%
[a] {return a;}
[b] {return b;}
[n] {return 0;}
%%
/* No Main Function
Dr. Prem Nath 23
24. Linking lex and Yacc…
/* Yacc Tool cd.y
%{
#include<stdio.h>
#include<stdlib.h>
%}
% token a b
%%
start: S ‘n’ {return 0;}
S: aSb {$S=$1$2;}
%%
Dr. Prem Nath 24
25. Linking lex and Yacc…
/* Yacc Tool CD.y
/* Main Function
int main( )
{
printf(“Enter a String:”);
if(yyparse= = 0)
printf(“Valid String”);
yyerror( )
{
printf(“Invalid String”);
exit(0);
}
int yywrap( )
{
return 1;
}
}
Dr. Prem Nath 25