Code Monkey home page Code Monkey logo

xscript's Introduction

xscript

一个脚本的虚拟机、汇编器和编译器的实现

  最近看《游戏脚本高级编程》,然后顺便把里面实现的虚拟机,汇编器以及编译器手动用C++重写了一遍,原版书中提供的代码,风格不是很好,而且有几处BUG。我现在开源的代码中已经修复了BUG,而且有些地方做了一些改进。

  这本书对我的帮助很大,虽然作者比较啰嗦,代码风格也不是很好,但是作者写的很简单明了,只要是会写C程序的,就肯定能看懂。书中一步步的介绍了一个游戏脚本的实现过程,如果有点编译原理知识在结合这本书,那效果就会更好。一般编译原理相关的书籍中,实践的比较少,而且有实践的书籍在做词法分析器和语法分析器的时候,都是直接用lex以及yacc直接生成。让人少了一种成就感,对以后的学习兴趣会产生不小的负面影响。这本书中虽然实现的比较简单,但是代码都是手动写的。词法分析器手动写的状态机,语法分析用LL(递归下降)实现。看完之后让人有个很直观的了解。也比较有成就感。

  我把书中代码重新实现,然后改进了一些不足,但是我没有做过多的改进,因为我想保持它的简单性。

目录说明: xasm 目录下面是xscript的汇编器,编译的时候进入该目录,输入make就可以。

xvm 目录下面是xscript的虚拟机,编译的时候进入该目录,输入make就可以。

xcomplier 目录下面是xscript的编译器,编译的时候进入该目录,输入make就可以。

console 目录下面是个简单的控制台,编译的时候进入该目录,输入make就可以。

运行脚本方式: 进入test目录,下面有已经写好的测试程序t.xss,可以自己编译,也可以直接运行 t.xss.XSE文件。运行方式 ./xvm t.xss.XSE即可。

注意:运行的时候 xcomplier, xasm要放在同一目录才可进行xss脚本的编译工作。因为xcomplier 程序中会直接调用xasm程序。

xscript's People

Contributors

kiven-li avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.