This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Friday 2 October 2015

Contoh Analisis Leksikal Pada Java (Tugas Teknik Kompilasi)

Berikut ini merupakan program sederhana yang di buat menggunakan bahasa pemrograman java, dimana program tersebut akan menampilkan kalimat “hello world” pada outputnya. Dibawah ini merupakan source code dari program tersebut :

Codingan program :

Output Program :


Analisis leksikal adalah sebuah proses yang mendahului parsing sebuah rangkaian karakter. Ia menerima masukan serangkaian karakter (seperti dalam dokumen plain-text atau source code) dan menghasilkan deretan simbol yang masing-masing dinamakan token; proses parsing akan lebih mudah dilakukan bila inputnya sudah berupa token.
Token adalah level entitas yang paling rendah dalam diagram sintaks
Jenis-jenis token antara lain:
·         identifiers (contoh variabel & nama fungsidll)
·         keywords (seperti while, if, function, dll)
·         operators (seperti +, -, *, ++, +=, dll)
·         literals (nilai konstanta seperti 27.3, “Hello”, dll)
·         punctuation (seperti ‘;’, ‘:’, ‘,’, dll)

Berikut adalah analisis leksikal dari program sederhana java di atas :
Source code :
package latihan;
public class tugas {
    public static void main(String[ ] args) {
        System.out.println("Hello, World");
    }
}

Token:
latihan, tugas merupakan identifiers
Package, public, class, static, void, main, String, args, System.out.println merupakan keywords
Hello, World merupakan literals
“{“, “}”, “[“,”]”, “(“, “)”, “;” merupakan punctuation