Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
26Activity
0 of .
Results for:
No results containing your search query
P. 1
Modul Peraktikum Teknik Kompilasi III

Modul Peraktikum Teknik Kompilasi III

Ratings: (0)|Views: 1,167 |Likes:
Published by cyberjack30

More info:

Published by: cyberjack30 on Jan 18, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

07/03/2013

pdf

text

original

 
 Modul Peraktikum MTBTeknik Kompilasi (T.Informatika)
MODUL PERAKTIKUM TEKNIK KOMPILASI III
PROGRAM SCANNER LANJUT (KOMPLEKS)*****************************************************
Program dibawah ini merupakan program PARSER sederhana dengan caraRecursive Descent untuk sebuah bahasa yang memiliki tata bahasa (memakai UnitScanner pada Modul Peraktikum Teknik Kompilasi I).
PROGRAM PARSER;USES CRT, SCANNER;vAR IS_ANY_ERROR : BOOLEAN;PROCEDURE EXP_PROC ; FORWARD;PROCEDURE VAR_PROC; FORWARD;PROCEDURE TERM_PROC; FORWARD;PROCEDURE FACT_PROC; FORWARD;PROCEDURE FACTOR_PROC; FORWARD;PROCEDURE ERROR_REPORTING(ID : BYTE);BEGINIS_ANY_ERROR := TRUE;CASE ID OF1 : WRITELN('''THEN'' EXPECTED');2 : WRITELN(''':='' EXPECTED');3 : WRITELN('''IDENTIFIER'' EXPECTED');4 : WRITELN(''']'' EXPECTED');5 : WRITELN(''')'' EXPECTED');END;WRITELN('LINE : ',LINENUMBER);END;PROCEDURE STAT_PROC;BEGINIF TOKEN = T_IF THENBEGINSCAN;EXP_PROC;IF TOKEN <> T_THEN THENERROR_REPORTING(1)ELSEBEGINSCAN;STAT_PROC;IF TOKEN = T_ELSE THENBEGINSCAN;STAT_PROC;ENDEND;
 
 Modul Peraktikum MTBTeknik Kompilasi (T.Informatika)
ENDELSEBEGINVAR_PROC;IF TOKEN <> T_ASSIGN THENERROR_REPORTING(2)ELSEBEGINSCAN;EXP_PROC;END;END;END;PROCEDURE VAR_PROC;BEGINIF TOKEN <> T_ID THENERROR_REPORTING(3)ELSEBEGINSCAN;IF TOKEN = T_LBRACK THENBEGINSCAN;EXP_PROC;IF TOKEN <> T_RBRACK THENERROR_REPORTING(4)ELSESCAN;END;END;END;PROCEDURE EXP_PROC;BEGINTERM_PROC;WHILE TOKEN IN [T_ADD, T_SUB] DOBEGINSCAN;TERM_PROC;END;END;PROCEDURE TERM_PROC;BEGINFACT_PROC;WHILE TOKEN IN [T_MUL,T_RDIV] DOBEGINSCAN;FACT_PROC;END;END;
 
 Modul Peraktikum MTBTeknik Kompilasi (T.Informatika)
PROCEDURE FACT_PROC;BEGINFACTOR_PROC;WHILE TOKEN = T_DOUBLE_MUL DOBEGINSCAN;FACT_PROC;END;END;PROCEDURE FACTOR_PROC;BEGINIF TOKEN = T_LPARENT THENBEGINSCAN;EXP_PROC;IF TOKEN <> T_RPARENT THENERROR_REPORTING(5)ELSESCAN;ENDELSE IF TOKEN = T_INT THENSCANELSEVAR_PROC;END;BEGINCLRSCR;INITIALIZE;IS_ANY_ERROR := FALSE;SCAN;CLRSCR;STAT_PROC;TERMINATE;IF IS_ANY_ERROR THENWRITELN('PARSING FAIL');WRITELN('PARSING SUCCES');REPEAT UNTIL READKEY = #13END.

Activity (26)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
Arifin January liked this
Arifin January liked this
Sankala Tertawa liked this
Neiyo Deviko liked this
Dodik Krisd liked this
Dodik Krisd liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->