PCD - ALGO
PCD - ALGO
NFA Construction
Aim:
To construct a Non-deterministic Finite Automaton (NFA) for a given
regular expression.
Algorithm:
1. Initialize the transition table.
2. Read the regular expression.
3. Traverse each character:
o Handle a, b, and e transitions.
4. For * and /, apply looping and branching using epsilon.
5. Use state numbers to track transitions.
6. Print the final NFA transition table.
12. LR Parser
Aim:
To simulate a simple LR parsing process.
Algorithm:
1. Read the arithmetic expression.
2. Scan input and shift id as E.
3. Push operators onto stack.
4. Perform reductions using grammar rules.
5. Print stack after each step.
6. Accept if reduced to start symbol.
13. Intermediate Code Generation
Aim:
To generate intermediate (three-address) code from expressions.
Algorithm:
1. Read an arithmetic expression.
2. Identify operators by precedence.
3. Extract left and right operands.
4. Assign temporary variables.
5. Replace original expression with temp results.
6. Print three-address code.