| 1 | #!/usr/local/bin/perl -w | ||
| 2 | |||
| 3 | # A BASIC interpreter. | ||
| 4 | # | ||
| 5 | # Reads in file $ARGV[0] or "program.bas" by default and runs it as a BASIC | ||
| 6 | # program. | ||
| 7 | use strict; | ||
| 8 | use Language::Basic; | ||
| 9 | |||
| 10 | my $Default_Filename = "program.bas"; | ||
| 11 | die "Usage: $0 [filename] - runs BASIC program filename\nRuns $Default_Filename by default\n" unless -e "$Default_Filename" or @ARGV; | ||
| 12 | |||
| 13 | my $Program = new Language::Basic::Program; | ||
| 14 | my $infile = shift || "$Default_Filename"; | ||
| 15 | |||
| 16 | # Read the lines from a file | ||
| 17 | print("Reading program... \n"); | ||
| 18 | $Program->input($infile); | ||
| 19 | |||
| 20 | # Parse the lines | ||
| 21 | print ("Parsing program... \n"); | ||
| 22 | $Program->parse; | ||
| 23 | |||
| 24 | # Implement the program | ||
| 25 | print("Beginning to run the program...\n\n"); | ||
| 26 | $Program->implement; | ||
| 27 | |||
| 28 | print "\n\nDone running the program.\n"; | ||
| 29 | exit(0); |