Problem – Implement a recognizer for pascal identifiers based on a DFA that accepts strings belonging to the definition of the language of the same.
Here is a regular definition for the set of Pascal identifiers that are defined as the set of strings of letters and digits beginning with a letter.
letter : A | B | . . . | Z | a | b | . . . | z digit : 0 | 1 | 2 | . . . | 9 ID : letter (letter | digit)*
The regular expression ID is the pattern for the Pascal identifier token and defines letter and digit where a letter is a regular expression for the set of all upper-case and lowercase letters in the alphabet and digit is regular for the set of all decimal digits.
State diagram of the DFA
Working code for the recognizer:
Geeks : Valid for : Valid Geeks : Valid is : Valid 9ice : Invalid platfo$m : Invalid for : Valid every1 : Valid
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- DFA for exactly one of a and at least one of b
- Church’s Thesis for Turing Machine
- Difference between DFA and NFA
- Design a DFA that every 00 is immediately followed by 1
- Turing Machine to check whether given string is Even Palindrome or not
- Mealy Machine for 1's Complement
- Find all compatable and non compatable edges of a machine
- Design a mealy machine for 2's complement
- Various Properties of context free languages (CFL)
- Optimizing state table of a completely specified machine
- NFA to accept strings that has atleast one character occurring in a multiple of 3
- Conversion of Epsilon-NFA to NFA
- Program to build a DFA to accept strings that start and end with same character
- Program to build a DFA that accepts strings starting and ending with different character
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.