nil

nil is a brain**** language macro language and interpreter.

Macro language

nil supports a few macros that get expanded to vanilla brain**** code.

Numbered commands

The commands >, <, +, and - can be given a number to repeat that command. For example:

+5 will be expanded into ++++++

Macros

Macros can be defined and referenced. However, since they are only expanded, they cannot recurse.

Macros are defined in the form of :sub_name{code} and are called in the form of sub_name:

Example:

:add_two{++}add_two:

will be expanded to:

++

Including other files

Other files can be included in the current one. Files are included in the format of: .include(file.nil)

Comments

Unlike regular brain**** where everything is treated as a comment, only lines looking like such are comments:

;this is a comment;

Comments must include both semicolons.

Modes

The original brain**** specification calls for buffers to be output as ASCII text. However, sometimes outputting numbers is more useful. Nil allows modes to be set. In the nil code, the line:

.mode(mode)

Will be used to set the mode. The mode can either be num or ascii. The default mode is ascii.

Interpreter

nil also interprets brain**** code.

Installing

Add this line to your application's Gemfile:

gem 'nil'

And then execute:

$ bundle

Or install it yourself as:

$ gem install nil

Usage

require 'nil'

code = "+4."

mc = Nil::MacroCompiler.new
commands = mp.compile code

commands.run

Run nil -h for command line tool usage.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request