The Stimulators Project Readme
*****************************************************************************************
The
following descriptions of our program will thoroughly take the
user through the ways the program works, executing the program, and how to
use
it.
********************************************************************************************
Taget Audience
Our main audience is the students who are novice to the
regular expressions. The purpose of this program is also to serve
as a practice for those who want to improve their understanding of
it.
INTRODUCTION
'myRegs' is a program written in Perl that performs string comparisons based on two pieces of input.
The First input is a regular expression that has to meet certain conditions. Those conditions will be described below.
The second input will be a string or more a 'set of strings'.
'myRegs' is a file written in Perl but has a Makefile that will compile into bytecode. At first, we planned to
compile the code into C code but 'perlcc', which is part of Perl, gave me issues. The command originally used to
compile my code into C code was:
perlcc myRegs.p -o myRegs
This command never allowed us to compile the simplest perl code and so I read up on perldoc perlcc and I used the '-b' switch along with the above command to compile the program into byte code which compiled but coredumped every time after execution of the program completed. I would like to note that this program was only compiled and executed on a OpenBSD 2.8 system and Sun Solaris 8 system.
Files
The files needed needed to use this program by method of compiling are listed below:
Makefile
myRegs.p
With both of these files, you can run the program by typing 'make' from the command prompt. It will compile and
return a file called 'myRegs' and also chmod it to 755 by default. You may change this if you wish in the Makefile. 'myRegs' can be run by typing ./myRegs from the command prompt.
Another way to run the program is to type 'make nonexec' which will not compile the code but only change the modes on the perlfile so you can run it. After typing 'make nonexec', you can run the program by typing './myRegs.p'.
In the case of both methods, some test input files have been provided. The test input files are named test1 to test4.
To use any of these test files, simply provide the name of the file during invoking the 'myRegs' program. An example is provided below.
./myRegs.p < test1 or ./myRegs < test1
depending on how you plan to make the program.
Stratagy used in the program
The strategy that was used in this program was the iteration as a while
loop and for loop. The while loop basically just keeps asking for the
user input until user does provide it. Once the regular expression and the
search string are provided by the user the for loop processes the search
string provided by the user to look for any of the words that would match
the regular expressions. As each word of the string that is matched with
the regular expression, the word is put into an array that contains the
other possible matches of the regular expressions.
General Skills
The general skill that we have applied in this programming project is
actually understanding how the regular expression works and actually go by
writting the program for it to use it in the future.
Top level algorithm in English
In plain English, this program is based on a really simple idea but yet
powerful.
As a student of CS301, I always wondered if a certain string belongs to a
given regular
expression. This program will be of help to students of coming semesters
to use.
The user is able to type in the regular expression of choice, then type
the strings.
The program will read in the regular expression and store it into an
array. After
that is done, the strings are read without spaces and put into a second
array.
Then a loop is used to loop through the strings' array comparing each to
the element
in the first array ( the regular expression ).
For every strings that we find beloging to the regular expression, we
stick into another
array to print it later.
At the end we simply print the third array with all the right entry to the
screen.
The psudocode of the program
The following link will take you to the psuedo_code of our program.
psuedo
The logical blocks of code actually used
while ( !$in ) {
print "Please enter the regular expression you would like to
search
$in = ;
chomp($in);
}
and
if ( $i =~ m/$regexp[0]/ ) {
$counter++;
# will tell the term to print in bold
#print color 'bold blue';
print "$i ";
push(@valids, $i);
# if no matches are found then just print the word
} else {
# will reset it back to normal so the bold is lifted
#print color 'reset';
print "$i ";
}
}
Language used
The language used to write this program is Perl. Since we knew from the
beginnig that we will be using perl as our language, there was nothing
really different than what we planned in the progress report.
Timeline
1) The day group were decided, in a group meeting we decided what the
project will be about
2)The progress report was turned in on the tuesday following the day it
was hand out.
3)daily goup meeting for 20 minutes, in which we discussed the
progress as well as worked on the program piece by piece.
4)Last but not least, test files were developed after couple of meetings
to test the program.
Individual involments in the project
Anoop bhat: Anoop basically sturctured and wrote the code for
this project, as he was the only one in the group who knew Perl.
Parin Variava and Sami Abuhamatto: Parin and Sami basically
worked together to put up the report, test files, testing the project and
somewhat involvement comming up with algorithm of the program.
Each person in the group did every thing that was described in the
progress report, so not much change there.
Line that we are proud of
The one syntex line that we are proud of is as follows:
if ($i=~ m/$rgexp[0])
This command made our program very reliable that we did not need much to
code, as this command does all of the comparison on it's own. This
statement is basically in a loop so what it does is that we don't have to
actually compare leter by leter to see if the regular expression was
matched. Rather this command compares the "strings" of the search phrase
with the regular expression. So, in a way it is like the "strcmpr()"
function in C++.
Test plan
Ths basic test plan that was carried out was to come up with the regular
expressions that will be used to test our program. Some of the tests are
listed below in the test files.
Difficulties
The main difficulty was to come up with the one algorith that would work
for our program, which was faced with spending lot of time after it
thinking and testing out different algorithms.
References used
We used the cs301 text book to come up with the regular expressions to
test our program.
Overall we learned...
Overall we learned how to use regular expression in different forms. The
behavior of the regular expressions and also actually comming up with the
program to implement it in Perl.
Test files
Following are some of the test files that we have used to test our
program. It is not necessery to use those as you can also provide your
own input and test it out.
myRegs.p: This file is where the source code lives.
Makefile: This file is where the instructions to make the program, live.
test1: test1 of 4.
test2: test2 of 4.
test3: test3 of 4.
test4: test4 of 4.
The sample input output of our program
sample
This report and our turned-in code represent our own work and only our
own work. Only people in this class with whom we discussed anything about
this project were the instructor and the TA, or posted on the courseinfo
discussion board.
This members in this group are:
Anoop Bhat
Parin Variava
Sami Abuhamato