วันพุธที่ 22 มิถุนายน พ.ศ. 2554

Derivation

การพิสูจน์ว่า "ประโยคใดๆเป็นสมาชิกของไวยากรณ์ภาษา G หรือไม่" ใช้หลักการของการกระจายโปรดักชั่น เพื่อผลิตประโยคที่ต้องการตรวจสอบ ซึ่งมีรายละเอียดดังนี้
  1. นำสัญลักษณ์เริ่มต้น(start symbol) S เป็นจุดเริ่มต้นของการกระจายวากยสัมพันธ์ และกำหนดให้สายสัญลักษณ์บนตัวขวามือของโปรดักชั่น S เป็น "สายอักขระก่อกำเนิด" (สายอักขระก่อกำเนิด อาจประกอบด้วย Terminal Symbol หรือ Non-Terminal Symbol)
  2. ดำเนินกิจกรรมกระจายสายอักขระก่อกำเนิด โดยการเลือกโปรดักชั่น A-->aBb ที่สอดคล้องกับสัญลักษณ์ไม่สิ้นสุด A บนสายอักขระก่อกำเนิด เพื่อนำตัวประกอบขวามือของโปรดักชั่นมาแทนที่สัญลักษณ์ A บนสายอักขระก่อกำเนิด
  3. ดำเนินกิจกรรมกระจายสายอักขระจนกระทั่งไม่สามารถนำโปรดักชั่นใดมากระจายสายอักขระได้อีก จากนั้นตรวจสอบว่า สายอักขระที่ถูกผลิดตรงกับประโยคที่นำมาตรวจสอบหรือไม่

Java Thread

Thread เป็นการทำงานพร้อมกันหลายๆงาน เพื่อประมวลผลพร้อมกันได้ ซึ่งในภาษาจาวานั้น จะมี method พิเศษทีชื่อว่า run ในการกำหนดการทำงานของ thread ถ้าเรานำ thread ไปใช้กับโปรแกรมด้าน network ก็จะใช้ในการประมวลผลของ server ที่มีเครื่อง client หลายๆเครื่องพร้อมกัน เมื่อเราเรียกใช้ method run แล้วมันก็จะแยกการทำงานแบบอัตโนมัติ ซึ่งในการเรียกใช้งาน method run นั้นจะต้องเรียกใช้โดย method start และในการใช้งาน thread นั้นจะต้องมีการเรียกใช้ method sleep เพื่อหยุด thread บางตัวเพื่อไม่ให้ทำงานที่ขัดแย้งกัน
public class ThreadShowName extends Thread{
public static void main(String args[]){
ThreadShowName thread1,thread2;
thread1 = new ThreadShowName();
thread2 = new ThreadShowName();
thread1.start();
thread2.start();
}
public void run(){
int pause;
for(int i=0;i<10;i++){
try{
System.out.println(getName()+" being executed.");
pause = (int)(Math.random()*3000);
sleep(pause); //0-3 seconds
}
catch(InterruptedException interruptEx){
System.out.println(interruptEx);
}
}
}
}

วันอาทิตย์ที่ 19 มิถุนายน พ.ศ. 2554

The Lexical Analysis Driver (Scanner)

For lexical analysis , we can consider  the input  source program as a long sequence of characters with two pointers:  a current pointer and a lookahead pointer.

1

When lexical analysis begins to find the next token, current and lookahead both point to the same character:

2

In the algorithm , four actions will be performed on these pointers:

1.GetChar : Moves the lookahead pointer ahead one character and returns.

1

2.Retract : Moves the lookahead pointer back one character.

3

4

3.Accept : Moves the current pointer ahead to the lookahead pointer.

5

4.Return : Returns a token consisting of a class and value , as well as performs any actions associated with that state , e.g., installing an identifier into the name table.

The driver program scans the input program and consults the entry at Table[State,InputChar] for the new state. The entry at Table[State,InputChar] consists of a new state and perhaps an action to be performed before moving to the new state:

Algorithm : Driver for Lexical Analysis

WHILE there is more input

     InputChar := GetChar

     State := Table[0,InputChar]

     WHILE State <> Blank

          InputChar := GetChar

          State := Table[State,InputChar]

     ENDWHILE

     Retract

     Accept

     Return token = (Class,Value)

ENDWHILE

In the algorithm for the lexical analysis driver , retract is neccessary when a token is found because the algorithm will have scanned one character too far.

วันอังคารที่ 14 มิถุนายน พ.ศ. 2554

CWM?

CWM คือตัวอักษรย่อมาจาก Clock Work Mod โดยสำหรับท่านที่กำลังจะเริ่มเล่น CWR สิ่งที่ต้องมีในเครื่องท่านก็คือ MAGLDR 1.13 ในเครื่องก่อน และอีกอันนึงที่สำคัญสำหรับการอัพรอมคือ CWR Partition Size แล้วเราจะรู้ได้ยังไงว่า รอมที่เราจะลงใช้ Partition Size เท่าไหร่ ก็ดูตามนี้เลย หลักๆมันมี 3 แบบ (ยกเว้นแต่บางอันคนทำรอมจะกำหนดเป็นแบบอื่นซึ่งเค้าจะต้องบอกไว้)

  1. Partition Size 150 MB เหมาะสำหรับพวก Base Rom ทั้งหลาย เช่น CyanogenMod , AOSP และ MIUI
  2. Partition Size 250 MB เหมาะสำหรับพวก Standard SENSE Rom ทั้งหลาย เช่น Rom ที่ได้มาจาก HTC Desire หรือ Evo
  3. Partition Size 400 MB เหมาะสำหรับพวก Rom ขนาดใหญ่ เช่น Rom ที่ได้มาจากรุ่น Desire HD รวมถึงรอมที่ต้องการ data2sd

ส่วนวิธีการติดตั้งก็คือ

  1. โหลด Partition Size ที่ต้องการจะติดตั้งมา
  2. แตกไฟล์ไว้ในเครื่องและเข้า USB Flasher ใน MAGLDR 1.13 เอาไว้
  3. รัน DAF.exe แล้วทำตามขั้นตอน
  4. หาโหลด rom ที่ต้องการแบบ zip มาแล้วโยนลง SD
  5. หลังจากติดตั้งเสร็จเครื่องจะรีบูทใหม่,กดปุ่ม Power ค้างไว้ และเลือก AD Recovery จากหน้าเมนู
  6. Recovery ก็จะโหลดขึ้นมาแล้วหล่ะ
*Credit PDAMobiz.com