GithubHelp home page GithubHelp logo

baseline0 / cyprus Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gatesphere/cyprus

0.0 0.0 0.0 6.37 MB

A membrane-computing oriented programming language

License: Other

Python 99.36% Makefile 0.30% Shell 0.33%

cyprus's Introduction

cyprus

A membrane-computing oriented programming language

Overview

Cyprus is a programming language based on the concept of a P System.

Computation is modeled as chemical reactions happening within protocellular constructions, producing new chemicals.

License

Cyprus is BSD Licensed.


Terminology

Cyprus uses several unique terms when it comes to programming languages. These are described below.

  • Container - an object that holds membranes, particles, and reaction definitons.

  • Environment - a container that cannot be dissolved, nor whose walls can be permeated. A Cyprus program consists of at least one, possibly many, environment definitions.

  • Membrane - a container nested within an environment or another membrane. Membranes can be dissolved and their walls can be permeated.

  • Particle - a chemical, required for reactions to take place, and produced by reactions.

  • Reaction - a rule governing the interaction of particles within a membrane.

  • Priority - an ordering of reactions. Reactions with a higher priority will be maximally applied before those with a lower priority.


How Cyprus Works

Cyprus is governed by a single monolithic clock. All activity within all environments occurs in lockstep with the tick of the clock. Each tick, all reactions that are applicable within a given container are applied maximally, obeying reaction priorities.

The clock stops ticking when no more reaction applications can occur. At this point, the particles contained by the environments are interpreted as the final output of the program, with everything else left in the system discarded as leftover state.

During the execution of a Cyprus program, membranes may dissolve, destroying their reaction defenitions with them, but spilling their particles into their parent container. Environments cannot dissolve.

Particles may also osmose through their containing membrane's walls, either targeting their container's parent, or a specific membrane by way of names.

Using named targets, a particle can osmose deeper into nested membranes, or pass through multiple containing membranes. Environments cannot be osmosed through, though particles may osmose over environmental boundaries.

Reaction application is maximal, but non-deterministic: reactions are applied in any valid order which obeys the assigned reaction priorities.

Cyprus is a Turing complete language, though using it for anything other than fun and experimentation would be insane. It is therefore an extremely losely defined Turing Tarpit.


Install and Usage

Getting Cyprus

  1. Ensure you have Python3 2.7 installed (not Python 3+!)
  2. Install funcparser lib with pip install funcparserlib
  3. Clone this repo

Using Cyprus

Usage:

    $ python cyprus.py
    usage: python cyprus.py [-p | -V] <filename.cyp>
           python cyprus.py -v
           python cyprus.py -h
      -p: pretty-print(a parse tree and exit
      -V: display verbose output of the program's execution
      -v: display version info and exit
      -h: display this help text and exit

Convenience tools include:

Edit

    run.sh 

or add to Makefile.


Cyprus' grammar

Here's the grammar, in a modified EBNF:

program        := {env}
env            := "[", body, "]"
membrane       := "(", body, ")"
body           := <name>, {statement}
statement      := membrane | expr
expr           := exists | reaction | priority
exists         := "exists", "~", name, {name}
reaction       := "reaction", <"as", name>, "~", name, {name}, "::",
                   {symbol} 
priority       := "priority", "~", name, ">>", name
name           := number | atom
atom           := [A-Za-z], {[A-Za-z0-9]}
number         := [0-9], {[0-9]} | {[0-9]}, ".", [0-9], {[0-9]}
symbol         := atom | "!", name, <"!!", name> | "$", [name]

see examples/README.md

Those examples, along with the grammar, show pretty much all you need to know about writing Cyprus programs.

Planned features

  • Particle and membrane charges
  • Variable membrane permeability
  • Syntactic sugar for catalysts (reaction~ *x :: x == reaction~ x :: x x)
  • Clean up code (remove globals, comment, etc.)

WIP

python3 compatibility

cyprus's People

Contributors

baseline0 avatar gatesphere 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.