莫亚空间
莫亚空间
Tuesday, November 24, 2009
Antlr 笔记1
Antlr 下载地址:http://www.antlr.org/download.html
Antlr提供了:
* 从一份Grammar自动生成该Grammar描述的语言的分析器(基本任务……)
* Antlr Grammar IDE -> ANTLRWorks+ANTLR
* 多语言目标:
http://www.antlr.org/wiki/display/ANTLR3/Code+Generation+Targets
Java, C/C++, C#/C#2, D, ObjectiveC, Python, Ruby, [Emacs ELisp],
Perl/Perl6, Php, Ada95, Oberon, Action Script, Dephi, JavaScript
----------------
Antlr命令行程序是一个jar文件,使用方法
java -jar "Antlr.jar" [Grammar.g]
我的bat包装: antlr.bat 放入system包含目录就可以在任一目录执行了。
@echo off
java.exe -jar "d:\program files\antlr\antlr.jar" %1 %2 %3 %4 %5 %6 %7 %8 %9
工作方法:
首先,建立一个需要处理的目标语言的Grammar,可以使用ANTLRWorks(或者Eclipse+相关插件, AntlrDT)等。
antlr Grammar.g
生成相关的文件,如果基于java平台,会生成GrammarLexer.java GrammarParser.java 等文件。
Friday, July 17, 2009
Gmail IMAP
Tuesday, April 7, 2009
wxStandardPaths().GetDataDir()
Saturday, March 21, 2009
All modes in python built-in open function(转发)
open(file,mode="r",buffering=None,encoding=None,errors=None,newline=None,closefd=True)
The possible modes are:
* r: Reading
* w: Open for writing
* a: Open for appending
* b: Binary mode
* t: Text mode
* +: Open a disk file for updating
* U: Universal newline mode
The default mode is rt, or open for reading text mode.
(原文地址:http://www.ibm.com/developerworks/linux/library/l-python3-1/)
python 3.0 也有介绍 http://docs.python.org/3.0/library/io.html
Saturday, February 28, 2009
Bakefile 中文版手册
Table of Contents
By far the simplest way to generate makefiles using Bakefile is to use so-called presets which are prepared skeletons of bakefiles that get you started quickly. Let's see how it works on an example of the famous Hello, world program written in C and implemented in the hello.c
file:
现在,用Bakefile生成makefile最简单的方法是,使用一些预先设定的框架 presets,它可以让你快速起步。让我们看看bakefile如何应用于这个著名的用C语言实现的Hello, world 例子,源文件是hello.c
:
#include <stdio.h> int main() { printf("Hello, world!\n"); return 0; }
The bakefile needed to compile it,hello.bkl
, looks like this:
Bakefile需要编译它,hello.bkl
, 如下:
<?xml version="1.0"?> <makefile> <include file="presets/simple.bkl"/> <exe id="hello" template="simple"> <sources>hello.c</sources> </exe> </makefile>
Presets are included using the include directive. The structure of the file name is always the same: presets/NAME-OF-PRESET.bkl
. In general, you can combine several presets, but in practice you must be careful when doing so. It's always a good idea to read the code for the preset before using it. The "simple" preset we include here defines a DEBUG
option and a template called simple
. Generated makefiles will allow the user to build all targets that are based on this template as either debug or release build.
使用include 命令来导入preset。文件名的结构总是如下: presets/NAME-OF-PRESET.bkl
。通常,你可以合并使用多个preset,但是实际操作的时候,你最好小心点来。导入之前最好先读读preset的代码。我们这里导入的 "simple" preset 定义了一个 DEBUG
option 和一个simple
template 。 生成的makefile文件可以让用户基于这个template 来生成所有的target的debug 或 release build。
Let's generate some makefiles now. The bakefile command is used to do it. For example:
Le现在我们来生成makefile。bakefile命令就是干这个的,例:
$
bakefile -f msvc hello.bkl
That's all. This will creates VC++ makefile makefile.vc
. Of course, you can change the name of output file if you don't like the default:
搞定。现在会生成VC++的makefile makefile.vc
。当然,如果你不喜欢默认的输出文件名,你可以换:
$
bakefile -f msvc -o makefile hello.bkl
Bakefile will also generate the Makefile.in
files used by Autoconf:
Bakefile 同时可以生成 Autoconf 使用的 Makefile.in
文件:
$
bakefile -f autoconf hello.bkl
These are templates for makefiles. Autoconf also requires a configure.ac
script (previously, configure.in
), but Bakefile will not generate this for you. This script checks for platform features necessary to build the program; see the autoconf manual for details.
These are templates for makefiles. Autoconf 还需要一个 configure.ac
脚本 (之前版本 configure.in
),但Bakefile不会帮你生成它。这个脚本检查系统平台是否满足build当前program,详见 autoconf 手册。
When producing autoconf format output, Bakefile will also generate a file called autoconf_inc.m4
which defines macros needed by the generated Makefile.in files. To use this, call the AC_BAKEFILE
macro within your configure.ac
script.
生成 autoconf format 输出的时候,Bakefile 同时会生成一个叫做 autoconf_inc.m4
的文件,它定义了生成的 Makefile.in 文件需要的宏。应用中,在 configure.ac
脚本里调用 AC_BAKEFILE
宏。
A minimal configure.ac
script for our example program would look like this:
我们的示例program的最精简 configure.ac
可能格式如下:
AC_PREREQ(2.53) AC_INIT(aclocal.m4) AC_CANONICAL_SYSTEM DEBUG=0 AC_BAKEFILE([m4_include(autoconf_inc.m4)]) AC_OUTPUT([Makefile])
Note the part that sets the DEBUG
variable. Any options declared in your bakefile must be set to some default value before calling AC_BAKEFILE
. The simple.bkl preset defines the DEBUG
option, so we have to give it a default value here.
注意设置 DEBUG
变量的位置。你的bakefile定义(?)的任何option在调用 AC_BAKEFILE
之前必须给定一个默认值。 "simple.bkl" preset 定义了 DEBUG
option,所以我们得给它个默认值。
While the above code will work, there's a better way to handle the debug option:
虽然上面的代码可以工作,这儿有个更好的方法来管理 debug option:
AC_PREREQ(2.53) AC_INIT(aclocal.m4) AC_CANONICAL_SYSTEM AC_ARG_ENABLE(debug, [ --enable-debug Enable debugging information], USE_DEBUG="$enableval", USE_DEBUG="no") if test $USE_DEBUG = yes ; then DEBUG=1 dnl Bakefile doesn't touch {C,CPP,CXX,LD}FLAGS in autoconf format, we dnl have to do it ourselves. This will work with many compilers dnl (but not all, proper configure script would check if the compiler dnl supports it): CFLAGS="$CFLAGS -g" else DEBUG=0 fi AC_BAKEFILE([m4_include(autoconf_inc.m4)]) AC_OUTPUT([Makefile])
You are ready to generate Autoconf's configure
script now:
你现在已经准备好生成 Autoconf 的 configure
脚本了:
$
bakefilize --copy && aclocal && autoconf
Bakefile 中文版手册
Bakefile 手册 | ||
---|---|---|
Next 下一页 |
Table of Contents
- 1. 简介 Introduction
- 2. 入门 Tutorial
- 3. Bakefile 概念 Bakefile Concepts
- 4. 目标 Targets
- 5. 命令参考 Commands Reference
- 6. 常见问题 Frequently encountered issues
- 7. Bakefile内置变量 Variables defined by Bakefile
- 8. Python函数 Python functions
- 9. 格式相关文档 Format specific documentation
- 10. 模模组 Modules
- 11. 用bakefile_gen自动生成bakefile Batch bakefile generation with bakefile_gen
- I. 运行Bakefile Running Bakefile
- bakefile — 本地makefile生成工具 native makefiles generator
- bakefile_gen — 自动化生成bakefile batch bakefile generation
- bakefilize — 为Autoconf用户生成Bakefile项目文件 prepare Bakefile project for use with Autoconf
Next 下一页 | ||
Chapter 1. 介绍 Introduction |
Wednesday, February 4, 2009
用 VC2005 编译 Python 3.0 无法打开工程文件?
文件夹 \Python-3.0-src\PC 里面包含了支持老版本VC的工程文件。
可是,双击 VS8.0 目录下面的 pcbuild.sln 却无法正常打开。
先启动VC8,再用Open Project 才成功打开。重新保存一次后,可以正常双击自动启动VC8打开了。