Giter Club home page Giter Club logo

pascal-compiler's Introduction

pascal-compiler

this is a pascal compiler which can translate pascal code to x86 assembly language. easy to use, try it!

compile and run

this project can only run in Linux, make sure you have flex and bison. if you don't have, please install:

sudo apt-get install flex
sudo apt-get install bison

after install, you can run it

make
./main x.spl y.asm
# such as: ./main test/test2.spl test/test2.asm
# you can input 'make clean' to delele .o file

file decription

├── absyn.cpp           for abstract tree 
├── absyn.h             for abstract tree
├── absyn.o
├── codegen.cpp         for code generate 
├── codegen.h           for code generate
├── codegen.o
├── colorconsole.h      add console color
├── gendefine.h         code generate class define
├── lex.l               lexical analysis
├── lex.yy.c
├── lex.yy.o
├── main                main
├── main.cpp            main function
├── main.o
├── Makefile            makefile
├── symboldefine.h      symbol table define
├── symboltable.cpp     for symbol table
├── symboltable.h       for symbol table
├── symboltable.o
├── testspl             test
│   ├── test2.asm
│   ├── test2.spl
│   ├── test4.asm
│   ├── test4.spl
│   ├── test6.asm
│   └── test6.spl
├── typemap.h           enum-string map
├── yacc.tab.c
├── yacc.tab.h
├── yacc.tab.o
└── yacc.y              syntax analysis

work finished

Scanning. Using Lex √
Parsing. Using Yacc √
Semantic Analysis √
Error detection √(simple)
Error recovery √(simple)
Symbol table, type checking √
Code generation Target: MASM √
Runtime environment √
Optimization √(simple)

middle code generate ×

support

Type:

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

statement

  • if statement
  • for statement
  • repeat statement
  • while statement
  • case statement
  • goto statement

system function

  • write
  • writeln
  • read

other

  • variable
  • type
  • function
  • procedure

finally

please forgive a little bug ^_+

pascal-compiler's People

Contributors

yinxiaojian avatar

Stargazers

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

Watchers

 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.