Month: ตุลาคม 2008

วิธีการใช้ GLUT บน MAC ด้วย Eclipse

 - by NAzT

With Eclipse On Mac

ก่อนอื่นเราต้องใช้ (Use This)

#include <OpenGL/gl.h> #include <GLUT/glut.h>
แทนที่จะใช้ (Instead Of)
#include <GL/gl.h> #include <GL/glut.h>
แล้ว
  1. คลิกขวาที่ ด้านซ้ายมือ
  2. เลือก Properties
  3. เลือก  “C/C++ Build:Properties”
  4. มองหาและไปที่ “Tool Settings”
  5. เลือกไปที่ “Mac OS X C++ Linker : Miscellaneous”
  6. เพิ่มใช่ช่อง “Linker flags” field: ด้วย -framework GLUT -framework OpenGL

Read this article »

Intro to Lex & Yacc [1]

 - by NAzT

มาทำ scanner ด้วย flex กัน !!

lex &

หมายเหตุ ว่า

ส่วนของ scanner (ทำ lexical analysis)  ผมจะใช้โปรแกรม flex หรือ lex ส่วนของ parser เราใช้โปรแกรม bison

ซึ่ง

flex (Flex is a fast lexical analyser generator.) และ bison (Bison is a general-purpose parser generator) เป็นโปรแกรม บน unix based OS แต่บน windows  ก็มีให้ใช้ ลองไป search หา กันได้ครับ
วิธีการติดตั้งง่ายๆ บน (ubuntu) พิมพ์ code ข้างล่างลงใน terminal (shell) sudo apt-get install flex sudo apt-get install bison

แล้วก็มาว่าด้วย flex กันต่อ

flex ก็เหมือน compiler ที่ compile code ภาษา c อะแหละ

แต่ว่า compiler ของภาษา c มันจะ compile ไฟล์ .c ให้เป็น ภาษาเครื่อง (.exe — executable file)

แต่ไอ้เจ้า flex เนี่ย จะ compile ไฟล์นามสกุล .l ให้เป็นไฟล์ภาษา c (ไฟล์ .c )

แล้วเราก็ต้องเอา ไฟล์ภาษา c ที่ได้มา compile ต่อเป็นภาษาเครื่อง

แล้วเราก็จะได้โปรแกรมที่รับ input แล้วเอาไปตัดเป็น tokens ตามที่เราตั้งกฎไว้

เดี๋ยวมาต่อตอน 2 นะครับนะ

Related Blogs