home *** CD-ROM | disk | FTP | other *** search
- {MAIN3.PAS}
-
- Program ParseEngine;
-
- {
- Description: Main program for demonstration of parsing Pascal source
- Author: Karl Gerhard
- Date: 7/25/87
- Application: IBM PC and compatibles
- }
-
- {$R+}
- CONST
- grammar_name = 'grammar3.pas';
- input_name = 'input3.pas';
- log_name = 'log.pas';
- stackmax = 250;
- input_max = 10000;
-
- TYPE
- stdstr = string[250];
- stack_type = string[stackmax];
- input_array_type = array[1..input_max] of char;
-
- VAR
- input_array : input_array_type;
- grammar : array[1..100] of stdstr;
- plevel,token_ptr,input_line,v_length, input_length, gr_length : integer;
- FLOG,FN : text;
- FIN : file;
- statement, the_token : stdstr;
- parts_of_speech : stdstr;
-
- {$i debug logging routines }
- {$i strlib3 string functions }
- {$i parslib3 parser itself }
- {$i parse3 parser itself }
- {$i textrd3 read input }
-
- BEGIN { --- Program Main ---- }
- assign(FLOG,log_name);
- rewrite(FLOG);
-
- { read grammar }
- assign(FN,grammar_name);
- reset(FN);
- gr_length := 0;
- while not eof(FN) do begin
- gr_length := gr_length + 1;
- readln(FN,grammar[gr_length]);
- end;
- close(FN);
-
- assign(FIN,input_name);
- textblockread(input_array,FIN);
-
- clrscr;
- writeln(' PARSER Part 3 kpg 7/14/87');
-
- { parse statement }
- window(10,4,80,22); gotoxy(1,1);
- token_ptr := 1;
- the_token := getoken;
- if parse(1, 'START') then writeln(' GO')
- else writeln(' Parse failed.');
- logging(' == End of ',' run');
- close(FLOG);
- window(1,1,80,25); gotoxy(20,24);
- write(' Enter to continue or BRK (Log is saved)'); readln(statement);
-
- close(FIN);
- writeln; writeln(' End of Demo');
- END.
- {***}
-