GithubHelp home page GithubHelp logo

makenowjust / brat Goto Github PK

View Code? Open in Web Editor NEW

This project forked from presidentbeef/brat

0.0 3.0 0.0 14.11 MB

Brat is a little language for people who don't like to be told what to do.

Home Page: http://brat-lang.org

Terra 0.04% Shell 2.53% Lua 53.05% Vim Script 0.02% C 38.91% Makefile 1.37% CSS 0.13% HTML 3.20% Roff 0.02% C++ 0.69% Python 0.03% Perl 0.02%

brat's Introduction

Brat

Brat is a simple and flexible little toy language.

Brat uses a PEG parser to compile to Lua and executes using LuaJIT.

Brat is flexible enough that you can get by with a very small core and write any functionality that most languages use keywords for. For example, you can write and use a while loop like so:

#Loops until the block returns false
while = { block |
    true? block, { while ->block }
}

n = 1
while {
    p n
    n = n + 1
    n < 10
}

If you would rather have your conditions be separated out, you could define it this way instead:

#Loops until condition is false
while = { condition, block |
    true? condition, { block; while ->condition, ->block }
}   

n = 1 
while { n < 10 } { p n; n = n + 1 }

Features

  • Typeless, and pretty much classless
  • Everything is object, except functions
  • And functions are closures, which can be attached to objects to make methods
  • Objects use a prototyping system and are completely open
  • Built in hash tables and dynamic arrays
  • Very flexible unary and binary operators
  • Tail calls are optimized to make infinite loops faster (and more infinite)

Requirements

Please have on hand:

  • Linux or OS X
  • The usual development tools (like make and gcc)
  • OpenSSL headers (sudo urpmi libssl-devel or similar)
  • Git if you want to check it out of the repository directly - sudo urpmi git-core (or the equivalent for your platform)

Installation

Please follow the following steps, in the order in which they are ordered. Otherwise, results are not guaranteed.

With Git:

  1. Clone the latest Brat version: git clone git://github.com/presidentbeef/brat.git
  2. Change to new directory: cd brat
  3. Run sh ./build.sh
  4. Optionally, run sudo sh ./install.sh. This will install in /usr by default. Append a directory to change this.

Without Git:

  1. Download the latest
  2. Decompress the archive (unzip brat-master.zip)
  3. Change to the new directory (cd brat-master)
  4. Run sh ./build.sh
  5. Optionally, run sudo sh ./install.sh. This will install in /usr by default. Append a directory to change this.

Testing

Try out your newly discovered power thusly:

  1. Create a new file, perhaps called test.brat
  2. In that file, type something like: p "OK COMPUTER"
  3. Save and close it
  4. Return to the comfort of your command line
  5. Type brat test.brat (or ./brat test.brat if you did not run the install script)
  6. Cross fingers
  7. Press enter
  8. Marvel or weep, as appropriate

More Testing

Run brat test/test.brat to run the test suite. SWEET.

More fun

Running Brat without specifying a file will launch interactive mode.

Even more fun

Take a look at some examples of Brat code.

Problems

Sometimes there are problems. Everyone has issues. Report Brat issues here.

License

The MIT License

Copyright (c) 2010-2014, Justin Collins

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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.