Code Monkey home page Code Monkey logo

cs152lab1's Introduction

CS152 Lab: A Calculator Example

home page for lab1

Tools preparation

Make sure you have a Linux environment for this project. You can use 'bolt', your own Linux machine, or Windows Subsystem for Linux(WSL). I highly recommend you directly use 'bolt' since it contains all the necessary tools preinstalled.

ssh <your-net-id>@bolt.cs.ucr.edu

Make sure you have the following tools installed and check the version:

  1. flex -V (>=2.5)
  2. git --version (>=1.8)
  3. make -v (>=3.8)
  4. gcc -v (>=4.8)
  5. g++ -v (>=4.8 optional if you wish to use C++)

Clone

Use 'git' to clone the project template:

    git clone <your-repo-link> lab1

Check Your Tasks for Lab 1

Read the documentation of flex and your tasks in home page for lab1. From this starter template, you can edit 'calc.lex' to finish tasks step by step.

Using Flex to generate C source code

Here is a basic FLEX tutorial: http://alumni.cs.ucr.edu/~lgao/teaching/flex.html

flex can generate C source code of a lexer using flex specification 'calc.lex' in our lab.

flex -o calc.c calc.lex

After generate the C code, we can use gcc to compile it and link flex library 'fl' to support its functionailty.

gcc calc.c -lfl -o calc

The lexer will read from STDIN and tokenize your input stream by running actions defined in your specification.

We recommand you to write a Makefile to avoid typing these commands repeatly.

Keep your progress by uploading to Github

After you finish all 4 tasks, you are done the first part of this lab. You don't need to submit the code but should keep your progress until next time when we start learning syntax analysis.

Uploading to Github is a safe way:

git add .  # add all files under current folder to staged changes
git commit -m "lab1 - lexer"  # create a new commit
git push   # upload to Github, it may requires your username and password of Github

cs152lab1's People

Contributors

jwalk057 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.