Code Monkey home page Code Monkey logo

compilerrrrr's Introduction

my badge

CompilerRRRR

編譯器器器器器

This a final semester project of the course, Compiler.

Requirements

This project use:

  1. gcc version 4.6.1

  2. flex version 2.5.4

  3. bison(GNU bison) version 2.4.1

Simple installation tutorial(you can expand this tag)📖

Simple installation tutorial 📖

For gcc, you can install wxDev-C++ version 7.4.2 to get this gcc from this:

http://wxdsgn.sourceforge.net/

In website, choose the tab, "download"

In the tab page, "download", choose the download option, "wxDev-C++ Full Installer" to download.

Note that the installation could not including space.

After the installation completed, you need to set the environment variable.

In System Variable, choose the Path option and insert Your installation location.

At last, you need to run wxDevC++ to get the linking library. (they will show up in the following steps)

First of all, wxDevC++ will ask you to set the First-Run Configuration, Choose the language you are using.

Second, tick the "Yes, I want to use this feature".

Other configuration can keep the default.


For Flex, you can install from this:

http://gnuwin32.sourceforge.net/packages/flex.htm

In website, choose the download option, "Complete package, except sources" to download.

Note that the installation could not including space


For Bison, you can install from this:

http://gnuwin32.sourceforge.net/packages/bison.htm

In website, choose the download option, "Complete package, except sources" to download.

The installation location should be identical to Flex's.

Note that the installation could not installation space

After the installation completed, you need to set the environment variable.

In System Variable, choose the Path option and insert Your installation location.


Copy Linking Library

The linking library will show up after you complete First-Run Configuration of wxDev-C++.

Copy the 3 files of the directory "lib" that under the Flex's and Bison's root location.

Paste in the directory MinGW32\lib that under the wxDev-C++'s root location.


Testing installation results

type the script as followed

(Note that v is case-sensitive)

gcc -v

The version should be 4.6.1

The COLLECT_LTO_WRAPPER location should under the directory of wxDev-C++'s location.

(If not, may be the wrong version of gcc being caught)

flex -V

The version should be 2.5.4

bison -V

The version should be 2.4.1


Introduction ⚡

A "calculator" implemented with the Lex and Bison(Yacc's GNU version).

This calculator including Arithmetic Expression which can have operations Such like:

  1. Addition
  2. Subtraction
  3. Multiplication
  4. Division

Also support:

  1. Modulus
  2. Round brackets

API Functions 🗺:

Basic Mathematical Functions

+

-

*

/

%

Constant

pi:3.1415926

Trigonometric functions:

sin()

cos()

tan()

Floor and ceiling functions

ceil() = uGuass

uGuass() = ceil()

floor() = lGuass()

lGuass() = floor()

Other Mathematical Functions

abs():Absolute value.

sqrt():Square root.

log():The logarithm of X to base 10.

ln():The logarithm of X to base 2.

exp():Natural logarithm.

Usage(on Windows Command Prompt):

flex calculator_trail.l

It should produces lex.yy.c

bison -d Calculator.y

It should produces Calculator.tab.h and Calculator.tab.c

gcc -o Calculator Calculator.tab.c lex.yy.c -lfl

It should produces Calculator.exe

./Calculator.exe

It starts to run the calculator.

You can type any Arithmetic expression on terminal.

Usage_2(on Windows Command Prompt):

We create a windows batch file to simply the process of compiling and executing.

compile_and_run.bat Calculator

It should produces Calculator.tab.h, Calculator.tab.c, lex.yy.c and Calculator.exe.

Next it starts to run the calculator.

You can type any Arithmetic expression on terminal.

Examples 🖩

(You can use Pure_input.txt to enter into Terminal to see the results and you can see the details of Pure_input from DEMO_input.txt)


screenshot_1 screenshot_2 screenshot_3 screenshot_4

Here are examples that will cause error.

When an error occurred, the calculator will be terminated.

NG_screenshot_1 NG_screenshot_2 NG_screenshot_3 NG_screenshot_4

Empty characters also provoke an error.

NG_screenshot_5


Cheat Sheet(you can "copy and paste" on your Windows Command Prompt):

flex Calculator.l

bison -d Calculator.y

gcc Calculator.tab.c lex.yy.c -lfl

./Calculator.exe

compilerrrrr's People

Contributors

yeeoreo avatar junhua9981 avatar

Watchers

 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.