Giter Site home page Giter Site logo

pascal's Introduction

Pascal

a pascal compiler implemented by LLVM 3.5.1.

This is the final project of the course Compiler Course Design in ZJU. Sorry for bugs and lacking of documents

Current Status: in Updating docs

Authors

Build

  • llvm 3.5.1 (must be)
  • -std=stdc++11 (see more in makefile)
  • Mac OSX (recommended)

Pascal Grammar Support

Details about grammar support can be found in yacc source file pascal.y

Type

  • Integer
  • Real
  • Char
  • Bool
  • Record (imperfectly)
  • Array (imperfectly)

Control flow

  • if statement
  • for statement
  • repeat statement
  • while statement
  • case statement
  • goto statement (imperfectly)

Others

  • function/procedure declaration/execution
  • binary operators
  • system functions
    • read/readln
    • write/writeln

References

  • LLVM官网教程

http://llvm.org/docs/tutorial/index.html

  • 使用 LLVM 框架创建一个工作编译器,这里有IR的教程

http://www.ibm.com/developerworks/cn/opensource/os-createcompilerllvm1/

  • 一个完整的flex+bison+llvm的例子

http://www.cppblog.com/woaidongmao/archive/2009/11/11/100693.aspx

  • 例子源代码

https://github.com/lsegal/my_toy_compiler

  • 另外一个例子

http://my.oschina.net/linlifeng/blog/97457

pascal's People

Contributors

denil1111 avatar gnnng avatar lyt9304 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

Watchers

 avatar  avatar  avatar  avatar

pascal's Issues

check multiple declaration

program llvm;
var a, b, c: integer; a, b, c: integer;
...

Codes like this will pass the check, a,b,c should not be allowed to declared again.
Need to reimplement the function getValue of CodeGenBlock, and check if a symbol has not been declared

Error in Make/Build!

$ make

g++ -c `/usr/local/opt/llvm35/bin/llvm-config-3.5 --cppflags` -std=c++11 -Wno-return-type -Wno-c++11-compat-deprecated-writable-strings -Wno-deprecated-register -Wno-switch  -g -o parser.o parser.cpp 
/bin/sh: 1: /usr/local/opt/llvm35/bin/llvm-config-3.5: not found
In file included from pascal.y:7:0:
ast.h:4:27: fatal error: llvm/IR/Value.h: No such file or directory
 #include "llvm/IR/Value.h"
                           ^
compilation terminated.
makefile:27: recipe for target 'parser.o' failed
make: *** [parser.o] Error 1

How fix?

Friendly Error Prompt and Recovery

Two sets of error:

  1. compile error
  2. running error

More subtypes in each set. E.g. syntax error and invalid type error are both compile errors

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.