Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit of files harvested from old min-koi project.

  • Loading branch information...
commit da2ebfcebf8f06332966ec959c8160fd62206077 0 parents
@aarongough authored
Showing with 162 additions and 0 deletions.
  1. +20 −0 MIT-LICENSE
  2. +83 −0 README.rdoc
  3. +45 −0 Rakefile
  4. +14 −0 bin/minkoi
20 MIT-LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2010 Aaron Gough (http://thingsaaronmade.com/)
+
+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.
83 README.rdoc
@@ -0,0 +1,83 @@
+= MinKoi
+
+MinKoi is a small programming language that is designed to be easy to use, easy to understand and easy to implement.
+
+=== Example
+
+This is an old-school 'Blast Off!' program written in MinKoi:
+
+ countdown = function( count )
+ print( to_string( count ))
+ print( ", " )
+ if( count == 0 )
+ return()
+ end
+ count = count - 1
+ call( countdown, count )
+ end
+
+ call( countdown, 10 )
+
+ print( "Blast Off!" )
+
+ #=> 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, Blast Off!
+
+
+=== More Info
+
+MinKoi was conceived as an intermediate language in which it would be possible to implement higher-level languages and their object models, to this end flexibility is one of it's primary goals.
+
+MinKoi is an imperative, dynamic, weakly-typed language with first-class functions. MinKoi's syntax is influenced by JavaScript, Lua and Ruby, but works very hard to be unambiguous so that it is easy to write parsers for (in stark contrast with Ruby).
+
+=== Goals
+
+* Ease of use
+* Ease of implementation
+* Ease of modification
+* Flexibility
+* Speed
+
+=== Data types
+
+MinKoi features a full set of basic data types including:
+
+* Nil
+* Boolean
+* Integer
+* Float
+* String
+* Function
+
+(array and hash coming soon!)
+
+=== Flow control
+
+MinKoi currently only implements a minimal set of flow control operators:
+
+ if( expression )
+ call( do_work )
+ endif
+
+ unless( expression )
+ call( do_other_work )
+ endunless
+
+=== Built-in functions
+
+print( string ):: Writes a string to STDOUT.
+gets():: Fetches a newline delimited string from STDIN.
+call( identifier [, parameter]):: Calls the function that is stored in 'identifier'.
+tailcall( identifier[, parameter]):: Performs a 'tailcall' to the function stored in 'identifier'. This type of call is used when recursing heavily to improve performance and to facilitate the use of functions as iterators.
+return( [value] ):: Return a value from a function.
+to_string( value/identifier ):: Converts the given value to a representative string.
+type_of( value ):: Returns a string representing the type of the value given, eg: "integer".
+
+=== Reserved words
+
+if, endif, unless, endunless, function, endfunction, call, tailcall, print, gets, return, to_string, type_of, nil, true, false
+
+=== Author & Credits
+
+Author:: {Aaron Gough}[mailto:aaron@aarongough.com]
+
+Copyright (c) 2010 {Aaron Gough}[http://thingsaaronmade.com/] ({thingsaaronmade.com}[http://thingsaaronmade.com/]), released under the MIT license
45 Rakefile
@@ -0,0 +1,45 @@
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+desc 'Default: run unit tests.'
+task :default => :test
+
+begin
+ require 'jeweler'
+ Jeweler::Tasks.new do |gemspec|
+ gemspec.name = "min-koi"
+ gemspec.summary = "A Parser and compiler for the MinKoi language."
+ gemspec.description = "A modular compilation toolchain for the MinKoi language."
+ gemspec.email = "aaron@aarongough.com"
+ gemspec.homepage = "http://github.com/aarongough/min-koi"
+ gemspec.authors = ["Aaron Gough"]
+ gemspec.rdoc_options << '--line-numbers' << '--inline-source'
+ gemspec.extra_rdoc_files = ['README.rdoc', 'MIT-LICENSE']
+ gemspec.add_dependency('treetop')
+ gemspec.add_dependency('koi-vm')
+ gemspec.executables << 'minkoi'
+ end
+rescue LoadError
+ puts "Jeweler not available. Install it with: gem install jeweler"
+end
+
+
+desc 'Test MinKoi.'
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib/*.rb'
+ t.libs << 'test'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+end
+
+
+desc 'Generate documentation for MinKoi.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'MinKoi'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README.rdoc')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+ rdoc.rdoc_files.include('app/**/*.rb')
+end
14 bin/minkoi
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+
+require 'rubygems'
+require 'koi-vm'
+require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'min-koi.rb'))
+
+data = ARGF.read
+
+tree = Parser.parse(data)
+
+bytecode = MinKoiCompiler.compile(tree)
+
+vm = KoiVM::VM.new
+vm.run( bytecode )
Please sign in to comment.
Something went wrong with that request. Please try again.