尊敬的 微信汇率:1円 ≈ 0.046166 元 支付宝汇率:1円 ≈ 0.046257元 [退出登录]
SlideShare a Scribd company logo
EXPERIMENT NO:1
TITLE: LEXICAL ANALYZER
To find out a given string is an identifier or not.
OUTLINE:
Identifier is an entity which starts from a letter and then it can contain both letters and digit,
any other special character is not allowed in the identifier. While checking for identifier we
normally use DFA as it is done in lexical analysis state which works with regular grammar.
DFA for identifier consists of three states first state is accepting only letters and then moving
to second state when it got a letter. Second state can accept both letters and digits and
comeback to itself when it got one. Second state can also accept terminating symbol
(delimiter) which lead it to third state which identifies it as an identifier.
ALGORITHM:
Step 1. Start
Step 2. Check if the first char is a letter goto step 3 with rest of the string else goto 5.
Step 3. Check if the first character of the given string is a letter or a digit repeat step
3 with rest of the string else goto step 5.
Step 4. Print “The given string is an identifier” and goto step 6.
Step 5. Print “The given string is not an identifier”.
Step 6. Exit
OUTPUT:
Enter the desired String: a123
The given string is an identifier
……………………………………………….
Enter the desired String: shailesh
The given string is an identifier
……………………………………………..
Enter the desired String: 1asd
The given string is not an identifier
……………………………………………..
Enter the desired String: as-*l
The given string is not an identifier
EXPERIMENT NO :2
TITLE: DFA SIMULATION
Write a program for acceptance of a string using a given DFA.
OUTLINE:
A DFA is an acceptor that, for any state and input character, has at most one transition
state that the acceptor changes to. A Deterministic Finite Automata M involves the
following components:
■ A list of states
■ A set of alphabet letters
■ A set of transition functions
■ A start state
■ A set of final states
The program reads the description (listed above) of the machine M. It then reads in a set of
input strings (interactively) and determines whether or not a particular string is acceptable
by the machine.
OUTPUT:
No. of states in DFA are:3
No. of final states in DFA are:1
Enter state number(s) of final states(s):2
No. of characters you are using in DFA are:2
Enter those characters one by one:
a b
Describe your DFA
If char ‘A’ is output from state i to state j then write j at combination of i & ‘A’
1) Enter the string to be tested: aab
Valid string
2) Enter the string to be tested: abab
Error!!! Invalid string
TITLE: LEXICAL ANALYZER
To write a program for dividing the given input program into lexemes.
OUTLINE:
lexical analysis is the process of converting a sequence of characters into a sequence
of tokens. A program or function which performs lexical analysis is called a lexical
analyzer, or lexer.
ALGORITHM:
Step 1: start
Step 2: Read the file and open the file as read mode.
Step 3: Read the string for tokens identifiers, variables.
Step 4: take parenthesis also a token.
Step 5: parse the string
Step 6: stop.
OUTPUT:
Enter the input:
void main()
{
}
^Z
Lexeme Token
……………………………………………………………
void Keyword
main Function
( parenthesis
) parenthesis
{ Braces
} Braces
EXPERIMENT NO :3
TITLE:
A program to check the string of a given grammar.
OUTLINE:
A grammar consists of a finite nonempty set of rules or productions which specify the syntax
of the language. In the context of lexical analysis the rules are known as lexical rules.
Otherwise, the rules are meant for production rules or syntactical rules.
For a given grammar, the program reads a string as input. In a simple derivation process
the given string is parsed on a top-down manner.
ALGORITHM:
Step 1: start
Step 2: Read the file and open the file as read mode.
Step 3: Read the string for tokens identifiers, variables.
Step 4: take parenthesis also a token.
Step 5: parse the string
Step 6: stop.
OUTPUT:
The given grammar is: S->aS, S->Sb, S->ab
Enter the string to be checked:
aaabb
The string accepted
Enter the string to be checked:
abaab
The string does not belong to the specified grammar
Enter the string to be checked:
baaa
The string does not belong to the specified grammar
TITLE: CFG
Program to eliminate left-recursion from a context-free grammar.
OUTLINE:
A grammar G is said to be left-recursive if it has a non-terminal A such that there is a
derivation A => Aa for some a. A left-recursive grammar can cause a top -down parser to go
into an infinite loop i.e. when try to expand A, you may eventually find yourself again trying
to expand A without having consumed any input.
Consider the grammar:
A–> Aa | b is a general form of immediate left-recursive grammar.
To eliminate left-recursion you have to replace the grammar by the following pair of
production rules:
A–> bA’
A’–> aA |
ALGORITHM:
1. Arrange the NTs into some order A1, A2, …, An
2. for i ¬ 1 to n do
begin
for j¬ 1 to i-1 do
replace each production Ai ® Aj g by the productions
Ai ® d1 g ½d2 g½¼½dk g, where Ai® d1 ½d2½¼½dk are
all the current productions for Aj
eliminate any immediate left recursion among the Ai -productions
end
OUTPUT:
Enter no. of production are:6
Enter production:
E->E+T
E->T
T->T*F
T->F
F->(E)
F->id
production after left recursion are:
E->TU
U->+TU
U->#
T->FV
V->*FV
V->#
F->(E)
F->id
EXPERIMENT NO :4
TITLE: TOP-DOWN PARSING
Recursive-descent parsing: To write a program on recursive descendent parsing.
OUTLINE:
A parser that uses a set of recursive procedures to recognize its input by performing syntax
analysis with no backtracking is called a recursive-descent parser. It works in a top-down
fashion.
Consider the following grammar that is suitable for non-backtracking recursive-descent
parsing:
E–> TE’
E’–> +TE’ |
T–> FT’
T’–> *FT’ |
F–> (E) | id
ALGORITHM:
Step 1: start.
Step 2: Declare the prototype functions E() , EP(),T(), TP(),F()
Step 3: Read the string to be parsed.
Step 4: Check the productions
Step 5: Compare the terminals and Non-terminals
Step 6: Read the parse string.
Step 7: stop the production
OUTPUT:
The given grammar is: E–> TE’, E’–> +TE’ |@, T–> FT’, T’–> *FT’ |@, F–> (E) | id
Enter the expression to be parsed:
id + id * id
The string is parsed.
The given grammar is: E–> TE’, E’–> +TE’ |@, T–> FT’, T’–> *FT’ |@, F–> (E) | id
Enter the expression to be parsed:
id + id *+ id
The string is not parsed
EXPERIMENT NO :5
TITLE: IMPLEMENTATION OF PREDICTIVE PARSING
 Write a code to compute the FIRST, and FOLLOW for all non-terminals.
 Write a code to build LL(1) Parsing table for the given grammar.
OUTLINE:
Consider the grammar, G
E -> T E’
E’ -> + T E’ | ε
T -> F T’
T’ -> * F T’ | ε
F -> ( E ) | id
The construction of a predictive parser is aided by two functions associated with a grammar
G. These functions, FIRST and FOLLOW, allow us to fill in the entries of a predictive
parsing table for G, whenever possible.
ALGORITHM:
Computing FIRST sets:
To compute FIRST(X) for all grammar symbols X, apply the following rules until no more
terminals or ε can be added to any FIRST set.
1. if X is terminal, then FIRST(X) is {X}.
2. if X is non-terminal and X-> aα is a production, then add a to FIRST(X). if X-> ε to
FIRST(X).
3. if -> Y1,Y2,…….Yk is a production, then for all i such that all of Y1,….Yi-1 are non-
terminals and FIRST(Yj) contains ε for j=1,2,…… i-1, add every non- ε symbol
in FIRST(Y1) to FIRST(x). if V is in FIRST(Yj) for j=1,2,………k, then add ε to FIRST(X).
Computing FOLLOW sets:
To compute FOLLOW(A) for all non-terminals A, apply the following rules until nothing can
be added to any
1. Place $ in FOLLOW(S), where S is the start symbol and $ is the input right end marker.
2. If there is a production A –> aBb , then everything in FIRST(b), except for ε, is placed in
FOLLOW(B).
3. If there is a production A –> aB, or a production A –> aBb where FIRST(b)
contains ε (i.e., b =>* ε), then everything in FOLLOW(A) is in FOLLOW(B).
Constructing Parsing Table:
To construct a parsing table M[A, a] for a grammar G is very simple. Here M[A, a] is a 2-
dimensional array.
1. For each production A–> a of the grammar, do steps 2 and 3.
2. For each terminal a in FIRST(a), add A–> a to M[A, a].
3. If ε is in FIRST(a) and $ is in FOLLOW(A), add A–> a to M[A, $].
Make each undefined entry of M error.
OUTPUT:
Non Terminals :
NT1 E
NT2 T
NT3 F
NT4 E’
NT5 T’
Terminals :
T1 : +
T2 : *
T3: (
T4: )
T5: id
T6: ε
Productions :
Production No 1 E->T E’
Production No 2 E’->+ T E’
Production No 3 T->F T’
Production No 4 T’->* F T’
Production No 5 F->( E )
Production No 6 F->id
Production No 7 E’->ε
Production No 8 T’->ε
First of all Non Terminal
FIRST( E ) = { (, id }
FIRST( T ) = { (, id }
FIRST( F ) = { (, id }
FIRST( E’ ) = { +, ε }
FIRST( T’ ) = { *, ε }
Follow of all Non Terminal
FOLLOW( E ) = { $, ) }
FOLLOW( T ) = { +, $, ) } FOLLOW( F ) = { *, +, $, ) } FOLLOW( E’ ) = { $, ) }
FOLLOW( T’ ) = { +, $, ) }
EXPERIMENT NO :6
TITLE: BOTTOM-UP PARSING
Program to show the implementation of Shift-Reduce Parser.
OUTLINE:
Shift-reduce parsing attempts to construct a parse tree for an input string beginning at the
leaves (the bottom) and working up towards the root (the top). At each reduction step a
particular substring matching the right side of a production is replaced by the symbol on the
left of that production, and if the substring is chosen correctly at each step, a rightmost
derivation is traced out in reverse.
In general, this parsing strategy is non-deterministic. Non-determinism can arise if there are
two productions such that the RHS of one of them is a prefix of the RHS of the other, i.e., if
there are different productions A → α, B → αβ with α ∈ (VN ∪ VT )and β ∈ ∈ (VN ∪ VT )*.
Implementation:
 To implement shift-reduce parser, use a stack to hold grammar symbols and an input
buffer to hold the string w to be parsed.
 Use $ to mark the bottom of the stack and also the right end of the input.
 Initially the stack is empty, and the string w is on the input, as follows:
Stack Input
$ w $
 The parser operates by shifting zero or more input symbols onto the stack until a handle β
is on top of the stack.
 The parser then reduces β to the left side of the appropriate production.
 The parser repeats this cycle until it has detected an error or until the stack contains the
start symbol and the input is empty:
Stack Input
$S $
 After entering this configuration, the parser halts and announces successful completion of
parsing.
 There are four possible actions that a shift-reduce parser can make:1) shift 2) reduce 3)
accept 4) error.
1. In a shift action, the next symbol is shifted onto the top of the stack.
2. In a reduce action, the parser knows the right end of the handle is at the top of the
stack. It must then locate the left end of the handle within the stack and decide with what
non-terminal to replace the handle.
3. In an accept action, the parser announces successful completion of parsing.
4. In an error action, the parser discovers that a syntax error has occurred and calls an
error recovery routine.
· Note: an important fact that justifies the use of a stack in shift-reduce parsing: the
handle will always appear on top of the stack, and never inside
OUTPUT:
SHIFT REDUCE PARSER
GRAMMAR
E–> E + E
E–> E / E
E–> E * E
E–> E | ε
E–> a | b
Enter the string: a + b
Stack Implementation table
——————————————————————————————
Stack Input symbol Action
——————————————————————————————-
$ a + b$ —–
$a +b$ shift a
$E +b$ E–> a
$E+ b$ shift +
$E + b $ shift b
$E + E $ E–> b
$E $ E–> E + E
$E $ ACCEPT
TITLE: INTERMEDIATE CODE GENERATION
Program to generate the intermediate code in the form of Polish notation.
OUTLINE:
Polish notation, also known as Polish prefix notation or simply prefix notation, is a form of
notation for logic, arithmetic, and algebra. Its distinguishing feature is that it
places operators to the left of their operands. When Polish notation is used as a syntax for
mathematical expressions by compiler of programming languages, it is readily parsed
into abstract syntax trees and can, in fact, define a one-to-one representation for the same.
ALGORITHM:
begin
Create OperandStack;
Create OperatorStack;
while( not an empty input expression ) read next token from the input expression
if ( token is an operand )
OperandStack.Push (token);
endif
else if ( token is ‘(‘ or OperatorStack.IsEmpty() or OperatorHierarchy(token) >_
OperatorHierarchy(OperatorStack.Top()) )
OperatorStack.Push ( token );
endif
else if( token is ‘)’ )
while( OperatorStack.Top()!='(‘ )
OperatorStack.Pop(operator);
OperandStack.Pop(RightOperand);
OperandStack.Pop(LeftOperand);
operand = operator + LeftOperand + RightOperand;
OperandStack.Push(operand);
endwhile
OperatorStack.Pop(operator);
endif
else if( operator hierarchy of token is less than or equal to hierarchy of top of the operator
stack )
while( !OperatorStack.IsEmpty() and_
OperatorHierarchy(token)<=OperatorHierarchy(OperatorStack.Top()) )
OperatorStack.Pop(operator);
OperandStack.Pop(RightOperand);
OperandStack.Pop(LeftOperand);
operand = operator + LeftOperand + RightOperand;
OperandStack.Push(operand);
endwhile
OperatorStack.Push(token);
endif
endwhile
while( !OperatorStack.IsEmpty() )
OperatorStack.Pop(operator);
OperandStack.Pop(RightOperand);
OperandStack.Pop(LeftOperand);
operand = operator + LeftOperand + RightOperand;
OperandStack.Push(operand) ;
endwhile
// Save the prefix expression at the top of the operand stack followed by popping // the
operand stack.
print OperandStack.Top();
OperandStack.Pop();
End
OUTPUT:
Enter an input in the form of expression:
(a+b)*(c-d)
The polish notation is: *+ab-cd
Enter an input in the form of expression:
(a–b)/c*(d + e – f / g)
EXPERIMENT NO :7
TITLE: ITERMEDIATE CODE GENERATION
Program for generating for various intermediate code form:
· Three address code
· Quadruple
OUTLINE:
Three address code is a sequence of statements of the form x = y op z . Since a statement
involves no more than three references, it is called a “three-address statement,” and a sequence
of such statements is referred to as three-address code. For example, the three-address code for
the expression a + b * c + d is:
Sometimes a statement might contain less than three references; but it is still called a three-
address statement.
Representing three-address statements:
Records with fields for the operators and operands can be used to represent three-address
statements. It is possible to use a record structure with four fields: the first holds the operator,
the next two hold the operand1 and operand2, respectively, and the last one holds the result. This
representation of a three-address statement is called a “quadruple representation”.
Using quadruple representation, the three-address statement x = y op z is represented by
placing op in the operator field, y in the operand1 field, z in the operand2 field, and x in the result
field.
OP ARG1 ARG2 RESULT
0 + a B T1
1 + c D T2
2 * T1 T2 T3
OUTPUT:
Enter The Expression: a=b+c*d/e; THREE ADDRESS CODE
B:= d / e
C:= c * B
D:= b + B
E:= a = B
QUADRUPLES
ID OP OPERAND 1 OPERAND2 RESULT
(0) / d e B
(1) * c B C
(2) + b B D
(3) = a B E
EXPERIMENT NO :8
This program is to find out whether a given string is a identifier or not.
#include<stdio.h>
#include<conio.h>
int isiden(char*);
int second(char*);
int third();
void main()
{
char *str;
int i = -1;
clrscr();
printf(“nnttEnter the desired String: “);
/*do
{
++i;
str[i] = getch();
if(str[i]!=10 && str[i]!=13)
printf(“%c”,str[i]);
if(str[i] == ‘b’)
{
–i;
printf(” b”);
}
}while(str[i] != 10 && str[i] != 13);
*/
gets(str);
if(isident(str))
printf(“nnttThe given strig is an identifier”);
else
printf(“nnttThe given string is not an identifier”);
getch();
}
//To Check whether the given string is identifier or not
//This function acts like first stage of dfa
int isident(char *str)
{
if((str[0]>=’a’ && str[0]<=’z’) || (str[0]>=’A’ && str[0]<=’Z’))
{
return(second(str+1));
}
else
return 0;
}
//This function acts as second stage of dfa
int second(char *str)
{
if((str[0]>=’0′ && str[0]<=’9′) || (str[0]>=’a’ && str[0]<=’z’) || (str[0]>=’A’ && str[0]<=’Z’))
{
return(second(str+1)); //Implementing the loop from second stage to second stage
}
else
{
if(str[0] == 10 || str[0] == 13)
{
return(third(str));
}
else
{
return 0;
}
}
}
//This function acts as third stage of dfa
int third()
{
return 1; //Being final stage reaching it mean the string is identified
}
EXPERIMENT NO :10
Write a program to simulate a machine known as the Deterministic
Finite Automata (DFA).
PROGRAM:
#include<iostream.h>
#include<conio.h>
#include<process.h>
#include<string.h>
class p_dfa
{
int n,n1,n2,final[10],fa[10][10];
char ch[10],*str;
public:
void accept();
void dfa(char*);
};
void p_dfa::accept()
{
int i,j;
cout << endl << “No. of states in DFA are:”;
cin >> n;
cout << endl << “No. of final states in DFA are:”;
cin >> n1;
cout << endl << “Enter state number(s) of final states(s):”;
for(i=0;i<n1;i++)
cin >> final[i];
cout << endl << “No. of characters you are using in DFA are:”;
cin >> n2;
cout << endl << “Enter those characters one by one:” << endl;
for(i=0;i<n2;i++)
cin >> ch[i];
cout << endl << “Describe your DFA” << endl;
cout << endl << “If char ‘A’ is output from stayte i to state j”;
cout << endl << “then write j at combination of i & ‘A'” << endl;
for(i=0;i<n2;i++)
cout << “t” << ch[i];
cout << endl;
for(i=0;i<n;i++)
{
cout << i << “t”;
for(j=0;j<n2;j++)
cin >> fa[i][j];
}
cout << endl << “Enter the string to be tested:”;
cin >> str;
dfa(str);
}
void p_dfa::dfa(char *str)
{
int i,j,len,state=0,flag;
char c;
len = strlen(str);
for(i=0;i<len;i++)
{
c = str[i];
for(j=0;j<n2;j++)
{
if(c == ch[j])
{
if(fa[state][j] != 0)
{
}
else
{
state = fa[state][j];
break;
cout << endl << “Error!!!”;
cout << endl << “Invalid string”;
}
}
flag=0;
exit(0);
}
}
for(i=0;i<n1;i++)
if(state == final[i])
{
cout << endl << “Valid string”;
flag=1;
}
if(flag=0)
cout << endl << “Invalid string (Final state never obtained)!!!”;
}
void main()
{
p_dfa d;
clrscr();
d.accept();
getch();
}
INDEX
S.no Practical Signature Remark
1
2
3
4
5-a
5-b
6
7
8
To find out a given string is an identifier or not.
Write a program for acceptance of a string
using a given DFA.
A program to check the string of a given
grammar.
Recursive-descent parsing: To write a program
on recursive descendent parsing.
• Write a code to compute the FIRST, and
FOLLOW for all non-terminals.
• Write a code to build LL(1) Parsing table
for the given grammar.
Program to show the implementation of Shift-
Reduce Parser.
Program for generating for various
intermediate code form:
• Three address code
• Quadruple
This program is to find out whether a given
string is a identifier or not.

More Related Content

What's hot

Two-way Deterministic Finite Automata
Two-way Deterministic Finite AutomataTwo-way Deterministic Finite Automata
Two-way Deterministic Finite Automata
Hafsa.Naseem
 
Types of Parser
Types of ParserTypes of Parser
Types of Parser
SomnathMore3
 
HDLC and Point to point protocol
HDLC and Point to point protocolHDLC and Point to point protocol
HDLC and Point to point protocol
Kinza Razzaq
 
First and follow set
First and follow setFirst and follow set
First and follow set
Dawood Faheem Abbasi
 
Network Layer
Network LayerNetwork Layer
Network Layer
reshmadayma
 
Ll(1) Parser in Compilers
Ll(1) Parser in CompilersLl(1) Parser in Compilers
Ll(1) Parser in Compilers
Mahbubur Rahman
 
Intermediate code generator
Intermediate code generatorIntermediate code generator
Intermediate code generator
sanchi29
 
Church Turing Thesis
Church Turing ThesisChurch Turing Thesis
Church Turing Thesis
Hemant Sharma
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFA
Maulik Togadiya
 
Difference between OSI Layer & TCP/IP Layer
Difference between OSI Layer & TCP/IP LayerDifference between OSI Layer & TCP/IP Layer
Difference between OSI Layer & TCP/IP Layer
Netwax Lab
 
Bfs and Dfs
Bfs and DfsBfs and Dfs
Bfs and Dfs
Masud Parvaze
 
Interrupts
InterruptsInterrupts
Interrupts
Albin Panakkal
 
TCP-IP Reference Model
TCP-IP Reference ModelTCP-IP Reference Model
TCP-IP Reference Model
Mukesh Tekwani
 
Combinational circuits
Combinational circuitsCombinational circuits
Combinational circuits
SARITHA REDDY
 
push down automata
push down automatapush down automata
push down automata
Christopher Chizoba
 
Optimization of dfa
Optimization of dfaOptimization of dfa
Optimization of dfa
Kiran Acharya
 
RECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSINGRECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSING
Jothi Lakshmi
 
Three Address code
Three Address code Three Address code
Three Address code
Pooja Dixit
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure ppt
NalinNishant3
 
stack & queue
stack & queuestack & queue
stack & queue
manju rani
 

What's hot (20)

Two-way Deterministic Finite Automata
Two-way Deterministic Finite AutomataTwo-way Deterministic Finite Automata
Two-way Deterministic Finite Automata
 
Types of Parser
Types of ParserTypes of Parser
Types of Parser
 
HDLC and Point to point protocol
HDLC and Point to point protocolHDLC and Point to point protocol
HDLC and Point to point protocol
 
First and follow set
First and follow setFirst and follow set
First and follow set
 
Network Layer
Network LayerNetwork Layer
Network Layer
 
Ll(1) Parser in Compilers
Ll(1) Parser in CompilersLl(1) Parser in Compilers
Ll(1) Parser in Compilers
 
Intermediate code generator
Intermediate code generatorIntermediate code generator
Intermediate code generator
 
Church Turing Thesis
Church Turing ThesisChurch Turing Thesis
Church Turing Thesis
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFA
 
Difference between OSI Layer & TCP/IP Layer
Difference between OSI Layer & TCP/IP LayerDifference between OSI Layer & TCP/IP Layer
Difference between OSI Layer & TCP/IP Layer
 
Bfs and Dfs
Bfs and DfsBfs and Dfs
Bfs and Dfs
 
Interrupts
InterruptsInterrupts
Interrupts
 
TCP-IP Reference Model
TCP-IP Reference ModelTCP-IP Reference Model
TCP-IP Reference Model
 
Combinational circuits
Combinational circuitsCombinational circuits
Combinational circuits
 
push down automata
push down automatapush down automata
push down automata
 
Optimization of dfa
Optimization of dfaOptimization of dfa
Optimization of dfa
 
RECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSINGRECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSING
 
Three Address code
Three Address code Three Address code
Three Address code
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure ppt
 
stack & queue
stack & queuestack & queue
stack & queue
 

Similar to Theory of automata and formal language lab manual

Cd2 [autosaved]
Cd2 [autosaved]Cd2 [autosaved]
Cd2 [autosaved]
BBDITM LUCKNOW
 
Assignment10
Assignment10Assignment10
Assignment10
Sunita Milind Dol
 
Top Down Parsing, Predictive Parsing
Top Down Parsing, Predictive ParsingTop Down Parsing, Predictive Parsing
Top Down Parsing, Predictive Parsing
Tanzeela_Hussain
 
Ch06
Ch06Ch06
Ch06
Hankyo
 
Parsing
ParsingParsing
Parsing
khush_boo31
 
PARSING.ppt
PARSING.pptPARSING.ppt
PARSING.ppt
ayyankhanna6480086
 
Top down parsing
Top down parsingTop down parsing
Top down parsing
ASHOK KUMAR REDDY
 
3. Syntax Analyzer.pptx
3. Syntax Analyzer.pptx3. Syntax Analyzer.pptx
3. Syntax Analyzer.pptx
Mattupallipardhu
 
Syntax analysis
Syntax analysisSyntax analysis
Syntax analysis
Akshaya Arunan
 
In the Notes on Programming Language Syntax page, an example par.docx
In the Notes on Programming Language Syntax page, an example par.docxIn the Notes on Programming Language Syntax page, an example par.docx
In the Notes on Programming Language Syntax page, an example par.docx
mecklenburgstrelitzh
 
Cs6660 compiler design may june 2016 Answer Key
Cs6660 compiler design may june 2016 Answer KeyCs6660 compiler design may june 2016 Answer Key
Cs6660 compiler design may june 2016 Answer Key
appasami
 
Ch4_topdownparser_ngfjgh_ngjfhgfffdddf.PPT
Ch4_topdownparser_ngfjgh_ngjfhgfffdddf.PPTCh4_topdownparser_ngfjgh_ngjfhgfffdddf.PPT
Ch4_topdownparser_ngfjgh_ngjfhgfffdddf.PPT
FutureTechnologies3
 
Syntax Analysis.pptx
Syntax Analysis.pptxSyntax Analysis.pptx
Syntax Analysis.pptx
AshaS74
 
Assignment7
Assignment7Assignment7
Assignment7
Sunita Milind Dol
 
11CS10033.pptx
11CS10033.pptx11CS10033.pptx
11CS10033.pptx
ssuser0be977
 
LL(1) parsing
LL(1) parsingLL(1) parsing
LL(1) parsing
KHYATI PATEL
 
Topic 2_revised.pptx
Topic 2_revised.pptxTopic 2_revised.pptx
Topic 2_revised.pptx
JAYAPRIYAR7
 
Lecture 1 - Lexical Analysis.ppt
Lecture 1 - Lexical Analysis.pptLecture 1 - Lexical Analysis.ppt
Lecture 1 - Lexical Analysis.ppt
NderituGichuki1
 
Automata theory - CFG and normal forms
Automata theory - CFG and normal formsAutomata theory - CFG and normal forms
Automata theory - CFG and normal forms
Akila Krishnamoorthy
 
Compiler unit 2&3
Compiler unit 2&3Compiler unit 2&3
Compiler unit 2&3
BBDITM LUCKNOW
 

Similar to Theory of automata and formal language lab manual (20)

Cd2 [autosaved]
Cd2 [autosaved]Cd2 [autosaved]
Cd2 [autosaved]
 
Assignment10
Assignment10Assignment10
Assignment10
 
Top Down Parsing, Predictive Parsing
Top Down Parsing, Predictive ParsingTop Down Parsing, Predictive Parsing
Top Down Parsing, Predictive Parsing
 
Ch06
Ch06Ch06
Ch06
 
Parsing
ParsingParsing
Parsing
 
PARSING.ppt
PARSING.pptPARSING.ppt
PARSING.ppt
 
Top down parsing
Top down parsingTop down parsing
Top down parsing
 
3. Syntax Analyzer.pptx
3. Syntax Analyzer.pptx3. Syntax Analyzer.pptx
3. Syntax Analyzer.pptx
 
Syntax analysis
Syntax analysisSyntax analysis
Syntax analysis
 
In the Notes on Programming Language Syntax page, an example par.docx
In the Notes on Programming Language Syntax page, an example par.docxIn the Notes on Programming Language Syntax page, an example par.docx
In the Notes on Programming Language Syntax page, an example par.docx
 
Cs6660 compiler design may june 2016 Answer Key
Cs6660 compiler design may june 2016 Answer KeyCs6660 compiler design may june 2016 Answer Key
Cs6660 compiler design may june 2016 Answer Key
 
Ch4_topdownparser_ngfjgh_ngjfhgfffdddf.PPT
Ch4_topdownparser_ngfjgh_ngjfhgfffdddf.PPTCh4_topdownparser_ngfjgh_ngjfhgfffdddf.PPT
Ch4_topdownparser_ngfjgh_ngjfhgfffdddf.PPT
 
Syntax Analysis.pptx
Syntax Analysis.pptxSyntax Analysis.pptx
Syntax Analysis.pptx
 
Assignment7
Assignment7Assignment7
Assignment7
 
11CS10033.pptx
11CS10033.pptx11CS10033.pptx
11CS10033.pptx
 
LL(1) parsing
LL(1) parsingLL(1) parsing
LL(1) parsing
 
Topic 2_revised.pptx
Topic 2_revised.pptxTopic 2_revised.pptx
Topic 2_revised.pptx
 
Lecture 1 - Lexical Analysis.ppt
Lecture 1 - Lexical Analysis.pptLecture 1 - Lexical Analysis.ppt
Lecture 1 - Lexical Analysis.ppt
 
Automata theory - CFG and normal forms
Automata theory - CFG and normal formsAutomata theory - CFG and normal forms
Automata theory - CFG and normal forms
 
Compiler unit 2&3
Compiler unit 2&3Compiler unit 2&3
Compiler unit 2&3
 

More from Nitesh Dubey

HTML Presentation
HTML  PresentationHTML  Presentation
HTML Presentation
Nitesh Dubey
 
MLApproachToProgramming.ppt
MLApproachToProgramming.pptMLApproachToProgramming.ppt
MLApproachToProgramming.ppt
Nitesh Dubey
 
seminar topic of holography.ppt
seminar topic of holography.pptseminar topic of holography.ppt
seminar topic of holography.ppt
Nitesh Dubey
 
Compiler design.pdf
Compiler design.pdfCompiler design.pdf
Compiler design.pdf
Nitesh Dubey
 
Online shopping ppt
Online shopping pptOnline shopping ppt
Online shopping ppt
Nitesh Dubey
 
Python lab manual all the experiments are available
Python lab manual all the experiments are availablePython lab manual all the experiments are available
Python lab manual all the experiments are available
Nitesh Dubey
 
Web Technology Lab files with practical
Web Technology Lab  files with practicalWeb Technology Lab  files with practical
Web Technology Lab files with practical
Nitesh Dubey
 
Software engineering practical
Software engineering practicalSoftware engineering practical
Software engineering practical
Nitesh Dubey
 
Principal of programming language lab files
Principal of programming language lab files Principal of programming language lab files
Principal of programming language lab files
Nitesh Dubey
 
database management system lab files
database management system lab filesdatabase management system lab files
database management system lab files
Nitesh Dubey
 
design and analysis of algorithm Lab files
design and analysis of algorithm Lab filesdesign and analysis of algorithm Lab files
design and analysis of algorithm Lab files
Nitesh Dubey
 
Computer Organization And Architecture lab manual
Computer Organization And Architecture lab manualComputer Organization And Architecture lab manual
Computer Organization And Architecture lab manual
Nitesh Dubey
 
industrial training report on Ethical hacking
industrial training report on Ethical hackingindustrial training report on Ethical hacking
industrial training report on Ethical hacking
Nitesh Dubey
 
Project synopsis on face recognition in e attendance
Project synopsis on face recognition in e attendanceProject synopsis on face recognition in e attendance
Project synopsis on face recognition in e attendance
Nitesh Dubey
 
Hrms industrial training report
Hrms industrial training reportHrms industrial training report
Hrms industrial training report
Nitesh Dubey
 
Industrial training report on core java
Industrial training report on core java Industrial training report on core java
Industrial training report on core java
Nitesh Dubey
 
SEWAGE TREATMENT PLANT mini project report
SEWAGE TREATMENT PLANT mini project reportSEWAGE TREATMENT PLANT mini project report
SEWAGE TREATMENT PLANT mini project report
Nitesh Dubey
 
synopsis report on BIOMETRIC ONLINE VOTING SYSTEM
synopsis report on BIOMETRIC ONLINE VOTING SYSTEMsynopsis report on BIOMETRIC ONLINE VOTING SYSTEM
synopsis report on BIOMETRIC ONLINE VOTING SYSTEM
Nitesh Dubey
 
artificial intelligence ppt
artificial intelligence pptartificial intelligence ppt
artificial intelligence ppt
Nitesh Dubey
 
object oriented Programming ppt
object oriented Programming pptobject oriented Programming ppt
object oriented Programming ppt
Nitesh Dubey
 

More from Nitesh Dubey (20)

HTML Presentation
HTML  PresentationHTML  Presentation
HTML Presentation
 
MLApproachToProgramming.ppt
MLApproachToProgramming.pptMLApproachToProgramming.ppt
MLApproachToProgramming.ppt
 
seminar topic of holography.ppt
seminar topic of holography.pptseminar topic of holography.ppt
seminar topic of holography.ppt
 
Compiler design.pdf
Compiler design.pdfCompiler design.pdf
Compiler design.pdf
 
Online shopping ppt
Online shopping pptOnline shopping ppt
Online shopping ppt
 
Python lab manual all the experiments are available
Python lab manual all the experiments are availablePython lab manual all the experiments are available
Python lab manual all the experiments are available
 
Web Technology Lab files with practical
Web Technology Lab  files with practicalWeb Technology Lab  files with practical
Web Technology Lab files with practical
 
Software engineering practical
Software engineering practicalSoftware engineering practical
Software engineering practical
 
Principal of programming language lab files
Principal of programming language lab files Principal of programming language lab files
Principal of programming language lab files
 
database management system lab files
database management system lab filesdatabase management system lab files
database management system lab files
 
design and analysis of algorithm Lab files
design and analysis of algorithm Lab filesdesign and analysis of algorithm Lab files
design and analysis of algorithm Lab files
 
Computer Organization And Architecture lab manual
Computer Organization And Architecture lab manualComputer Organization And Architecture lab manual
Computer Organization And Architecture lab manual
 
industrial training report on Ethical hacking
industrial training report on Ethical hackingindustrial training report on Ethical hacking
industrial training report on Ethical hacking
 
Project synopsis on face recognition in e attendance
Project synopsis on face recognition in e attendanceProject synopsis on face recognition in e attendance
Project synopsis on face recognition in e attendance
 
Hrms industrial training report
Hrms industrial training reportHrms industrial training report
Hrms industrial training report
 
Industrial training report on core java
Industrial training report on core java Industrial training report on core java
Industrial training report on core java
 
SEWAGE TREATMENT PLANT mini project report
SEWAGE TREATMENT PLANT mini project reportSEWAGE TREATMENT PLANT mini project report
SEWAGE TREATMENT PLANT mini project report
 
synopsis report on BIOMETRIC ONLINE VOTING SYSTEM
synopsis report on BIOMETRIC ONLINE VOTING SYSTEMsynopsis report on BIOMETRIC ONLINE VOTING SYSTEM
synopsis report on BIOMETRIC ONLINE VOTING SYSTEM
 
artificial intelligence ppt
artificial intelligence pptartificial intelligence ppt
artificial intelligence ppt
 
object oriented Programming ppt
object oriented Programming pptobject oriented Programming ppt
object oriented Programming ppt
 

Recently uploaded

Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...
Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...
Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...
simrangupta87541
 
Call Girls In Lucknow 🔥 +91-7014168258🔥High Profile Call Girl Lucknow
Call Girls In Lucknow 🔥 +91-7014168258🔥High Profile Call Girl LucknowCall Girls In Lucknow 🔥 +91-7014168258🔥High Profile Call Girl Lucknow
Call Girls In Lucknow 🔥 +91-7014168258🔥High Profile Call Girl Lucknow
yogita singh$A17
 
Butterfly Valves Manufacturer (LBF Series).pdf
Butterfly Valves Manufacturer (LBF Series).pdfButterfly Valves Manufacturer (LBF Series).pdf
Butterfly Valves Manufacturer (LBF Series).pdf
Lubi Valves
 
paper relate Chozhavendhan et al. 2020.pdf
paper relate Chozhavendhan et al. 2020.pdfpaper relate Chozhavendhan et al. 2020.pdf
paper relate Chozhavendhan et al. 2020.pdf
ShurooqTaib
 
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdfAsymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
felixwold
 
Hot Call Girls In Bangalore ✔ 9079923931 ✔ Hi I Am Divya Vip Call Girl Servic...
Hot Call Girls In Bangalore ✔ 9079923931 ✔ Hi I Am Divya Vip Call Girl Servic...Hot Call Girls In Bangalore ✔ 9079923931 ✔ Hi I Am Divya Vip Call Girl Servic...
Hot Call Girls In Bangalore ✔ 9079923931 ✔ Hi I Am Divya Vip Call Girl Servic...
Banerescorts
 
🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...
🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...
🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...
AK47
 
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
DharmaBanothu
 
Kandivali Call Girls ☑ +91-9967584737 ☑ Available Hot Girls Aunty Book Now
Kandivali Call Girls ☑ +91-9967584737 ☑ Available Hot Girls Aunty Book NowKandivali Call Girls ☑ +91-9967584737 ☑ Available Hot Girls Aunty Book Now
Kandivali Call Girls ☑ +91-9967584737 ☑ Available Hot Girls Aunty Book Now
SONALI Batra $A12
 
My Airframe Metallic Design Capability Studies..pdf
My Airframe Metallic Design Capability Studies..pdfMy Airframe Metallic Design Capability Studies..pdf
My Airframe Metallic Design Capability Studies..pdf
Geoffrey Wardle. MSc. MSc. Snr.MAIAA
 
Cuttack Call Girls 💯Call Us 🔝 7374876321 🔝 💃 Independent Female Escort Service
Cuttack Call Girls 💯Call Us 🔝 7374876321 🔝 💃 Independent Female Escort ServiceCuttack Call Girls 💯Call Us 🔝 7374876321 🔝 💃 Independent Female Escort Service
Cuttack Call Girls 💯Call Us 🔝 7374876321 🔝 💃 Independent Female Escort Service
yakranividhrini
 
🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...
🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...
🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...
sonamrawat5631
 
SPICE PARK JUL2024 ( 6,866 SPICE Models )
SPICE PARK JUL2024 ( 6,866 SPICE Models )SPICE PARK JUL2024 ( 6,866 SPICE Models )
SPICE PARK JUL2024 ( 6,866 SPICE Models )
Tsuyoshi Horigome
 
❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...
❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...
❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...
nainakaoornoida
 
MODULE 5 BIOLOGY FOR ENGINEERS TRENDS IN BIO ENGINEERING.pptx
MODULE 5 BIOLOGY FOR ENGINEERS TRENDS IN BIO ENGINEERING.pptxMODULE 5 BIOLOGY FOR ENGINEERS TRENDS IN BIO ENGINEERING.pptx
MODULE 5 BIOLOGY FOR ENGINEERS TRENDS IN BIO ENGINEERING.pptx
NaveenNaveen726446
 
Particle Swarm Optimization–Long Short-Term Memory based Channel Estimation w...
Particle Swarm Optimization–Long Short-Term Memory based Channel Estimation w...Particle Swarm Optimization–Long Short-Term Memory based Channel Estimation w...
Particle Swarm Optimization–Long Short-Term Memory based Channel Estimation w...
IJCNCJournal
 
CSP_Study - Notes (Paul McNeill) 2017.pdf
CSP_Study - Notes (Paul McNeill) 2017.pdfCSP_Study - Notes (Paul McNeill) 2017.pdf
CSP_Study - Notes (Paul McNeill) 2017.pdf
Ismail Sultan
 
Better Builder Magazine, Issue 49 / Spring 2024
Better Builder Magazine, Issue 49 / Spring 2024Better Builder Magazine, Issue 49 / Spring 2024
Better Builder Magazine, Issue 49 / Spring 2024
Better Builder Magazine
 
Sachpazis_Consolidation Settlement Calculation Program-The Python Code and th...
Sachpazis_Consolidation Settlement Calculation Program-The Python Code and th...Sachpazis_Consolidation Settlement Calculation Program-The Python Code and th...
Sachpazis_Consolidation Settlement Calculation Program-The Python Code and th...
Dr.Costas Sachpazis
 
Call Girls Goa (india) ☎️ +91-7426014248 Goa Call Girl
Call Girls Goa (india) ☎️ +91-7426014248 Goa Call GirlCall Girls Goa (india) ☎️ +91-7426014248 Goa Call Girl
Call Girls Goa (india) ☎️ +91-7426014248 Goa Call Girl
sapna sharmap11
 

Recently uploaded (20)

Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...
Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...
Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...
 
Call Girls In Lucknow 🔥 +91-7014168258🔥High Profile Call Girl Lucknow
Call Girls In Lucknow 🔥 +91-7014168258🔥High Profile Call Girl LucknowCall Girls In Lucknow 🔥 +91-7014168258🔥High Profile Call Girl Lucknow
Call Girls In Lucknow 🔥 +91-7014168258🔥High Profile Call Girl Lucknow
 
Butterfly Valves Manufacturer (LBF Series).pdf
Butterfly Valves Manufacturer (LBF Series).pdfButterfly Valves Manufacturer (LBF Series).pdf
Butterfly Valves Manufacturer (LBF Series).pdf
 
paper relate Chozhavendhan et al. 2020.pdf
paper relate Chozhavendhan et al. 2020.pdfpaper relate Chozhavendhan et al. 2020.pdf
paper relate Chozhavendhan et al. 2020.pdf
 
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdfAsymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
 
Hot Call Girls In Bangalore ✔ 9079923931 ✔ Hi I Am Divya Vip Call Girl Servic...
Hot Call Girls In Bangalore ✔ 9079923931 ✔ Hi I Am Divya Vip Call Girl Servic...Hot Call Girls In Bangalore ✔ 9079923931 ✔ Hi I Am Divya Vip Call Girl Servic...
Hot Call Girls In Bangalore ✔ 9079923931 ✔ Hi I Am Divya Vip Call Girl Servic...
 
🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...
🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...
🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...
 
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
 
Kandivali Call Girls ☑ +91-9967584737 ☑ Available Hot Girls Aunty Book Now
Kandivali Call Girls ☑ +91-9967584737 ☑ Available Hot Girls Aunty Book NowKandivali Call Girls ☑ +91-9967584737 ☑ Available Hot Girls Aunty Book Now
Kandivali Call Girls ☑ +91-9967584737 ☑ Available Hot Girls Aunty Book Now
 
My Airframe Metallic Design Capability Studies..pdf
My Airframe Metallic Design Capability Studies..pdfMy Airframe Metallic Design Capability Studies..pdf
My Airframe Metallic Design Capability Studies..pdf
 
Cuttack Call Girls 💯Call Us 🔝 7374876321 🔝 💃 Independent Female Escort Service
Cuttack Call Girls 💯Call Us 🔝 7374876321 🔝 💃 Independent Female Escort ServiceCuttack Call Girls 💯Call Us 🔝 7374876321 🔝 💃 Independent Female Escort Service
Cuttack Call Girls 💯Call Us 🔝 7374876321 🔝 💃 Independent Female Escort Service
 
🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...
🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...
🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...
 
SPICE PARK JUL2024 ( 6,866 SPICE Models )
SPICE PARK JUL2024 ( 6,866 SPICE Models )SPICE PARK JUL2024 ( 6,866 SPICE Models )
SPICE PARK JUL2024 ( 6,866 SPICE Models )
 
❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...
❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...
❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...
 
MODULE 5 BIOLOGY FOR ENGINEERS TRENDS IN BIO ENGINEERING.pptx
MODULE 5 BIOLOGY FOR ENGINEERS TRENDS IN BIO ENGINEERING.pptxMODULE 5 BIOLOGY FOR ENGINEERS TRENDS IN BIO ENGINEERING.pptx
MODULE 5 BIOLOGY FOR ENGINEERS TRENDS IN BIO ENGINEERING.pptx
 
Particle Swarm Optimization–Long Short-Term Memory based Channel Estimation w...
Particle Swarm Optimization–Long Short-Term Memory based Channel Estimation w...Particle Swarm Optimization–Long Short-Term Memory based Channel Estimation w...
Particle Swarm Optimization–Long Short-Term Memory based Channel Estimation w...
 
CSP_Study - Notes (Paul McNeill) 2017.pdf
CSP_Study - Notes (Paul McNeill) 2017.pdfCSP_Study - Notes (Paul McNeill) 2017.pdf
CSP_Study - Notes (Paul McNeill) 2017.pdf
 
Better Builder Magazine, Issue 49 / Spring 2024
Better Builder Magazine, Issue 49 / Spring 2024Better Builder Magazine, Issue 49 / Spring 2024
Better Builder Magazine, Issue 49 / Spring 2024
 
Sachpazis_Consolidation Settlement Calculation Program-The Python Code and th...
Sachpazis_Consolidation Settlement Calculation Program-The Python Code and th...Sachpazis_Consolidation Settlement Calculation Program-The Python Code and th...
Sachpazis_Consolidation Settlement Calculation Program-The Python Code and th...
 
Call Girls Goa (india) ☎️ +91-7426014248 Goa Call Girl
Call Girls Goa (india) ☎️ +91-7426014248 Goa Call GirlCall Girls Goa (india) ☎️ +91-7426014248 Goa Call Girl
Call Girls Goa (india) ☎️ +91-7426014248 Goa Call Girl
 

Theory of automata and formal language lab manual

  • 1. EXPERIMENT NO:1 TITLE: LEXICAL ANALYZER To find out a given string is an identifier or not. OUTLINE: Identifier is an entity which starts from a letter and then it can contain both letters and digit, any other special character is not allowed in the identifier. While checking for identifier we normally use DFA as it is done in lexical analysis state which works with regular grammar. DFA for identifier consists of three states first state is accepting only letters and then moving to second state when it got a letter. Second state can accept both letters and digits and comeback to itself when it got one. Second state can also accept terminating symbol (delimiter) which lead it to third state which identifies it as an identifier. ALGORITHM: Step 1. Start Step 2. Check if the first char is a letter goto step 3 with rest of the string else goto 5. Step 3. Check if the first character of the given string is a letter or a digit repeat step 3 with rest of the string else goto step 5. Step 4. Print “The given string is an identifier” and goto step 6. Step 5. Print “The given string is not an identifier”. Step 6. Exit OUTPUT: Enter the desired String: a123 The given string is an identifier ………………………………………………. Enter the desired String: shailesh The given string is an identifier …………………………………………….. Enter the desired String: 1asd The given string is not an identifier …………………………………………….. Enter the desired String: as-*l The given string is not an identifier
  • 2. EXPERIMENT NO :2 TITLE: DFA SIMULATION Write a program for acceptance of a string using a given DFA. OUTLINE: A DFA is an acceptor that, for any state and input character, has at most one transition state that the acceptor changes to. A Deterministic Finite Automata M involves the following components: ■ A list of states ■ A set of alphabet letters ■ A set of transition functions ■ A start state ■ A set of final states The program reads the description (listed above) of the machine M. It then reads in a set of input strings (interactively) and determines whether or not a particular string is acceptable by the machine. OUTPUT: No. of states in DFA are:3 No. of final states in DFA are:1 Enter state number(s) of final states(s):2 No. of characters you are using in DFA are:2 Enter those characters one by one: a b Describe your DFA If char ‘A’ is output from state i to state j then write j at combination of i & ‘A’ 1) Enter the string to be tested: aab Valid string 2) Enter the string to be tested: abab Error!!! Invalid string TITLE: LEXICAL ANALYZER To write a program for dividing the given input program into lexemes. OUTLINE: lexical analysis is the process of converting a sequence of characters into a sequence of tokens. A program or function which performs lexical analysis is called a lexical analyzer, or lexer.
  • 3. ALGORITHM: Step 1: start Step 2: Read the file and open the file as read mode. Step 3: Read the string for tokens identifiers, variables. Step 4: take parenthesis also a token. Step 5: parse the string Step 6: stop. OUTPUT: Enter the input: void main() { } ^Z Lexeme Token …………………………………………………………… void Keyword main Function ( parenthesis ) parenthesis { Braces } Braces
  • 4. EXPERIMENT NO :3 TITLE: A program to check the string of a given grammar. OUTLINE: A grammar consists of a finite nonempty set of rules or productions which specify the syntax of the language. In the context of lexical analysis the rules are known as lexical rules. Otherwise, the rules are meant for production rules or syntactical rules. For a given grammar, the program reads a string as input. In a simple derivation process the given string is parsed on a top-down manner. ALGORITHM: Step 1: start Step 2: Read the file and open the file as read mode. Step 3: Read the string for tokens identifiers, variables. Step 4: take parenthesis also a token. Step 5: parse the string Step 6: stop. OUTPUT: The given grammar is: S->aS, S->Sb, S->ab Enter the string to be checked: aaabb The string accepted Enter the string to be checked: abaab The string does not belong to the specified grammar Enter the string to be checked: baaa The string does not belong to the specified grammar TITLE: CFG Program to eliminate left-recursion from a context-free grammar. OUTLINE: A grammar G is said to be left-recursive if it has a non-terminal A such that there is a derivation A => Aa for some a. A left-recursive grammar can cause a top -down parser to go into an infinite loop i.e. when try to expand A, you may eventually find yourself again trying
  • 5. to expand A without having consumed any input. Consider the grammar: A–> Aa | b is a general form of immediate left-recursive grammar. To eliminate left-recursion you have to replace the grammar by the following pair of production rules: A–> bA’ A’–> aA | ALGORITHM: 1. Arrange the NTs into some order A1, A2, …, An 2. for i ¬ 1 to n do begin for j¬ 1 to i-1 do replace each production Ai ® Aj g by the productions Ai ® d1 g ½d2 g½¼½dk g, where Ai® d1 ½d2½¼½dk are all the current productions for Aj eliminate any immediate left recursion among the Ai -productions end OUTPUT: Enter no. of production are:6 Enter production: E->E+T E->T T->T*F T->F F->(E) F->id production after left recursion are: E->TU U->+TU U-># T->FV V->*FV V-># F->(E) F->id
  • 6. EXPERIMENT NO :4 TITLE: TOP-DOWN PARSING Recursive-descent parsing: To write a program on recursive descendent parsing. OUTLINE: A parser that uses a set of recursive procedures to recognize its input by performing syntax analysis with no backtracking is called a recursive-descent parser. It works in a top-down fashion. Consider the following grammar that is suitable for non-backtracking recursive-descent parsing: E–> TE’ E’–> +TE’ | T–> FT’ T’–> *FT’ | F–> (E) | id ALGORITHM: Step 1: start. Step 2: Declare the prototype functions E() , EP(),T(), TP(),F() Step 3: Read the string to be parsed. Step 4: Check the productions Step 5: Compare the terminals and Non-terminals Step 6: Read the parse string. Step 7: stop the production OUTPUT: The given grammar is: E–> TE’, E’–> +TE’ |@, T–> FT’, T’–> *FT’ |@, F–> (E) | id Enter the expression to be parsed: id + id * id The string is parsed. The given grammar is: E–> TE’, E’–> +TE’ |@, T–> FT’, T’–> *FT’ |@, F–> (E) | id Enter the expression to be parsed: id + id *+ id The string is not parsed
  • 7. EXPERIMENT NO :5 TITLE: IMPLEMENTATION OF PREDICTIVE PARSING  Write a code to compute the FIRST, and FOLLOW for all non-terminals.  Write a code to build LL(1) Parsing table for the given grammar. OUTLINE: Consider the grammar, G E -> T E’ E’ -> + T E’ | ε T -> F T’ T’ -> * F T’ | ε F -> ( E ) | id The construction of a predictive parser is aided by two functions associated with a grammar G. These functions, FIRST and FOLLOW, allow us to fill in the entries of a predictive parsing table for G, whenever possible. ALGORITHM: Computing FIRST sets: To compute FIRST(X) for all grammar symbols X, apply the following rules until no more terminals or ε can be added to any FIRST set. 1. if X is terminal, then FIRST(X) is {X}. 2. if X is non-terminal and X-> aα is a production, then add a to FIRST(X). if X-> ε to FIRST(X). 3. if -> Y1,Y2,…….Yk is a production, then for all i such that all of Y1,….Yi-1 are non- terminals and FIRST(Yj) contains ε for j=1,2,…… i-1, add every non- ε symbol in FIRST(Y1) to FIRST(x). if V is in FIRST(Yj) for j=1,2,………k, then add ε to FIRST(X). Computing FOLLOW sets: To compute FOLLOW(A) for all non-terminals A, apply the following rules until nothing can be added to any 1. Place $ in FOLLOW(S), where S is the start symbol and $ is the input right end marker. 2. If there is a production A –> aBb , then everything in FIRST(b), except for ε, is placed in FOLLOW(B).
  • 8. 3. If there is a production A –> aB, or a production A –> aBb where FIRST(b) contains ε (i.e., b =>* ε), then everything in FOLLOW(A) is in FOLLOW(B). Constructing Parsing Table: To construct a parsing table M[A, a] for a grammar G is very simple. Here M[A, a] is a 2- dimensional array. 1. For each production A–> a of the grammar, do steps 2 and 3. 2. For each terminal a in FIRST(a), add A–> a to M[A, a]. 3. If ε is in FIRST(a) and $ is in FOLLOW(A), add A–> a to M[A, $]. Make each undefined entry of M error. OUTPUT: Non Terminals : NT1 E NT2 T NT3 F NT4 E’ NT5 T’ Terminals : T1 : + T2 : * T3: ( T4: ) T5: id T6: ε Productions : Production No 1 E->T E’ Production No 2 E’->+ T E’ Production No 3 T->F T’ Production No 4 T’->* F T’ Production No 5 F->( E ) Production No 6 F->id
  • 9. Production No 7 E’->ε Production No 8 T’->ε First of all Non Terminal FIRST( E ) = { (, id } FIRST( T ) = { (, id } FIRST( F ) = { (, id } FIRST( E’ ) = { +, ε } FIRST( T’ ) = { *, ε } Follow of all Non Terminal FOLLOW( E ) = { $, ) } FOLLOW( T ) = { +, $, ) } FOLLOW( F ) = { *, +, $, ) } FOLLOW( E’ ) = { $, ) } FOLLOW( T’ ) = { +, $, ) }
  • 10. EXPERIMENT NO :6 TITLE: BOTTOM-UP PARSING Program to show the implementation of Shift-Reduce Parser. OUTLINE: Shift-reduce parsing attempts to construct a parse tree for an input string beginning at the leaves (the bottom) and working up towards the root (the top). At each reduction step a particular substring matching the right side of a production is replaced by the symbol on the left of that production, and if the substring is chosen correctly at each step, a rightmost derivation is traced out in reverse. In general, this parsing strategy is non-deterministic. Non-determinism can arise if there are two productions such that the RHS of one of them is a prefix of the RHS of the other, i.e., if there are different productions A → α, B → αβ with α ∈ (VN ∪ VT )and β ∈ ∈ (VN ∪ VT )*. Implementation:  To implement shift-reduce parser, use a stack to hold grammar symbols and an input buffer to hold the string w to be parsed.  Use $ to mark the bottom of the stack and also the right end of the input.  Initially the stack is empty, and the string w is on the input, as follows: Stack Input $ w $  The parser operates by shifting zero or more input symbols onto the stack until a handle β is on top of the stack.  The parser then reduces β to the left side of the appropriate production.  The parser repeats this cycle until it has detected an error or until the stack contains the start symbol and the input is empty: Stack Input $S $  After entering this configuration, the parser halts and announces successful completion of parsing.  There are four possible actions that a shift-reduce parser can make:1) shift 2) reduce 3) accept 4) error. 1. In a shift action, the next symbol is shifted onto the top of the stack. 2. In a reduce action, the parser knows the right end of the handle is at the top of the stack. It must then locate the left end of the handle within the stack and decide with what non-terminal to replace the handle. 3. In an accept action, the parser announces successful completion of parsing.
  • 11. 4. In an error action, the parser discovers that a syntax error has occurred and calls an error recovery routine. · Note: an important fact that justifies the use of a stack in shift-reduce parsing: the handle will always appear on top of the stack, and never inside OUTPUT: SHIFT REDUCE PARSER GRAMMAR E–> E + E E–> E / E E–> E * E E–> E | ε E–> a | b Enter the string: a + b Stack Implementation table —————————————————————————————— Stack Input symbol Action ——————————————————————————————- $ a + b$ —– $a +b$ shift a $E +b$ E–> a $E+ b$ shift + $E + b $ shift b $E + E $ E–> b $E $ E–> E + E $E $ ACCEPT
  • 12. TITLE: INTERMEDIATE CODE GENERATION Program to generate the intermediate code in the form of Polish notation. OUTLINE: Polish notation, also known as Polish prefix notation or simply prefix notation, is a form of notation for logic, arithmetic, and algebra. Its distinguishing feature is that it places operators to the left of their operands. When Polish notation is used as a syntax for mathematical expressions by compiler of programming languages, it is readily parsed into abstract syntax trees and can, in fact, define a one-to-one representation for the same. ALGORITHM: begin Create OperandStack; Create OperatorStack; while( not an empty input expression ) read next token from the input expression if ( token is an operand ) OperandStack.Push (token); endif else if ( token is ‘(‘ or OperatorStack.IsEmpty() or OperatorHierarchy(token) >_ OperatorHierarchy(OperatorStack.Top()) ) OperatorStack.Push ( token ); endif else if( token is ‘)’ ) while( OperatorStack.Top()!='(‘ ) OperatorStack.Pop(operator); OperandStack.Pop(RightOperand); OperandStack.Pop(LeftOperand); operand = operator + LeftOperand + RightOperand;
  • 13. OperandStack.Push(operand); endwhile OperatorStack.Pop(operator); endif else if( operator hierarchy of token is less than or equal to hierarchy of top of the operator stack ) while( !OperatorStack.IsEmpty() and_ OperatorHierarchy(token)<=OperatorHierarchy(OperatorStack.Top()) ) OperatorStack.Pop(operator); OperandStack.Pop(RightOperand); OperandStack.Pop(LeftOperand); operand = operator + LeftOperand + RightOperand; OperandStack.Push(operand); endwhile OperatorStack.Push(token); endif endwhile while( !OperatorStack.IsEmpty() ) OperatorStack.Pop(operator); OperandStack.Pop(RightOperand); OperandStack.Pop(LeftOperand); operand = operator + LeftOperand + RightOperand; OperandStack.Push(operand) ; endwhile // Save the prefix expression at the top of the operand stack followed by popping // the operand stack. print OperandStack.Top(); OperandStack.Pop();
  • 14. End OUTPUT: Enter an input in the form of expression: (a+b)*(c-d) The polish notation is: *+ab-cd Enter an input in the form of expression: (a–b)/c*(d + e – f / g)
  • 15. EXPERIMENT NO :7 TITLE: ITERMEDIATE CODE GENERATION Program for generating for various intermediate code form: · Three address code · Quadruple OUTLINE: Three address code is a sequence of statements of the form x = y op z . Since a statement involves no more than three references, it is called a “three-address statement,” and a sequence of such statements is referred to as three-address code. For example, the three-address code for the expression a + b * c + d is: Sometimes a statement might contain less than three references; but it is still called a three- address statement. Representing three-address statements: Records with fields for the operators and operands can be used to represent three-address statements. It is possible to use a record structure with four fields: the first holds the operator, the next two hold the operand1 and operand2, respectively, and the last one holds the result. This representation of a three-address statement is called a “quadruple representation”. Using quadruple representation, the three-address statement x = y op z is represented by placing op in the operator field, y in the operand1 field, z in the operand2 field, and x in the result field. OP ARG1 ARG2 RESULT 0 + a B T1 1 + c D T2 2 * T1 T2 T3
  • 16. OUTPUT: Enter The Expression: a=b+c*d/e; THREE ADDRESS CODE B:= d / e C:= c * B D:= b + B E:= a = B QUADRUPLES ID OP OPERAND 1 OPERAND2 RESULT (0) / d e B (1) * c B C (2) + b B D (3) = a B E
  • 17. EXPERIMENT NO :8 This program is to find out whether a given string is a identifier or not. #include<stdio.h> #include<conio.h> int isiden(char*); int second(char*); int third(); void main() { char *str; int i = -1; clrscr(); printf(“nnttEnter the desired String: “); /*do { ++i; str[i] = getch(); if(str[i]!=10 && str[i]!=13) printf(“%c”,str[i]); if(str[i] == ‘b’) { –i; printf(” b”); } }while(str[i] != 10 && str[i] != 13); */ gets(str);
  • 18. if(isident(str)) printf(“nnttThe given strig is an identifier”); else printf(“nnttThe given string is not an identifier”); getch(); } //To Check whether the given string is identifier or not //This function acts like first stage of dfa int isident(char *str) { if((str[0]>=’a’ && str[0]<=’z’) || (str[0]>=’A’ && str[0]<=’Z’)) { return(second(str+1)); } else return 0; } //This function acts as second stage of dfa int second(char *str) { if((str[0]>=’0′ && str[0]<=’9′) || (str[0]>=’a’ && str[0]<=’z’) || (str[0]>=’A’ && str[0]<=’Z’)) { return(second(str+1)); //Implementing the loop from second stage to second stage } else { if(str[0] == 10 || str[0] == 13) { return(third(str));
  • 19. } else { return 0; } } } //This function acts as third stage of dfa int third() { return 1; //Being final stage reaching it mean the string is identified }
  • 20. EXPERIMENT NO :10 Write a program to simulate a machine known as the Deterministic Finite Automata (DFA). PROGRAM: #include<iostream.h> #include<conio.h> #include<process.h> #include<string.h> class p_dfa { int n,n1,n2,final[10],fa[10][10]; char ch[10],*str; public: void accept(); void dfa(char*); }; void p_dfa::accept() { int i,j; cout << endl << “No. of states in DFA are:”; cin >> n; cout << endl << “No. of final states in DFA are:”; cin >> n1; cout << endl << “Enter state number(s) of final states(s):”; for(i=0;i<n1;i++) cin >> final[i]; cout << endl << “No. of characters you are using in DFA are:”;
  • 21. cin >> n2; cout << endl << “Enter those characters one by one:” << endl; for(i=0;i<n2;i++) cin >> ch[i]; cout << endl << “Describe your DFA” << endl; cout << endl << “If char ‘A’ is output from stayte i to state j”; cout << endl << “then write j at combination of i & ‘A'” << endl; for(i=0;i<n2;i++) cout << “t” << ch[i]; cout << endl; for(i=0;i<n;i++) { cout << i << “t”; for(j=0;j<n2;j++) cin >> fa[i][j]; } cout << endl << “Enter the string to be tested:”; cin >> str; dfa(str); } void p_dfa::dfa(char *str) { int i,j,len,state=0,flag; char c; len = strlen(str); for(i=0;i<len;i++) { c = str[i];
  • 22. for(j=0;j<n2;j++) { if(c == ch[j]) { if(fa[state][j] != 0) { } else { state = fa[state][j]; break; cout << endl << “Error!!!”; cout << endl << “Invalid string”; } } flag=0; exit(0); } } for(i=0;i<n1;i++) if(state == final[i]) { cout << endl << “Valid string”; flag=1; }
  • 23. if(flag=0) cout << endl << “Invalid string (Final state never obtained)!!!”; } void main() { p_dfa d; clrscr(); d.accept(); getch(); }
  • 24. INDEX S.no Practical Signature Remark 1 2 3 4 5-a 5-b 6 7 8 To find out a given string is an identifier or not. Write a program for acceptance of a string using a given DFA. A program to check the string of a given grammar. Recursive-descent parsing: To write a program on recursive descendent parsing. • Write a code to compute the FIRST, and FOLLOW for all non-terminals. • Write a code to build LL(1) Parsing table for the given grammar. Program to show the implementation of Shift- Reduce Parser. Program for generating for various intermediate code form: • Three address code • Quadruple This program is to find out whether a given string is a identifier or not.
  翻译: