schaefer 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/.DS_Store +0 -0
  2. data/.gitignore +17 -0
  3. data/Examples/.DS_Store +0 -0
  4. data/Examples/exampleAdd.sch +2 -0
  5. data/Examples/exampleAdd.sch~ +8 -0
  6. data/Examples/exampleDisplay.sch +1 -0
  7. data/Examples/exampleDisplay.sch~ +1 -0
  8. data/Examples/exampleDo.sch +8 -0
  9. data/Examples/exampleDo.sch~ +8 -0
  10. data/Examples/exampleFunction.sch +11 -0
  11. data/Examples/exampleFunction.sch~ +11 -0
  12. data/Examples/exampleFunction2.sch +4 -0
  13. data/Examples/exampleGets.sch +7 -0
  14. data/Examples/exampleIf.sch +12 -0
  15. data/Examples/exampleIf.sch~ +13 -0
  16. data/Examples/exampleWrite.sch +1 -0
  17. data/Examples/exampleWrite.sch~ +5 -0
  18. data/Gemfile +4 -0
  19. data/LICENSE +22 -0
  20. data/README.md +29 -0
  21. data/Rakefile +2 -0
  22. data/bin/.DS_Store +0 -0
  23. data/bin/schaefer +35 -0
  24. data/lib/.DS_Store +0 -0
  25. data/lib/schaefer/.DS_Store +0 -0
  26. data/lib/schaefer/.environment.rb.swp +0 -0
  27. data/lib/schaefer/Library/.DS_Store +0 -0
  28. data/lib/schaefer/Library/additionOperator.sch +7 -0
  29. data/lib/schaefer/Library/display.sch +7 -0
  30. data/lib/schaefer/Library/display.sch~ +7 -0
  31. data/lib/schaefer/Library/do.sch +11 -0
  32. data/lib/schaefer/Library/do.sch~ +11 -0
  33. data/lib/schaefer/Library/equalTo.sch +8 -0
  34. data/lib/schaefer/Library/equalTo.sch~ +6 -0
  35. data/lib/schaefer/Library/function.sch +57 -0
  36. data/lib/schaefer/Library/if.sch +10 -0
  37. data/lib/schaefer/Library/if.sch~ +10 -0
  38. data/lib/schaefer/Library/input.sch +6 -0
  39. data/lib/schaefer/Library/write.sch +7 -0
  40. data/lib/schaefer/Library/write.sch~ +7 -0
  41. data/lib/schaefer/environment.rb +20 -0
  42. data/lib/schaefer/interpreter.rb +45 -0
  43. data/lib/schaefer/parser.rb +87 -0
  44. data/lib/schaefer/parser.rb~ +87 -0
  45. data/lib/schaefer/version.rb +3 -0
  46. data/lib/schaefer.rb +3 -0
  47. data/schaefer.gemspec +17 -0
  48. metadata +113 -0
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
Binary file
@@ -0,0 +1,2 @@
1
+ (add 1 2 3 4 5)
2
+
@@ -0,0 +1,8 @@
1
+ (define add(native_function "Proc.new do |arguments, interpreter|
2
+ tmp = arguments.map {|item| interpreter.evaluate(item)}
3
+ tmp.inject {|sum, n| sum + n}
4
+ end
5
+ "))
6
+
7
+ (add 1 2 3 4 5)
8
+
@@ -0,0 +1 @@
1
+ (display "hello")
@@ -0,0 +1 @@
1
+ (display "hello")
@@ -0,0 +1,8 @@
1
+ (define one 1)
2
+ (define won 1)
3
+
4
+ (if (equal? one won)
5
+ (do
6
+ (display "1 and 1 are equal")
7
+ (write " and thats a fact"))
8
+ (write "1 and 1 are not equal!")
@@ -0,0 +1,8 @@
1
+ (define one 1)
2
+ (define won 1)
3
+
4
+ (if (equal? one won)
5
+ (do
6
+ (display "1 and 1 are equal")
7
+ (write " and thats a fact"))
8
+ (write "1 and 1 are not equal!")
@@ -0,0 +1,11 @@
1
+ (define program
2
+ (function ()
3
+ (display "Enter password (Hint its password): ")
4
+ (define response (input))
5
+ (if (= response "password")
6
+ (write "Great Job!")
7
+ (do
8
+ (write "Im sorry. Thats incorrect!")
9
+ (program)))))
10
+
11
+ (program)
@@ -0,0 +1,11 @@
1
+ (define program
2
+ (lambda ()
3
+ (display "Enter password (Hint its password): ")
4
+ (define response (input))
5
+ (if (= response "password")
6
+ (write "Great Job!")
7
+ (do
8
+ (write "Im sorry. Thats incorrect!")
9
+ (program)))))
10
+
11
+ (program)
@@ -0,0 +1,4 @@
1
+ (define double
2
+ (function (x) (+ x x)))
3
+
4
+ (write (double 5))
@@ -0,0 +1,7 @@
1
+ (display "Enter password (Hint: its password): ")
2
+ (define result (input))
3
+
4
+ (if(= result "password")
5
+ (write "Excellent!")
6
+ (write "Wrong!")
7
+
@@ -0,0 +1,12 @@
1
+ (define one 1)
2
+ (define won 1)
3
+ (define two 2)
4
+
5
+ (if (= one won)
6
+ (write "1 = 1")
7
+ (write "1 != 1"))
8
+
9
+ (if (equal? one two)
10
+ (write "1 = 2")
11
+ (write "1 != 2"))
12
+
@@ -0,0 +1,13 @@
1
+ (define one 1)
2
+ (define won 1)
3
+ (define two 2)
4
+ (define too 2)
5
+
6
+ (if (= one won)
7
+ (begin(write "1 = 1")(write "Woohoo!"))
8
+ (write "1 != 1"))
9
+
10
+ (if (equal? one two)
11
+ (write "1 = 2")
12
+ (write "1 != 2"))
13
+
@@ -0,0 +1 @@
1
+ (write "hello")
@@ -0,0 +1,5 @@
1
+ (define tommy "Tommy")
2
+ (define schaefer "Schaefer")
3
+ (define first tommy)
4
+ (define last schaefer)
5
+ (write (add first " " last))
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in schaefer.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Tommy Schaefer
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Schaefer
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'schaefer'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install schaefer
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/bin/.DS_Store ADDED
Binary file
data/bin/schaefer ADDED
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'stringio'
4
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'schaefer.rb'))
5
+
6
+ interpreter = Schaefer::Interpreter.new
7
+
8
+ if ARGV.length > 0
9
+ if ARGV[0] == "-v"
10
+ puts "=> " + interpreter.run(File.read(ARGV[1])).inspect
11
+ else
12
+ interpreter.run(File.read(ARGV[0]))
13
+ end
14
+ exit
15
+ end
16
+
17
+ loop do
18
+ program = []
19
+ indent = 0
20
+ loop do
21
+ print "> " + (" " * indent)
22
+ program << gets
23
+ tmpProgram = program.join(" ")
24
+ openCount = tmpProgram.count("(")
25
+ closeCount = tmpProgram.count(")")
26
+ break if openCount == closeCount
27
+ indent += 1 if program.last.count("(") > program.last.count(")")
28
+ indent -= 1 if program.last.count("(") < program.last.count(")")
29
+ end
30
+ program = program.join(" ")
31
+ exit if program.strip == "quit"
32
+ result = interpreter.run(program)
33
+ puts "\n=> #{result.inspect}"
34
+ end
35
+
data/lib/.DS_Store ADDED
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,7 @@
1
+ (define +
2
+ (native_function "
3
+ Proc.new do |arguments, interpreter|
4
+ tmp = arguments.map {|item| interpreter.evaluate(item)}
5
+ tmp.inject {|sum, n| sum + n.to_i}
6
+ end
7
+ "))
@@ -0,0 +1,7 @@
1
+ (define display
2
+ (native_function "
3
+ Proc.new do |arguments, interpreter|
4
+ output = interpreter.evaluate(arguments[0])
5
+ print output
6
+ end
7
+ "))
@@ -0,0 +1,7 @@
1
+ (define display
2
+ (native_function "
3
+ Proc.new do |arguments, interpreter|
4
+ output = interpreter.evaluate(arguments[0])
5
+ print output
6
+ end
7
+ "))
@@ -0,0 +1,11 @@
1
+ (define do
2
+ (native_function "
3
+ Proc.new() do |arguments, interpreter|
4
+ val = nil
5
+ arguments.each do |i|
6
+ val = interpreter.evaluate(i)
7
+ end
8
+
9
+ val
10
+ end
11
+ "))
@@ -0,0 +1,11 @@
1
+ (define begin
2
+ (native_function "
3
+ Proc.new() do |arguments, interpreter|
4
+ val = nil
5
+ arguments.each do |i|
6
+ val = interpreter.evaluate(i)
7
+ end
8
+
9
+ val
10
+ end
11
+ "))
@@ -0,0 +1,8 @@
1
+ (define equal?
2
+ (native_function "
3
+ Proc.new do |arguments, interpreter|
4
+ !(arguments.map {|x| interpreter.evaluate(x) == interpreter.evaluate(arguments[0])}).include?(false)
5
+ end
6
+ "))
7
+
8
+ (define = equal?)
@@ -0,0 +1,6 @@
1
+ (define equal?
2
+ (native_function "
3
+ Proc.new do |arguments, interpreter|
4
+ !(arguments.map {|x| interpreter.evaluate(x) == interpreter.evaluate(arguments[0])}).include?(false)
5
+ end
6
+ "))
@@ -0,0 +1,57 @@
1
+ (define function
2
+ (native_function "
3
+ Proc.new() do |arguments, interpreter|
4
+ formals = arguments[0]
5
+ body = arguments.slice(1, arguments.length)
6
+
7
+ if formals.is_a? Array
8
+ # detect if any formal names have been used more than once
9
+ error_message = 'Formal {FORMAL} declared more than once'
10
+ formals.each_index do |x|
11
+ tmp = formals.dup
12
+ tmp.delete_at(x)
13
+ raise(error_message.gsub('{FORMAL}', formals[x])) if tmp.include? formals[x]
14
+ end
15
+ end
16
+
17
+ sub_env = Schaefer::Environment.new(interpreter.current_environment)
18
+
19
+ execute_body = Proc.new() do |body, environment, interpreter|
20
+ interpreter.current_environment = environment
21
+ result = nil
22
+ body.each do |expression|
23
+ result = interpreter.evaluate(expression)
24
+ end
25
+ interpreter.current_environment = environment.parent
26
+ result
27
+ end
28
+
29
+ if formals.is_a?(Array) && formals.include?(:'.')
30
+ Proc.new() do |arguments, interpreter|
31
+ args = arguments.dup
32
+ named_formals = formals.slice(0, formals.index(:'.'))
33
+ list_formal = formals[formals.index(:'.') + 1]
34
+ named_formals.each_index do |i|
35
+ sub_env.define(named_formals[i], interpreter.evaluate(args.shift))
36
+ end
37
+ sub_env.define(list_formal, args)
38
+ execute_body.call(body, sub_env, interpreter)
39
+ end
40
+
41
+ elsif formals.is_a? Array
42
+ Proc.new() do |arguments, interpreter|
43
+ formals.each_index do |i|
44
+ sub_env.define(formals[i], interpreter.evaluate(arguments[i]))
45
+ end
46
+ execute_body.call(body, sub_env, interpreter)
47
+ end
48
+
49
+ elsif formals.is_a? Symbol
50
+ Proc.new() do |arguments, interpreter|
51
+ arguments = arguments.map {|x| interpreter.evaluate(x) }
52
+ sub_env.define(formals, arguments)
53
+ execute_body.call(body, sub_env, interpreter)
54
+ end
55
+ end
56
+ end
57
+ "))
@@ -0,0 +1,10 @@
1
+ (define if
2
+ (native_function "
3
+ Proc.new do |arguments, interpreter|
4
+ if(interpreter.evaluate(arguments[0]))
5
+ interpreter.evaluate(arguments[1])
6
+ else
7
+ interpreter.evaluate(arguments[2]) unless(arguments[2].nil?)
8
+ end
9
+ end
10
+ "))
@@ -0,0 +1,10 @@
1
+ (define if
2
+ (native_function "
3
+ Proc.new do |arguments, interpreter|
4
+ if(interpreter.evaluate(arguments[0]))
5
+ interpreter.evaluate(arguments[1])
6
+ else
7
+ interpreter.evaluate(arguments[2]) unless(arguments[2].nil?)
8
+ end
9
+ end
10
+ "))
@@ -0,0 +1,6 @@
1
+ (define input
2
+ (native_function "
3
+ Proc.new do |arguments, interpreter|
4
+ $stdin.gets[0..-2]
5
+ end
6
+ "))
@@ -0,0 +1,7 @@
1
+ (define write
2
+ (native_function "
3
+ Proc.new do |arguments, interpreter|
4
+ output = interpreter.evaluate(arguments[0])
5
+ puts output
6
+ end
7
+ "))
@@ -0,0 +1,7 @@
1
+ (define write
2
+ (native_function "
3
+ Proc.new do |arguments, interpreter|
4
+ output = interpreter.evaluate(arguments[0])
5
+ puts output
6
+ end
7
+ "))
@@ -0,0 +1,20 @@
1
+ module Schaefer
2
+ class Environment
3
+ attr_accessor :parent
4
+
5
+ def initialize(parent = nil)
6
+ @parent = parent
7
+ @table = {}
8
+ end
9
+
10
+ def find(name)
11
+ return @table[name] if @table.has_key?(name)
12
+ return nil if @parent.nil?
13
+ return @parent.find(name)
14
+ end
15
+
16
+ def define(name, value)
17
+ @table[name] = value
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,45 @@
1
+ module Schaefer
2
+ class Interpreter
3
+ attr_accessor :base_environment, :current_environment
4
+
5
+ def initialize()
6
+ @base_environment = @current_environment = Schaefer::Environment.new
7
+ loadLibrary
8
+ end
9
+
10
+ def run(program)
11
+ expressions = Parser.new.parse(program)
12
+ result = nil
13
+ expressions.each do |expression|
14
+ result = evaluate(expression)
15
+ end
16
+ return result
17
+ end
18
+
19
+ def evaluate(expression)
20
+ return @current_environment.find(expression) if expression.is_a? Symbol
21
+ return expression unless expression.is_a? Array
22
+
23
+ if expression[0] == :define
24
+ return @current_environment.define(expression[1], evaluate(expression[2]))
25
+ elsif expression[0] == :native_function
26
+ return eval(expression[1])
27
+ else
28
+ function = evaluate(expression[0])
29
+ raise RuntimeError, "\n#{expression[0]} is not a function" unless function.is_a? Proc
30
+ arguments = expression.slice(1, expression.length)
31
+ return function.call(arguments, self)
32
+ end
33
+ end
34
+
35
+ private
36
+
37
+ def loadLibrary
38
+ pattern = File.join(File.dirname(__FILE__), "Library", "*.sch")
39
+
40
+ Dir[pattern].each do |file|
41
+ run(File.read(file))
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,87 @@
1
+ class Parser
2
+
3
+ def pullSLiterals(string) #method used to remove all string literals, save them in an array, and replace them with a set string that will not interfere with parsing
4
+ pattern = /"([^"\\]|\\.)*"/
5
+ replace = "***STRING-LITERAL***"
6
+ literals = []
7
+ string.gsub(pattern) do |occurence|
8
+ literals << occurence
9
+ end
10
+ string = string.gsub(pattern, replace)
11
+ return [string, literals]
12
+ end
13
+
14
+ def tokenize(string) #method used split program into tokens by adding spaces arround '('s and calling string.split(' ')
15
+ string = string.gsub("(", " ( ")
16
+ string = string.gsub(")", " ) ")
17
+ tokens = string.split(" ")
18
+ return tokens
19
+ end
20
+
21
+ def replaceSLiterals(tokens, literals) #method used to restore string literals in our tokens array now that we dont have to worry about special cases
22
+ return tokens.map do |token|
23
+ if token == "***STRING-LITERAL***"
24
+ literals.shift
25
+ else
26
+ token
27
+ end
28
+ end
29
+ end
30
+
31
+ def isMatch?(string, pattern) #check if type is a match, returns false if no, true if yes
32
+ match = string.match(pattern)
33
+ return false unless match
34
+ match[0].length == string.length
35
+ end
36
+
37
+ def isSymbol?(string) #return true if string is anything other than parenthasees, quotes, or commas
38
+ return isMatch?(string, /[^\"\'\,\(\)]+/)
39
+ end
40
+
41
+ def isInteger?(string) #return true if string is made of any number of numerals optionally preceded by a + or -
42
+ return isMatch?(string, /[\-\+]?[0-9]+/)
43
+ end
44
+
45
+ def isString?(string) #return true if string is text surrounded by quotes
46
+ return isMatch?(string, /"([^"\\]|\\.)*"/)
47
+ end
48
+
49
+ def convertTokens(tokens)
50
+ convertedTokens = []
51
+ tokens.each do |token|
52
+ convertedTokens << "(" and next if token == "("
53
+ convertedTokens << ")" and next if token == ")"
54
+ convertedTokens << token.to_i and next if isInteger?(token)
55
+ convertedTokens << token.to_sym and next if isSymbol?(token)
56
+ convertedTokens << eval(token) and next if isString?(token)
57
+ raise Exception, "Unrecognized token: #{token}"
58
+ end
59
+ return convertedTokens
60
+ end
61
+
62
+ def formStructure(tokens, offset = 0)
63
+ structure = []
64
+ while offset < tokens.length do
65
+ if tokens[offset] == "("
66
+ offset, tempArray = formStructure(tokens, offset + 1)
67
+ structure << tempArray
68
+ elsif tokens[offset] == ")"
69
+ break
70
+ else
71
+ structure << tokens[offset]
72
+ end
73
+ offset += 1
74
+ end
75
+ return [offset, structure]
76
+ end
77
+
78
+ def parse(string)
79
+ string, literals = pullSLiterals(string)
80
+ tokens = tokenize(string)
81
+ tokens = replaceSLiterals(tokens, literals)
82
+ tokens = convertTokens(tokens)
83
+ structure = formStructure(tokens)[1]
84
+ return structure
85
+ end
86
+ end
87
+
@@ -0,0 +1,87 @@
1
+ class Parser
2
+
3
+ def pullSLiterals(string) #method used to remove all string literals, save them in an array, and replace them with a set string that will not interfere with parsing
4
+ pattern = /"([^"\\]|\\.)*"/
5
+ replace = "***STRING-LITERAL***"
6
+ literals = []
7
+ string.gsub(pattern) do |occurence|
8
+ literals << occurence
9
+ end
10
+ string = string.gsub(pattern, replace)
11
+ return [string, literals]
12
+ end
13
+
14
+ def tokenize(string) #method used split program into tokens by adding spaces arround '('s and calling string.split(' ')
15
+ string = string.gsub("(", " ( ")
16
+ string = string.gsub(")", " ) ")
17
+ tokens = string.split(" ")
18
+ return tokens
19
+ end
20
+
21
+ def replaceSLiterals(tokens, literals) #method used to restore string literals in our tokens array now that we dont have to worry about special cases
22
+ return tokens.map do |token|
23
+ if token == "***STRING-LITERAL***"
24
+ literals.shift
25
+ else
26
+ token
27
+ end
28
+ end
29
+ end
30
+
31
+ def isMatch?(string, pattern) #check if type is a match, returns false if no, true if yes
32
+ match = string.match(pattern)
33
+ return false unless match
34
+ match[0].length == string.length
35
+ end
36
+
37
+ def isSymbol?(string) #return true if string is anything other than parenthasees, quotes, or commas
38
+ return isMatch?(string, /[^\"\'\,\(\)]+/)
39
+ end
40
+
41
+ def isInteger?(string) #return true if string is made of any number of numerals optionally preceded by a + or -
42
+ return isMatch?(string, /[\-\+]?[0-9]+/)
43
+ end
44
+
45
+ def isString?(string) #return true if string is text surrounded by quotes
46
+ return isMatch?(string, /"([^"\\]|\\.)*"/)
47
+ end
48
+
49
+ def convertTokens(tokens)
50
+ convertedTokens = []
51
+ tokens.each do |token|
52
+ convertedTokens << "(" and next if token == "("
53
+ convertedTokens << ")" and next if token == ")"
54
+ convertedTokens << token.to_i and next if isInteger?(token)
55
+ convertedTokens << token.to_sym and next if isSymbol?(token)
56
+ convertedTokens << eval(token) and next if isString?(token)
57
+ raise Exception, "Unrecognized token: #{token}"
58
+ end
59
+ return convertedTokens
60
+ end
61
+
62
+ def formStructure(tokens, offset = 0)
63
+ structure = []
64
+ while offset < tokens.length do
65
+ if tokens[offset] == "("
66
+ offset, tempArray = formStructure(tokens, offset + 1)
67
+ structure << tempArray
68
+ elsif tokens[offset] == ")"
69
+ break
70
+ else
71
+ structure << tokens[offset]
72
+ end
73
+ offset += 1
74
+ end
75
+ return [offset, structure]
76
+ end
77
+
78
+ def parse(string)
79
+ string, literals = pullSLiterals(string)
80
+ tokens = tokenize(string)
81
+ tokens = replaceSLiterals(tokens, literals)
82
+ tokens = convertTokens(tokens)
83
+ structure = formStructure(tokens)[1]
84
+ return structure
85
+ end
86
+ end
87
+
@@ -0,0 +1,3 @@
1
+ module Schaefer
2
+ VERSION = "0.0.2"
3
+ end
data/lib/schaefer.rb ADDED
@@ -0,0 +1,3 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), "schaefer", "environment.rb"))
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "schaefer", "interpreter.rb"))
3
+ require File.expand_path(File.join(File.dirname(__FILE__), "schaefer", "parser.rb"))
data/schaefer.gemspec ADDED
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/schaefer/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Tommy Schaefer"]
6
+ gem.email = ["me@tommyschaefer.net"]
7
+ gem.description = %q{Schaefer is a small programming language deigned to show how to build a programming language. Running the command 'schaefer' begins console based execution of code and passing a file name will execute the file. SchaeferScript is a scheme-style language where the core functions are written in ruby and other functions written in the language itself. You can access the source for SchaeferScript at https://github.com/tommyschaefer/SchaeferScript.}
8
+ gem.summary = %q{schaefer is short for SchaeferScript}
9
+ gem.homepage = "https://github.com/tommyschaefer/SchaeferScript"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "schaefer"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Schaefer::VERSION
17
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: schaefer
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
11
+ platform: ruby
12
+ authors:
13
+ - Tommy Schaefer
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-05-27 00:00:00 Z
19
+ dependencies: []
20
+
21
+ description: Schaefer is a small programming language deigned to show how to build a programming language. Running the command 'schaefer' begins console based execution of code and passing a file name will execute the file. SchaeferScript is a scheme-style language where the core functions are written in ruby and other functions written in the language itself. You can access the source for SchaeferScript at https://github.com/tommyschaefer/SchaeferScript.
22
+ email:
23
+ - me@tommyschaefer.net
24
+ executables:
25
+ - .DS_Store
26
+ - schaefer
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - .DS_Store
33
+ - .gitignore
34
+ - Examples/.DS_Store
35
+ - Examples/exampleAdd.sch
36
+ - Examples/exampleAdd.sch~
37
+ - Examples/exampleDisplay.sch
38
+ - Examples/exampleDisplay.sch~
39
+ - Examples/exampleDo.sch
40
+ - Examples/exampleDo.sch~
41
+ - Examples/exampleFunction.sch
42
+ - Examples/exampleFunction.sch~
43
+ - Examples/exampleFunction2.sch
44
+ - Examples/exampleGets.sch
45
+ - Examples/exampleIf.sch
46
+ - Examples/exampleIf.sch~
47
+ - Examples/exampleWrite.sch
48
+ - Examples/exampleWrite.sch~
49
+ - Gemfile
50
+ - LICENSE
51
+ - README.md
52
+ - Rakefile
53
+ - bin/.DS_Store
54
+ - bin/schaefer
55
+ - lib/.DS_Store
56
+ - lib/schaefer.rb
57
+ - lib/schaefer/.DS_Store
58
+ - lib/schaefer/.environment.rb.swp
59
+ - lib/schaefer/Library/.DS_Store
60
+ - lib/schaefer/Library/additionOperator.sch
61
+ - lib/schaefer/Library/display.sch
62
+ - lib/schaefer/Library/display.sch~
63
+ - lib/schaefer/Library/do.sch
64
+ - lib/schaefer/Library/do.sch~
65
+ - lib/schaefer/Library/equalTo.sch
66
+ - lib/schaefer/Library/equalTo.sch~
67
+ - lib/schaefer/Library/function.sch
68
+ - lib/schaefer/Library/if.sch
69
+ - lib/schaefer/Library/if.sch~
70
+ - lib/schaefer/Library/input.sch
71
+ - lib/schaefer/Library/write.sch
72
+ - lib/schaefer/Library/write.sch~
73
+ - lib/schaefer/environment.rb
74
+ - lib/schaefer/interpreter.rb
75
+ - lib/schaefer/parser.rb
76
+ - lib/schaefer/parser.rb~
77
+ - lib/schaefer/version.rb
78
+ - schaefer.gemspec
79
+ homepage: https://github.com/tommyschaefer/SchaeferScript
80
+ licenses: []
81
+
82
+ post_install_message:
83
+ rdoc_options: []
84
+
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ hash: 3
93
+ segments:
94
+ - 0
95
+ version: "0"
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ hash: 3
102
+ segments:
103
+ - 0
104
+ version: "0"
105
+ requirements: []
106
+
107
+ rubyforge_project:
108
+ rubygems_version: 1.8.21
109
+ signing_key:
110
+ specification_version: 3
111
+ summary: schaefer is short for SchaeferScript
112
+ test_files: []
113
+