Skip to content

Commit

Permalink
Merge pull request #36 from elite-lang/dev
Browse files Browse the repository at this point in the history
完成了graphviz图的绘制
xssss1 committed Feb 6, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents bf9d9f5 + 0a46352 commit 2805e01
Showing 15 changed files with 90 additions and 27 deletions.
3 changes: 2 additions & 1 deletion Builder/src/Worker.cpp
Original file line number Diff line number Diff line change
@@ -27,7 +27,8 @@ void Worker::Init(LexInterface* l, Parser* p, ScriptRunner* s, CodeGen* c) {
void Worker::Run(const char* input, const char* output) {
lex->setData(input);
Grammer_Node* root = Grammer_Node::NewNode();
parser->Parse(root);
int err = parser->Parse(root);
if (err) exit(1);
Node* node = script_runner->getRoot();
if (node == NULL) {
printf("分析器异常,返回为NULL\n");
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
Change Log
================
===============

### v0.8.4

修复了部分插件系统的bug
完成了graphviz图的绘制


### v0.8.3

大幅修缮了插件系统,修复JIT的bug
新增ICodeGenContext接口
修复了BasicBlock的相关bug


### v0.8.2

1 change: 1 addition & 0 deletions EliteTest/bug_list/10/TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
需要修复错误情况下llvm字节码的输出
1 change: 1 addition & 0 deletions EliteTest/bug_list/9/TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
break语句暂未实现
12 changes: 6 additions & 6 deletions EliteTest/bug_list/9/test.elite
Original file line number Diff line number Diff line change
@@ -4,15 +4,15 @@ int main(){
int n = 90;
printf("%d=", n);
// n>=2才执行下面的循环
for(int i=2; i<=n; i++){
while(n!=i){
if(n%i==0){
printf("%d*",i);
n=n/i;
for(int i = 2; i <=n ; i++){
while(n != i){
if(n % i == 0){
printf("%d*", i);
n = n / i;
}else
break;
}
}
printf("%d\n",n);
printf("%d\n", n);
return 0;
}
1 change: 0 additions & 1 deletion EliteTest/bug_list/9/test.out
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
90=2*3*3*5
7 changes: 7 additions & 0 deletions ExIconv/include/DebugMsg.h
Original file line number Diff line number Diff line change
@@ -53,6 +53,13 @@ class DebugMsg
static std::ostream& red_dbg();
static void red_close();


static std::ostream& lex_graphviz();
static void lex_graphviz_close();

static std::ostream& parser_graphviz();
static void parser_graphviz_close();

static DebugMsg_Private* getInstance();
private:
static DebugMsg_Private* instance;
36 changes: 36 additions & 0 deletions ExIconv/src/DebugMsg.cpp
Original file line number Diff line number Diff line change
@@ -21,6 +21,9 @@ class DebugMsg_Private
fstream parser_dbg_fs;
fstream parser_save_fs;
fstream red_dbg_fs;

fstream lex_graphviz_fs;
fstream parser_graphviz_fs;
};

void DebugMsg::setDebugFilePath(const char* path) {
@@ -107,6 +110,39 @@ void DebugMsg::red_close() {
fs.close();
}



std::ostream& DebugMsg::lex_graphviz() {
auto& fs = getInstance()->lex_graphviz_fs;
if(!fs.is_open()) {
fs.open(getInstance()->dbg_file_path+"/lex.gv", std::ios::out);
return fs;
}
return fs;
}

void DebugMsg::lex_graphviz_close() {
auto& fs = getInstance()->lex_graphviz_fs;
fs.close();
}


std::ostream& DebugMsg::parser_graphviz() {
auto& fs = getInstance()->parser_graphviz_fs;
if(!fs.is_open()) {
cout << getInstance()->dbg_file_path+"/parser.gv" << endl;
fs.open(getInstance()->dbg_file_path+"/parser.gv", std::ios::out);
return fs;
}
return fs;
}

void DebugMsg::parser_graphviz_close() {
auto& fs = getInstance()->parser_graphviz_fs;
fs.close();
}


DebugMsg_Private* DebugMsg::getInstance() {
if (instance == NULL)
instance = new DebugMsg_Private();
2 changes: 1 addition & 1 deletion LR_Scanner
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -10,20 +10,20 @@ Elite是一款脚本化驱动的编译器,一般的编程语言,语法是固

这个特点,使得Elite非常容易自由开发,成为一款领域专业语言(DSL),在自由配置后,方便地表达专业的相关内容。

详细请参加文档: <http://elite-lang.github.io/doc/zh-cn/>
详细请参加文档: <http://elite-lang.org/doc/zh-cn/>

## 编译安装

clone全部仓库,注意添加`--recursive`参数来下载全部子项目
```
git clone --depth=1 --recursive git@github.com:elite-lang/Elite.git
git clone --depth=1 --recursive git@github.com:elite-lang/Elite.git
```

本项目是在Ubuntu14.04 64位系统下开发的,依赖cmake-2.8, LLVM-3.6和glibmm-2.4、giomm-2.4, flex-2.5 bison-3.0
lua oolua dyncall

```
sudo apt-get install cmake llvm-3.6-dev libglibmm-2.4-dev flex bison libedit-dev
sudo apt-get install cmake llvm-3.6-dev libglibmm-2.4-dev flex bison libedit-dev
```

修复ubuntu源中LLVM-3.6的bug:
@@ -42,7 +42,7 @@ make release
```
mkdir build && cd build
cmake .. //cmake配置
make deps //下载并构建依赖项目
make deps //下载并构建依赖项目
make //构建项目
```

@@ -52,7 +52,7 @@ make //构建项目

项目不会向系统添加任何文件,希望使用环境变量配置,将编译器添加到PATH目录中,并且ELITE_HOME也确保编译器能够找到默认的词法、语法配置文件
```
# for elite
# for elite
export ELITE_HOME=【您的Elite仓库地址】
export PATH=$ELITE_HOME/bin:$ELITE_HOME/tools:$PATH
```
@@ -79,7 +79,7 @@ void hello(int k, int g) {
int y = k + g;
printf("%d\n", y);
if (k + g < 5) printf("right\n");
}
}
void go(int k) {
@@ -93,7 +93,7 @@ void go(int k) {
void print(int k) {
for (int i = 0; i < 10; i = i+1) {
printf("hello-%d\n",i);
}
}
}
@@ -158,9 +158,9 @@ Elite分为如下几个模块:

希望和我们交流非常容易,可以选择发邮件或在github上直接和我们联系,都可以。

- github:<https://github.com/elite-lang/Elite>
- 邮箱:<mailto:sunxfancy@gmail.com>
- gitter:[参与讨论](https://gitter.im/elite-lang/Elite?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
- github:<https://github.com/elite-lang/Elite>
- 邮箱:<mailto:sunxfancy@gmail.com>
- gitter:[参与讨论](https://gitter.im/elite-lang/Elite?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

## 开源协议

2 changes: 1 addition & 1 deletion RedApple
5 changes: 5 additions & 0 deletions doc/design/TODO.md
Original file line number Diff line number Diff line change
@@ -47,6 +47,11 @@ flex bison
8. 中间过程的导出 ok
使用log模块导出中间调试数据,用作EliteShow的展示

9. 添加break语句, 终止循环

10. 添加switch, do while, do until语句


## 次要任务

1. 编译器输入参数的处理,目前输入参数有误时没有提示信息
4 changes: 1 addition & 3 deletions doc/index.en.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,4 @@ Elite Compiler
==================


Elite是一款脚本化驱动的编译器,一般的编程语言,语法是固定的,只能使用有限的表达方式,而Elite的语法并非固定,而是由脚本配置而成的,如果需要,随时都可以自由更改。

这个特点,使得Elite非常容易自由开发,成为一款领域专业语言(DSL),在自由配置后,方便地表达专业的相关内容。
英文文档暂缺翻译, 欢迎您帮助我们完善该部分
2 changes: 1 addition & 1 deletion src/elite-config.h
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@

#define ELITE_VERSION_MAJOR "0"
#define ELITE_VERSION_MINOR "8"
#define ELITE_VERSION_RELEASE "3"
#define ELITE_VERSION_RELEASE "4"
#define ELITE_VERSION_NUM 8

#define ELITE_VERSION "Elite " ELITE_VERSION_MAJOR "." ELITE_VERSION_MINOR
6 changes: 4 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -89,19 +89,21 @@ int main(int argc, const char *argv[])
if (only_one_file == -1)
only_one_file = 0;


// 创建Worker和Builder
defalut_lex = PathUtils::native(defalut_lex);
defalut_parser = PathUtils::native(defalut_parser);
Builder* builder = Builder::Create();
if (is_show_time == 1)
builder->setDebugFilePath(dir.c_str());
Worker* worker = Worker::CreateDefault(
defalut_lex.c_str(), defalut_parser.c_str(),
PathGetter::getElitePackagesPath(),
builder
);
builder->setWorker(worker);
builder->SetBuildPath(dir);
if (is_show_time == 1)
builder->setDebugFilePath(dir.c_str());

if (only_one_file == 1) {
builder->BuildFile(onlyfile);
} else {

0 comments on commit 2805e01

Please sign in to comment.