mojikun 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 775137f72943fb9965160f02315b7b91d72bebcf
4
+ data.tar.gz: d26f81c79b0d822305250ffd2473a73a019bd84b
5
+ SHA512:
6
+ metadata.gz: 250f9d8fc80e85b79e11283da3029ad93f9b50b71f5cd793c3377322c265c1ce2718533951c1009c5aa84bf40e3136fecc9dd2434397c09ae033775aebeec601
7
+ data.tar.gz: d038efa6682638a3025ecc8c344e2ac366d89461347a770daf1c372a760d9eec4e3cb48a53d3ef74b30c422ae6ee4d25ca4d0888d707f89d78c04f4c325414db
data/README.md CHANGED
@@ -4,14 +4,14 @@ A Brainfuck based on Emoji.
4
4
 
5
5
  Instructions:
6
6
 
7
- 👉 Move the pointer to the right
8
- 👈 Move the pointer to the left
9
- 👍 Increment the memory cell under the pointer
10
- 👎 Decrement the memory cell under the pointer
11
- 💻 Output the character signified by the cell at the pointer
12
- 💾 Input a character and store it in the cell at the pointer
13
- 🔃 Jump past the matching 🔙 if the cell under the pointer is 0
14
- 🔙 Jump back to the matching 🔃 if the cell under the pointer is nonzero
7
+ 👉 Move the pointer to the right
8
+ 👈 Move the pointer to the left
9
+ 👍 Increment the memory cell under the pointer
10
+ 👎 Decrement the memory cell under the pointer
11
+ 💻 Output the character signified by the cell at the pointer
12
+ 💾 Input a character and store it in the cell at the pointer
13
+ 🔃 Jump past the matching 🔙 if the cell under the pointer is 0
14
+ 🔙 Jump back to the matching 🔃 if the cell under the pointer is nonzero
15
15
 
16
16
  ## Installation
17
17
 
@@ -33,11 +33,56 @@ A `mojikun` binary is provided to let you run programs. There is an examples
33
33
  directory which has some examples. Use `mojikun` like any other interpreter:
34
34
 
35
35
  ```
36
- mokikun examples/hello.moji
36
+ mojikun examples/hello.moji
37
37
  ```
38
38
 
39
39
  `.moji` is the preferred file ending for Mojikun.
40
40
 
41
+ ## Structure
42
+
43
+ While Mojikun is a simple language that could be interpreted in a 40ish line
44
+ script, I wanted to make it more like a 'real langauge' that would have all
45
+ of the parts and design that a more full one has. I may use this foundation
46
+ later to build more complex things.
47
+
48
+ We can see these parts in motion by examining the binary:
49
+
50
+ ```ruby
51
+ $ cat bin/mojikun
52
+ #!/usr/bin/env ruby
53
+
54
+ require 'mojikun'
55
+
56
+ source_code = ARGF.read.chomp
57
+
58
+ tokens = Mojikun::Lexer.new(source_code).call
59
+
60
+ ast = Mojikun::Parser.new(tokens).call
61
+
62
+ runtime = Mojikun::Runtime.new
63
+ interpreter = Mojikun::Interpreter.new(runtime)
64
+
65
+ interpreter.evaluate(ast)
66
+ ```
67
+
68
+ We have a Lexer, Parser, Runtime, and Interpreter. The Lexer turns the stream
69
+ of input into a series of tokens. The Parser takes those tokens and turns them
70
+ into an AST, which is more of a list than a tree, really. We generate a new
71
+ Runtime, which has all of the internal state we need to make the language work:
72
+ the data array, the program counter, etc. Then, the Interpreter takes that
73
+ AST and evaluates it in the context of the Runtime.
74
+
75
+ Pretty simple!
76
+
77
+ ## Testing
78
+
79
+ Mojikun is fully tested with MiniTest. I actually wrote it in a TDD fashion.
80
+ To run the tests, simply
81
+
82
+ ```
83
+ $ rake test
84
+ ```
85
+
41
86
  ## Contributing
42
87
 
43
88
  1. Fork it
@@ -0,0 +1 @@
1
+ 👉👍👍👍👍👍👍👍👉👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👉👎🔙👍👍👍👍👍👍👍👉👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👉👎🔙👍👍👍👍👍👍👍👍👍👍👉👍👍👍👍👍👍👍👍👍👉👉👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👉👎🔙👍👉👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👍👉👎🔙👍👍👉👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👉👎🔙👍👍👉👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👉👎🔙👍👉👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👍👉👎🔙👍👉👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👉👎🔙👍👉👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👍👉👎🔙👍👍👉👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👉👎🔙👍👉👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👍👉👎🔙👍👉👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👉👎🔙👍👉👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👉👎🔙👍👍👉👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👉👎🔙👍👍👍👍👉👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👍👉👎🔙👍👉👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👉👎🔙👍👍👉👍👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👉👎🔙👍👉👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍🔃👈👍👍👉👎🔙👍👍👍👍👍👍👍👍👍👍👍👍👍👉👍👍👉👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👉👎🔙👍👉👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👉👎🔙👍👍👍👉👍👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👉👎🔙👍👉👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👉👎🔙👍👉👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👍👉👎🔙👍👉👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👍👉👎🔙👍👉👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👍👉👎🔙👍👍👉👍👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👉👎🔙👍👉👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👉👎🔙👍👍👉👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👍👉👎🔙👍👉👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👉👎🔙👍👉👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👉👎🔙👍👉👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👉👎🔙👍👉👍👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👉👎🔙👍👍👉👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👉👎🔙👍👉👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👉👎🔙👍👉👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍👍👍👍👍👍🔃👈👍👍👍👍👍👍👍👍👍👍👉👎🔙👉👍👍👍👍👍🔃👈👍👍👉👎🔙👍👍👍👍👍👍👍👍👍👍👍👍👍🔃👈🔙👉👉👉👉🔃👈👎🔃👍🔃👉🔙👈👈💻👉💻👈💻👉💻🔃👈🔙👉💻👉💻👉👉👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻🔃👈🔙👉💻👉💻👉👉👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉👉👉👉👉👉👉👉👉👉👉👉👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻🔃👈🔙👉👉👎👈💻👉💻👉👉👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻🔃👈🔙👉👉👉👎👎🔙👍🔃👉🔙👈👈💻👉💻👈💻👉💻🔃👈🔙👉💻👉💻👉👉👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻🔃👈🔙👉💻👉💻👉👉👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉👉👉👉👉👉👉👉👉👉👉👉👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻🔃👈🔙👉👎👉👍👍👍👍👍👍👍👍👍👉👍👍👍👍👍👍👍👍👍👈👈💻👉💻👉👉👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻🔃👈🔙👉👉👉👉👎🔙👍👈👎👎👎🔃👍🔃👉🔙👈👈💻👉💻👈💻👉💻🔃👈🔙👉👉💻👉👉👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻🔃👈🔙👉👉💻👉👉👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉👉👉👉👉👉👉👉👉👉👉👉👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻🔃👈🔙👉👉👎💻👉👉👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻🔃👈🔙👉👉👉👎👎🔙👍🔃👉🔙👈👈💻👉💻👈💻👉💻🔃👈🔙👉👉💻👉👉👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻🔃👈🔙👉👉💻👉👉👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉👉👉👉👉👉👉👉👉👉👉👉👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻🔃👈🔙👉👉👎👈👉💻👉👉👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👈👈👈👈💻🔃👉🔙👈👈💻👉💻👈💻👉💻🔃👈🔙👉👉💻👉👉👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻🔃👈🔙👉👉💻👉👉👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉👉👉👉👉👉👉👉👉👉👉👉👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉 👉 👉 👉 👉 👉 👉 👉 👉 👉 👉 👉 👉 👉 👉 👉 👉 👉 👉💻👉💻👈👈👈 👈 👈 👈 👈 👈 👈 👈 👈 👈 👈 👈 👈 👈💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻🔃👉🔙👈👈👈👈💻👈👈💻🔃👈🔙👉👉👉👉👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻👉💻
@@ -1,3 +1,3 @@
1
1
  module Mojikun
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -65,8 +65,10 @@ class InterpreterTest < Minitest::Unit::TestCase
65
65
  end
66
66
 
67
67
  def test_eval_end_loop_node
68
- # so we enter the loop
68
+ # so we loop twice
69
69
  ast = [Mojikun::ThumbsUpNode.new,
70
+ Mojikun::ThumbsUpNode.new,
71
+
70
72
  Mojikun::LoopNode.new,
71
73
 
72
74
  # move right once, increment, move left
@@ -76,6 +78,7 @@ class InterpreterTest < Minitest::Unit::TestCase
76
78
 
77
79
  # decrement so we leave the loop
78
80
  Mojikun::ThumbsDownNode.new,
81
+
79
82
  Mojikun::EndLoopNode.new,
80
83
 
81
84
  # move right so we can see the 1 we did in the loop
@@ -83,7 +86,7 @@ class InterpreterTest < Minitest::Unit::TestCase
83
86
  ]
84
87
  @interpreter.evaluate(ast)
85
88
 
86
- assert_equal 1, @interpreter.runtime.current_data
89
+ assert_equal 2, @interpreter.runtime.current_data
87
90
  end
88
91
 
89
92
  def test_loop_map
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mojikun
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
5
- prerelease:
4
+ version: 1.0.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Steve Klabnik
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-12-09 00:00:00.000000000 Z
11
+ date: 2013-04-08 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: A simple programming language, using emoji.
15
14
  email:
@@ -25,6 +24,7 @@ files:
25
24
  - README.md
26
25
  - Rakefile
27
26
  - bin/mojikun
27
+ - examples/99_bottles.moji
28
28
  - examples/hello.moji
29
29
  - lib/mojikun.rb
30
30
  - lib/mojikun/display_node.rb
@@ -49,27 +49,26 @@ files:
49
49
  - test/test_helper.rb
50
50
  homepage: https://github.com/steveklabnik/mojikun
51
51
  licenses: []
52
+ metadata: {}
52
53
  post_install_message:
53
54
  rdoc_options: []
54
55
  require_paths:
55
56
  - lib
56
57
  required_ruby_version: !ruby/object:Gem::Requirement
57
- none: false
58
58
  requirements:
59
- - - ! '>='
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  required_rubygems_version: !ruby/object:Gem::Requirement
63
- none: false
64
63
  requirements:
65
- - - ! '>='
64
+ - - '>='
66
65
  - !ruby/object:Gem::Version
67
66
  version: '0'
68
67
  requirements: []
69
68
  rubyforge_project:
70
- rubygems_version: 1.8.24
69
+ rubygems_version: 2.0.0
71
70
  signing_key:
72
- specification_version: 3
71
+ specification_version: 4
73
72
  summary: A simple programming language, using emoji.
74
73
  test_files:
75
74
  - test/interpreter_test.rb