Skip to content

Commit

Permalink
Initial commit of files harvested from old min-koi project.
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongough committed Aug 30, 2010
0 parents commit da2ebfc
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 0 deletions.
20 changes: 20 additions & 0 deletions MIT-LICENSE
Original file line number Original file line Diff line number Diff line change
@@ -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 changes: 83 additions & 0 deletions README.rdoc
Original file line number Original file line Diff line number Diff line change
@@ -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 changes: 45 additions & 0 deletions Rakefile
Original file line number Original file line Diff line number Diff line change
@@ -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 changes: 14 additions & 0 deletions bin/minkoi
Original file line number Original file line Diff line number Diff line change
@@ -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 )

0 comments on commit da2ebfc

Please sign in to comment.