Download presentation
Presentation is loading. Please wait.
1
1 Programming Problem 1
2
2 The problem l Implement a program that »converts a regular expression into an NFA, »converts the NFA into a DFA, and »minimizes the DFA. l The work of the program is to execute the minimized DFA on a number of strings. »For each string, it should print the list of states the minimized DFA goes through, and then print either "accept" or "reject".
3
3 l Should use the support software provided in the URL : http://xml.cs.nccu.edu.tw/courses/compiler/cp2002Fall/pro blems/problem1/problem1.zip »The only code you should need to modify is the FA.java file. »You will be using Java class libraries from Java 1.4.0 or above.
4
4 Files in problem1.zip
5
5 l tools/java_cup/** l tools/JLex/** l prob1/** »files you should look at. »FA.java The main program »test*.in- Test case inputs »test*.log- Results of running your program on test inputs »test*.out- Results demonstrating correct operation »goAll.bat - Script to compile everything from scratch »goTest.bat - Script to run DFA minimizer on test input files »prob1/api –html doc for FA.java l Files you don't have to worry about »re.lex –The scanner specification for regular expressions. »re.cup –The grammar specification for regular expressions. »Yylex.java –Code produced by scanner generator (JLex). »sym.java,parser.java –Code generated by parser generator (CUP).
6
6
7
7 How to complete your 1 st assignment l down the file problem1.zip l unzip problem1.zip to a directory (ex: C:\compiler\problems\problem1 ) 1. the required tools will then be installed at »C:\compiler\problems\problem1\tools 2. and the support files installed at »C:\compiler\problems\problem1\prob1 l overwrite the 7 methods : »union(), concat(), and closure(). // regExpr NFA »move(), epsilon-closure(), NFA2DFA // NFA DFA »minimize() // DFA minimization listed in the FA class of the file FA.java.
8
8 How to complete your 1 st assignment > cd C:\compiler\problems\problem1\prob1 > goAll.bat >goTest l Notes: »can write additional functions/methods for FA.java »compile/build your DFA using the script "goAll.bat“ »test your result by using the script "goTest.bat". The script will test the DFA on some input files, putting the output in log files. »compare your results test*.log with the expected ones test*.out. Note: *.log and *.out need not be identical literally. for minimized DFA, *.log and.out should have the same numbers of states and accept the same inputs.
9
9 Format of the output ------NFA // or DFA or minimized DFA Transition Graph 0: a -> 1 // state 0, edge from 0 to 1 (on 'a') 1: epsilon -> 2 // state 1, edge from 1 to 2 (on empty str) 2: epsilon -> 3, b -> 1 // state 2, edges from 2 to 3 & 1 (on e, 'b') 3: // state 3, no edges start state: 0 final states: { 3 } alphabet: { b,a }
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.