วันพุธ, มิถุนายน 30, 2547

The typical compiler consists of several phases each of which passes its output to the next phase

* The lexical phase (scanner) groups characters into lexical units or tokens. The input to the lexical phase is a character stream. The output is a stream of tokens. Regular expressions are used to define the tokens recognized by a scanner (or lexical analyzer). The scanner is implemented as a finite state machine.
* The parser groups tokens into syntactical units. The output of the parser is a parse tree representation of the program. Context-free grammars are used to define the program structure recognized by a parser. The parser is implemented as a push-down automata.
* The contextual analysis phase analyzes the parse tree for context-sensitive information often called the static semantics. The output of the contextual analysis phase is an annotated parse tree. Attribute grammars are used to describe the static semantics of a program.
* The optimizer applies semantics preserving transformation to the annotated parse tree to simplify the structure of the tree and to facilitate the generation of more efficient code.
* The code generator transforms the simplified annotated parse tree into object code using rules which denote the semantics of the source language.
* The peep-hole optimizer examines the object code, a few instructions at a time, and attempts to do machine dependent code improvements.
รู้สึกวันนี้จะยังไม่ได้งานเป็นชิ้นเป็นอันเลยแฮะ.....เริ่มง่วงแล้วด้วย..

วันอังคาร, มิถุนายน 29, 2547

วันอาทิตย์, มิถุนายน 27, 2547

wow!

work แล้ว...ดีใจจัง..

ต้องลง +

-libgnutls7 กะ libgnutls7-dev เพิ่มอีก...

compile ใหม่อีกรอบ.... --'
อารายฟ่ะ....
ขึ้นเตือน SSL support is needed for MSN เจ้ย...
แล้วทามงายดีหวาา???
Gaim version 0.79 ออกมาอีกแระ... เร็วจิง..รู้สึก 0.78 ออกมาไม่กี่วันเอง..

ว่าจะลอง compile จาก source ซะหน่อย...

ต้อง get
-libglib2.0-0
-libglib2.0-dev (ถ้า compile เองต้องลงนี้ด้วย)
-libgtk2.0-0
-libgtk2.0-dev (ถ้า compile เองต้องลงนี้ด้วย)

เด๋วดูผล...แป๊บ..
นั่งอ่านวิธีเขียน grammar ของ yacc ได้พักใหญ่แล้ว...เริ่มเห็นลู่ทาง...ค่อยยังดีหน่อย..

==> Parsing a configuration file

สมมติจะ parse configuration ตัวนี้

zone "." {
type hint;
file "/etc/bind/db.root";
};

เริ่มต้นก็ต้องเขียน lex file ขึ้นมาก่อน return ให้ yacc เข้าพระทัยซะด้วย

%{
#include
#include "y.tab.h"
%}

%%

zone return ZONETOK;
file return FILETOK;
[a-zA-Z][a-zA-Z0-9]* yylval=strdup(yytext); return WORD;
[a-zA-Z0-9\/.-]+ yylval=strdup(yytext); return FILENAME;
\" return QUOTE;
\{ return OBRACE;
\} return EBRACE;
; return SEMICOLON;
\n /* ignore EOL */;
[ \t]+ /* ignore whitespace */;
%%

สังเกตว่า yylval จะไม่ใช่ integer แต่เป็น char * ดังนั้นก็เลยต้อง #define YYSTYPE char * ให้ yacc รู้จักก่อน

ตอนเริ่มเขียน yacc grammer นี้ชักจะเริ่มมั่วนิดส์นึง

เริ่มการ recusive ที่ root

commands:
|
commands command SEMICOLON
;

คือว่าแต่ละ command แยกกันด้วย ";"(semicolon)

command:
zone_set
;

zone_set:
ZONETOK quotedname zonecontent
{
printf("Complete zone for '%s' found\n",$2);
}
;
มี zonecontent ด้วย

zonecontent:
OBRACE zonestatements EBRACE

จะต้องมี { OBRACE และ } EBRACE

quotedname:
QUOTE FILENAME QUOTE
{
$$=$2;
}
นั่นคือ quotedname เท่ากับ filename

NOTE: this grammar chokes on filenames without either a '.' or a '/' in them.

zonestatements:
|
zonestatements zonestatement SEMICOLON
;

zonestatement:
statements
|
FILETOK quotedname
{
printf("A zonefile name '%s' was encountered\n", $2);
}
;

This is a generic statement that catches all kinds of statements within the 'zone' block. We again see the recursiveness.

block:
OBRACE zonestatements EBRACE SEMICOLON
;

statements:
| statements statement
;

statement: WORD | block | quotedname


วันศุกร์, มิถุนายน 25, 2547

เมื่อวาน OSNews post ข่าวเรื่องราคา WindowsXP ในเมืองไทยด้วย...เอิ้กๆ Thailand to get slimmed-down Windows
Redhat เอาใจ Java Programmer ให้ Eclipse เป็น Development suite รันเป็น Native ซะด้วย โดยใช้ libgcj...หวังว่าคงปรู้ดปร้าด...
Eclipse Goes Native compile ให้เป็น machine code โดยใช้ GCJ Compiler
เมื่อคืนนั่งดูบอลคู่โปรตุเกส-อังกฤษ มันส์มากเลยหง่ะ...ด้วยความเกลียดอังกฤษ...ได้เห็นสิงโตเขี้ยวหักนี้รู้สึกสะใจยังไงพิกล
อังกฤษนั้นเล่นไม่ได้เรื่องอยู่แล้ว...จากการวิเคราะห็ดูแล้ว...อังกฤษไม่มีตัวครองบอลแบบติดตีนซักคนนึง...ก็เลยไม่มีตัวป่วนเกมรับโปรตุเกสได้เลย
เน้นสาดยาวให้ owen วิ่ง..ปรู้ดๆ.. ส่วนโปรตุเกสนั้นก็ถือว่ายังเล่นห่วย..ถ้าเจอทีมรุกดีๆน่าจะต้านไม่อยู่...Figo เล่นไม่เอาถ่านเลย...จ่ายบอลไม่ได้เสียวซักลูก...ยิง freekick ข้ามคานไปสอง...ไม่สมกับเป็นจอมทัพเลย...แม่งลุ้นให้เปลี่ยนออก...แล้วก็ถูกเปลี่ยนออกจนได้...เอาใครลงมาไม่รู้...เสือกยิงได้...Rui Costa ก็ยิงได้ด้วย...เจ๋งเป้งไปเลย...แต่ตอนยิงลูกโทษ..ยิงนก...ตอนนั่งดูพูดยังไม่ทันขาดคำเลยว่า Rui Costa ชอบยิงข้ามคาน สังเกตจากเวลาเล่นในเวลา...ยิงโด่งตลอดเลย...และที่ฮาสุดๆ..คือ Beckham ยิงจุดโทษไม่เข้า( 3 ครั้งล่าสุด ยิง 3 เข้า 0) 5555+ ตลก..

วันพุธ, มิถุนายน 23, 2547

ไม่ได้ up blog หลายวันเหลือเกิน :
debian ที่ใช้อยู่นี้ก็ถือว่า work ดี

ลง suse9.1 personal แล้วใน notebook
พอดีเครื่องไม่แรง...ผลออกมาเลยทุเรศ...
อืดมากๆ...

งานหลักที่ต้องทำตอนนี้ก็ต้องสร้าง engine สำหรับ packet monitoring program
ของตัวเอง....ซึ่งต้องสร้างภาษาขึ้นมาเป็น data-driven language(packet-driven)
มั่วๆอยู่... อีกไม่นานคง work

วันพฤหัสบดี, มิถุนายน 10, 2547

Gaim version ใหม่ รับส่ง file ผ่าน MSN protocol ได้แระ

วันพุธ, มิถุนายน 09, 2547

สีไว้ทำ web www.visibone.com
มี review ของ Service Pack2 เห็นเค้าว่ากันว่าเป็น big security improvement ของ MS เลย
ยังไม่อยากลง เพราะเป็น beta อยู่ คอย final ออกแล้วค่อยจัดการ ไม่อยากลง windows ใหม่อีกรอบล่ะ..เหนื่อย..><
เอ.. มี Blog ของ Sun Engineer ด้วย..เอิ้กๆ ^^ Sun Opens Up with Blogging; Solaris Tidbits

วันอังคาร, มิถุนายน 08, 2547

ตอนนี้ debian กะ WinXP ก็ลงได้ราบรื่น
ชอบเจอปัญหาโลกแตกจิงๆ... แต่ก็ต้องทนอ่ะนะทำไงได้
เกิดมาอยู่ในวงการ computer

วันเสาร์, มิถุนายน 05, 2547

ไม่ได้เข้ามา post blog นานเหมือนกันแฮะ...

เมื่อคืนลงอะไรก็ไม่ผ่านซักอย่าง

debian unpack x-window-system ไม่ได้
windows Missing OS
Norton ค้างง....

กรำส์