Giter Site home page Giter Site logo

crab's Introduction

Introduction

It's called Crab because it can be confused with crap. Why you'd ever use this for anything is beyond my comprehension, but here it is nonetheless. This started as a console replica, but as with the Windows console, you can create .bat files which will execute a bunch of commands automatically. I soon realized that this could become some sort of language, but it didn't quite work as i wanted it to, so i started anew and abandon the old project: https://github.com/JonasUJ/console

NOTE

About 1 year later me speaking: My adventures on the internet took me across LISP... This seems to be almost the same language as Crab ¯\(ツ)/¯, what can I say other than that someone obviously stole my idea.

Crab

The new project is a bunch of methods and a parser that calls the methods. The keyword cal has a specific method do_cal which is called when the parser finds a cal in the code. The methods also get some arguments, ofcourse, cal 2 * 4 calls do_cal with the arguments 2, * and 4. do_cal then does something and returns a value, the value is then directly placed in the code and the parser moves on.

This means that this:

cal 1 + 2 * 3

Becomes:

7

Which isn't very useful since we don't do anything with the 7, just put it in the code until the program finishes executing.

Embeds

This is where embeds come in, they let you have multiple commands on one line. They work by basically replacing the embed with the returned value and thereby creating a new command. We can use this to output the 7:

cout {cal 1 + 2 * 3}

Will become:

cout 7

Which doesn't return anything, but cout outputs its arguments to the console. You can also have embeds inside other embeds:

cout {cal 5 * {cal 5 - 3}}

This outputs 10. Embedded embeds are executed recursivly from back to front inside out, if that makes sense. Here the are labelled 1-6 in order of execution:

6 {5 {4 {2} {1}} {3}}

Documentation

For documentation on what commands exists and how keywords behave take a look in the examples folder https://github.com/JonasUJ/crab/tree/master/Examples

crab's People

Contributors

jonasuj avatar

crab's Issues

Embedded commands that cause errors

When an embedded command causes an error, it doesn't get handled very well. I've had scripts just stop without an error message because of this

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.