Giter VIP home page Giter VIP logo

compiler's Introduction

Pascal-S compiler

编译运行

在 docker 环境下装配好对应环境且进入程序目录后,输入如下命令

mkdir build
cd build
cmake ..
make

可执行程序使用方式

USAGE: exp <option> <source.pas>
OPTION:
  -l            Emit LLVM IR code (.ll)
  -S            Emit assembly code (.s)
  -c            Emit object code (.o)
  -ast          puts ast tree
  -o des        name output file as des
  -O            IR optimize
  • 对于生成的 LLVM IR 文件,输入 lli output.ll 可以执行编译后的程序
  • 对于生成的对应平台的 .s.o 文件,输入 cc output.scc output.o 可以得到对应平台的可执行文件

特性

  • 简单的数据类型:布尔型,字符型,整型,实数型,字符串型
  • 一维数组,结构体类型
  • 控制流:if-else,case-of,while-do,repeat-until,for
  • 定义:常量(const),类型(type),变量(var),子程序(routine)部分
  • 子程序(函数和过程)定义和调用
    • 包括一些系统函数:read(ln)(读取),write(ln)(输出),abs(绝对值),sqrt(平方根),chr(字符),ord(顺序),pred(前驱),succ(后继)
  • 运算符:+ - * / div(整除)mod(取模)and(与)or(或)xor(异或)not(非)以及比较运算符
  • 类型检查,从整型到实数型的隐式类型转换

TBD

  • 错误恢复
  • 闭包函数
  • 二维数组,复杂的结构体

compiler's People

Contributors

laokashouji avatar kardusenor avatar qcnace 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.