Is anyone here familiar with Pascal?
I'm using it for my Computational Linguistics course. I'm okay with the stuff I've actually been taught and ned to know, but I'm trying to achieve something extra, just for neatness sake.
Basically the program asks the user to input a string of characters and then checks the string against a given 'language' and then accepts or rejects it accordingly.
I've achieved that pretty easily, but the trouble is you have to re-run the program every time you want to try it. I want the program to keep going back to the beginning whenever the string is rejected, with a message saying 'please try again' or something, and then get the program to stop once the user inputs an acceptable string.
Basically I need the program to keep looping until the currentstate is 'A' (accept).
Sounds like it should be easy, but if tried with IF, WHILE and REPEAT statements, and can't seem to get it to work...
Any ideas? Below is the 'Main Program' of the script. I'm pretty sure the commands I need will be inserted here somewhere, but I'm obviously doing something wrong.
Code: ags
If you think it would help to see the whole code, I can provide it, but I'm guessing it's not necessary.
Cheers guys.
I'm using it for my Computational Linguistics course. I'm okay with the stuff I've actually been taught and ned to know, but I'm trying to achieve something extra, just for neatness sake.
Basically the program asks the user to input a string of characters and then checks the string against a given 'language' and then accepts or rejects it accordingly.
I've achieved that pretty easily, but the trouble is you have to re-run the program every time you want to try it. I want the program to keep going back to the beginning whenever the string is rejected, with a message saying 'please try again' or something, and then get the program to stop once the user inputs an acceptable string.
Basically I need the program to keep looping until the currentstate is 'A' (accept).
Sounds like it should be easy, but if tried with IF, WHILE and REPEAT statements, and can't seem to get it to work...
Any ideas? Below is the 'Main Program' of the script. I'm pretty sure the commands I need will be inserted here somewhere, but I'm obviously doing something wrong.
{ *** Main Program *** }
begin
write ('Input a string consisting of the symbols a, b, c, d, and e: ');
readstring (string, stringlength);
process (currentsymbol, currentstate, string, stringlength);
if currentstate = 'A' then
writeln ('String Accepted :-)');
else
writeln ('String Rejected :-(');
end.
If you think it would help to see the whole code, I can provide it, but I'm guessing it's not necessary.
Cheers guys.