Morya

2009年12月14日

Eclipse 设置ANTLR package后 还需要在project上面右键点击 然后选择Add Antlr IDE support 才会在保存 .g 文件时 自动生成parser代码!
posted @ 2009-12-14 17:32 Morya 阅读(409) | 评论 (0)编辑 收藏

2009年12月11日

AntlrWorks 运行的时候,需要JRE
但是,正常工作却需要JDK
因为,它的Debug和Run部分需要调用 Javac.exe,这个东西JDK才有。

安装好了之后,还需要到 File -> Preference 里设置编译器路径。
AntlrWorks只是调试grammar的时候比较方便,作为一个编辑器,还
不够好用。

posted @ 2009-12-11 21:22 Morya 阅读(410) | 评论 (0)编辑 收藏

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...  阅读全文
posted @ 2009-12-07 00:13 Morya| 编辑 收藏

2009年10月23日

目的?

像我一样,不得不分析一些格式不是很复杂,但也不简单的log文件。
厌倦了写正则表达式,更不想为了这个东西搞一个状态机。(我也搞不来状态机……)


安装篇:
安装simpleParse。
http://sourceforge.net/projects/simpleparse/files/
找到 SimpleParse-2.1.1a2.win32-py2.5.exe 或者 SimpleParse-2.1.1a2.win32-py2.6.exe
安装。


使用篇:
1,要为需要被分析的文件写一个文法(grammar)。
2,后面就简单了。
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。

后面就没啥好讲的了。

posted @ 2009-10-23 23:39 Morya 阅读(257) | 评论 (0)编辑 收藏

2009年8月17日

Qt Creator 当前版本1.2.1 与 Qt4.5.2一起发布。
安装方式:windows 直接下载 qt-sdk-win-opensource-2009.03.1.exe 就很好用。
安装后有一个特别重要的东西需要调整,那就是代码补全的Hot Key (默认是Ctrl+Space……)

我认为,Qt Creator 下面几个特性最值得称道:

1,Locator 定位器 使用快捷键 Ctrl+K

2,使用快捷键Ctrl+1, 2, 3, 4, 5在几个mode里面快速切换

3,利用F4在cpp和header文件之间快速切换

4,使用Esc快速返回编辑模式

posted @ 2009-08-17 00:03 Morya 阅读(867) | 评论 (0)编辑 收藏

2009年8月16日

貌似,用了引用传值,connect虽然没有报错,却不会运行到那段代码,改成不是引用就没问题了。

posted @ 2009-08-16 17:49 Morya 阅读(432) | 评论 (0)编辑 收藏

2009年7月31日

C++ Primer 3rd Edition 说

fstream 已经包含了 iostream, 可是,明显不是这么回事。

下面的代码就编不过。(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;
}

posted @ 2009-07-31 10:36 Morya 阅读(292) | 评论 (2)编辑 收藏

2009年7月29日

其实,早就开源了,只是我没看到……

Raven以GPL2开源,项目地址 http://code.google.com/p/zoundryraven/

Raven的官方开发指南:

http://code.google.com/p/zoundryraven/wiki/WikiGettingStarted

该指南推荐在虚拟机里面开发Raven。。

Powered by Zoundry Raven

posted @ 2009-07-29 10:13 Morya 阅读(239) | 评论 (1)编辑 收藏

2009年7月28日

捕获异常,用引用还是用指针,我一直很糊涂。
学STL里面,有可能抛出异常的地方,用指针一直都无法捕获,搞相当疑惑。
后来才知道,用那种格式需要对你调用函数会抛出哪种异常清楚才行。

下面是示例代码:

 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 

异常是以指针方式抛出,就用指针形式来捕获,用普通形式抛出,就需要用普通格式,为了减少复制,那么用引用就可以了。

posted @ 2009-07-28 17:14 Morya 阅读(780) | 评论 (0)编辑 收藏

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;
}

posted @ 2009-07-23 19:29 Morya 阅读(452) | 评论 (0)编辑 收藏
仅列出标题  下一页

导航

<2024年3月>
252627282912
3456789
10111213141516
17181920212223
24252627282930
31123456

统计

常用链接

留言簿(1)

随笔档案(21)

文章档案(1)

最新评论

评论排行榜