Giter VIP home page Giter VIP logo

unoscript's Introduction

UnoScript

UnoScript is a general-purpose, stack-based programming language inspired by the UNO card game. It aims to maximize usability while meeting the constraint that every sequence of UNO cards is a valid program in the language.

This repository holds:

Building the Interpreter

The interpreter is written in C++, with dependencies on flex, gcc, and make.

To build the interpreter, open a terminal, cd into the project directory and run make. The Makefile expects that the executables flex and g++ are available on your terminal's PATH.

This will compile the interpreter source and create an executable named uno.

Running Programs

UnoScript programs can be run by passing them as input to the uno executable. By convention, UnoScript programs use the file extension ".uno".

For example, to run the hello world program, run this from the project root:

./uno < examples/hello_world.uno

Verbose Mode

To aid in writing UnoScript programs the interpreter provides a verbose mode.

In verbose mode, as each instruction is processed, the interpreter prints out:

  • The program source, with an arrow indicating the position of the head
  • The top five items on the stack

To enable this, pass the -v or --verbose flag to the interpreter, for example:

./uno --verbose < examples/hello_world.uno

Interpreting verbose output

For example, the output below shows an addition operation.

In the first state, a draw2 card is at the top of the stack with the head over a r0 card. The head reads the r0 card, pops the draw2 off the stack, and operates on the top two items on the stack.

r0 corresponds to addition, so the top of the stack is replaced with g0 + b1 = b1. The head moves to the next card.

-------------------------------
|r1   |b1   |draw2|r0   |draw2| (Tape)
-------------------------------
  55    56    57  ^ 58    59
-------------------------------
|y101 |b12  |g0   |b1   |draw2| (Stack)
-------------------------------

-------------------------------
|r1   |b1   |draw2|r0   |draw2| (Tape)
-------------------------------
  55    56    57    58  ^ 59
-------------------------------
|y108 |r108 |y101 |b12  |b1   | (Stack)
-------------------------------

Trademark Notes

According to the back of my UNO deck, Mattel, Inc. owns the "UNO" trademark. This project is not associated with Mattel in any way.

unoscript's People

Contributors

berlinquin avatar

Stargazers

Kacper Kostka avatar CHOSSY Lucas avatar Ectogen‮ avatar

Watchers

James Cloos 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.