2009年12月14日
Eclipse 設(shè)置ANTLR package后
還需要在project上面右鍵點(diǎn)擊 然后選擇Add Antlr IDE support 才會(huì)在保存 .g 文件時(shí)
自動(dòng)生成parser代碼!
2009年12月11日
AntlrWorks 運(yùn)行的時(shí)候,需要JRE
但是,正常工作卻需要JDK
因?yàn)椋腄ebug和Run部分需要調(diào)用 Javac.exe,這個(gè)東西JDK才有。
安裝好了之后,還需要到 File -> Preference 里設(shè)置編譯器路徑。
AntlrWorks只是調(diào)試grammar的時(shí)候比較方便,作為一個(gè)編輯器,還
不夠好用。
2009年12月7日
摘要: ANTLR 3
byR. Mark Volkmann, Partner/Software Engineer Object Computing, Inc. (OCI) 翻譯者:Morya
Preface
前言
ANTLR is a big topic, so this is a big article. The table of contents that follows contains...
閱讀全文
2009年10月23日
目的?
像我一樣,不得不分析一些格式不是很復(fù)雜,但也不簡(jiǎn)單的log文件。
厭倦了寫(xiě)正則表達(dá)式,更不想為了這個(gè)東西搞一個(gè)狀態(tài)機(jī)。(我也搞不來(lái)狀態(tài)機(jī)……)
安裝篇:
安裝simpleParse。
http://sourceforge.net/projects/simpleparse/files/
找到 SimpleParse-2.1.1a2.win32-py2.5.exe 或者 SimpleParse-2.1.1a2.win32-py2.6.exe
安裝。
使用篇:
1,要為需要被分析的文件寫(xiě)一個(gè)文法(grammar)。
2,后面就簡(jiǎn)單了。
ibm這里有一篇教程,
http://www.ibm.com/developerworks/library/l-simple.html?S_TACT=105AGX52&S_CMP=cn-a-l
也有翻譯成中文的
http://www.ibm.com/developerworks/cn/linux/sdk/python/charm-23/index.html
可惜,中文版的代碼格式亂掉了,需要代碼可以去英文版copy。
后面就沒(méi)啥好講的了。
2009年8月17日
Qt Creator 當(dāng)前版本1.2.1 與 Qt4.5.2一起發(fā)布。
安裝方式:windows 直接下載 qt-sdk-win-opensource-2009.03.1.exe 就很好用。
安裝后有一個(gè)特別重要的東西需要調(diào)整,那就是代碼補(bǔ)全的Hot Key (默認(rèn)是Ctrl+Space……)
我認(rèn)為,Qt Creator 下面幾個(gè)特性最值得稱道:
1,Locator 定位器 使用快捷鍵 Ctrl+K
2,使用快捷鍵Ctrl+1, 2, 3, 4, 5在幾個(gè)mode里面快速切換
3,利用F4在cpp和header文件之間快速切換
4,使用Esc快速返回編輯模式
2009年8月16日
貌似,用了引用傳值,connect雖然沒(méi)有報(bào)錯(cuò),卻不會(huì)運(yùn)行到那段代碼,改成不是引用就沒(méi)問(wèn)題了。
2009年7月31日
C++ Primer 3rd Edition 說(shuō)
fstream 已經(jīng)包含了 iostream, 可是,明顯不是這么回事。
下面的代碼就編不過(guò)。(VC2005)
//#include <iostream>
#include <fstream>
#include <string>
using std::cout;
using std::endl;
using std::fstream;
void test_fstream(){
fstream f;
f.open("c:\\in.txt", fstream::in);
if( f.fail() ){
cout << "Can't open file for input."<<endl;
}
else{
cout << "File opened." << endl;
}
f.close();
}
int main(){
test_fstream();
return 0;
}
2009年7月29日
其實(shí),早就開(kāi)源了,只是我沒(méi)看到……
Raven以GPL2開(kāi)源,項(xiàng)目地址 http://code.google.com/p/zoundryraven/
Raven的官方開(kāi)發(fā)指南:
http://code.google.com/p/zoundryraven/wiki/WikiGettingStarted
該指南推薦在虛擬機(jī)里面開(kāi)發(fā)Raven。。
Powered by Zoundry Raven
2009年7月28日
捕獲異常,用引用還是用指針,我一直很糊涂。
學(xué)STL里面,有可能拋出異常的地方,用指針一直都無(wú)法捕獲,搞相當(dāng)疑惑。
后來(lái)才知道,用那種格式需要對(duì)你調(diào)用函數(shù)會(huì)拋出哪種異常清楚才行。
下面是示例代碼:
1 #include <iostream>
2 #include <string>
3 #include <exception>
4
5 using std::cout;
6 using std::endl;
7 using std::string;
8 using std::exception;
9
10 class MyException : public exception{
11 public:
12 MyException();
13 };
14
15 MyException::MyException():exception("You know that"){}
16
17 void thr(){
18 throw new MyException();
19 }
20
21 void test_exception(){
22
23 string s;
24 try{
25 s.at(1);
26 }
27 catch(exception & e){
28 cout << "Caught exception." << e.what() << endl;
29 }
30
31 try{
32 thr();
33 }
34 catch(MyException* e){
35 cout << "Caught myException: " << e->what() << endl;
36 delete e;
37 e = NULL;
38 }
39 }
40
41 void main(){
42 test_exception();
43 }
44
異常是以指針?lè)绞綊伋觯陀弥羔樞问絹?lái)捕獲,用普通形式拋出,就需要用普通格式,為了減少?gòu)?fù)制,那么用引用就可以了。
2009年7月23日
下面的代碼可以搞定
void binary(int v){
using std::bitset;
using std::cout;
using std::endl;
bitset< 8*sizeof(int) > b = v;
cout << b.to_string() << endl;
bitset<8> b2 = v;
cout << b.to_string() << endl;
}