GithubHelp home page GithubHelp logo

cmaes / logoturtle Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 2.0 3.02 MB

An implementation of the Logo (turtle graphics) language in ocaml

Home Page: http://cmaes.github.io/logoturtle/

Makefile 2.98% OCaml 49.59% HTML 13.57% JavaScript 32.25% Python 1.61%

logoturtle's Introduction

A Logo Interperter in Ocaml (and Javascript)

A tree created in Logo

Try the interperter in your browser

Visit http://cmaes.github.io/logoturtle/

See this page for sample programs and their graphical output.

Installation

The following directions describe how to install the dependencies for running the code locally.

Install OCAML

Use the Real World OCAML installation instructions https://github.com/realworldocaml/book/wiki/Installation-Instructions

On Linux

$ sudo add-apt-repository ppa:avsm/ppa
$ sudo apt-get update
$ sudo apt-get install curl build-essential m4 ocaml opam

Then do

opam init
eval `opam config env`

On Mac

Install Homebrew http://brew.sh.

brew install ocaml
brew install opam

Then do

opam init
eval `opam config env`

Install ocamlfind

opam install ocamlfind

Install the Cairo Ocaml bindings

https://github.com/Chris00/ocaml-cairo

opam install cairo2

Install Dependencies

opam install core
opam install menhir
opam install lwt

Install js_of_ocaml

opam install js_of_ocaml
opam install js_of_ocaml-camlp4

Building the Logo Interperter

There are two different builds of the interperter:

  • A interpreter that runs from the command-line and uses Cairo as backend to output .png files from Logo programs

  • A interpreter that runs from Javascript and uses a Canvas backend to output graphics from Logo programs in the browser

Building the Command-line Interpreter

Issuing the following command to build both.

make

will build and run a program called logo.native. It creates a file named tree.png that should contain a tree.

To clean up do

make clean

Building the Javascript Interpreter

Issuing the following command

make logoweb.js

will build a Javascript library containing the interpreter. The file index.html shows how this library may be used from Javascript via the interpetLOGO command.

Logo Grammar

I made my own up. But there is one here

logoturtle's People

Contributors

cmaes avatar rabarar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

rabarar ghuysmans

logoturtle's Issues

Logo grammar has one shift/reduce conflict

This is related to unary minus

Warning: one state has shift/reduce conflicts.
Warning: one shift/reduce conflict was arbitrarily resolved.

Here is parser.conflict

** Conflict (shift/reduce) in state 61.
** Token involved: MINUS
** This state is reached from prog after reading:

ID rev_args_list expr 

** The derivations that appear below have the following common factor:
** (The question mark symbol (?) represents the spot where the derivations begin to differ.)

prog 
command_list EOF 
rev_command_list 
command 
ID args_list 
   rev_args_list 
   (?)

** In state 61, looking ahead at MINUS, shifting is permitted
** because of the following sub-derivation:

rev_args_list expr 
              arith 
              expr . MINUS expr 

** In state 61, looking ahead at MINUS, reducing production
** rev_args_list -> rev_args_list expr 
** is permitted because of the following sub-derivation:

rev_args_list expr // lookahead token appears because expr can begin with MINUS
rev_args_list expr . 

Pattern matching for expression evaluator is not exhaustive

OCaml gives the following error:

File "logoturtle.ml", line 226, characters 22-121:
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
(Plus (_, _)|Minus (_, _)|Times (_, _)|Divide (_, _)|Negate _|Or (_, _)|
And (_, _)|Not _|Less (_, _)|Greater (_, _)|Equal (_, _)|NEqual (_, _)|
LessEq (_, _)|GreaterEq (_, _))

But it looks to me like it is covering all the cases.

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.