Monday, September 26, 2011

0 program scanner dengan pascal

Date: Monday, September 26, 2011 9/26/2011 04:13:00 PM
Category:
Author: Unknown
Share:
Responds: 0 Comment
Listing Program
program Scan;
Uses crt;
Var
x : text;
y : Char;
token,Ttoken : String;

procedure input;
begin
read(x,y);
end;
procedure output;
begin
writeln(token:10,' ',Ttoken);
end;
procedure scan;
begin
clrscr;
assign(x,'contoh.txt');
reset(x);
repeat
input;
if (y in['A'..'Z','a'..'z']) then
begin
repeat
begin
token := token + y;
input;
end;
until (not(y in['A'..'Z','a'..'z']));
Ttoken := 'Tpengenal';
if token = 'Mulai' then
Ttoken := 'Tmulai';
if token = 'Jika' then
Ttoken:='Tjika';
if token='maka' then
Ttoken := 'Tmaka';
if token = 'div' then
Ttoken := 'Tdiv';
if token ='Beda' then
Ttoken := 'Tbeda';
if token ='mod' then
Ttoken :='Tmod';
if token = 'Selesai' then
Ttoken := 'Tselesai';
output;
token := '';
end;
if (y in['0'..'9']) then
begin
repeat
begin
token := token + y;
input;
end;
until (not(y in['0'..'9']));
Ttoken := 'Tbulat';
output;
token := '';
end;
if (y in[':','=',';','.']) then
begin
repeat
begin
token := token + y;
input;
end;
until (not(y in[':','=',';','.']));
if token =':=' then
Ttoken := 'Tmasuk';
if token ='=' then
Ttoken := 'Tsama';
if token ='.' then
Ttoken := 'Ttitik';
if token =';' then
Ttoken := 'Ttkoma';
output;
token := '';
end;

until y = '#';
end;
begin
scan;
readln;
end.

sumber
tinggalin coment ya...

Artikel Terkait :



Post a Comment