Skip to content
Browse files

added gitignore + MIT-LICENCE + fruitloop.gemspec; small doc modifica…

…tions
  • Loading branch information...
1 parent e876c7d commit e66a7c749c43721650c4a9c534d13461f97e6b6c @thoefer2 thoefer2 committed
Showing with 82 additions and 53 deletions.
  1. +1 −0 .gitignore
  2. +0 −3 LICENSE
  3. +22 −0 MIT-LICENSE
  4. +12 −12 README.md
  5. +14 −0 fruitloop.gemspec
  6. +3 −13 lib/add.loop
  7. +8 −0 lib/fruitloop.rb
  8. +0 −1 lib/gen/jsvisitor.rb
  9. +0 −1 lib/main.rb
  10. +1 −2 lib/mult.loop
  11. +19 −19 lib/parser.rb
  12. +2 −2 lib/sub.loop
View
1 .gitignore
@@ -0,0 +1 @@
+nbproject/
View
3 LICENSE
@@ -1,3 +0,0 @@
-== LoopLang
-
-Put appropriate LICENSE for your project here.
View
22 MIT-LICENSE
@@ -0,0 +1,22 @@
+== FRUITLOOP
+
+Copyright (c) 2012-2012 Thomas Hoefer
+
+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.
View
24 README.md
@@ -1,12 +1,12 @@
FRUITLOOP
=========
-Implementation of the LOOP programming language which compiles to JavaScript. See: http://de.wikipedia.org/wiki/LOOP-Programm.
+Implementation of the LOOP programming language which compiles to JavaScript. See: http://de.wikipedia.org/wiki/LOOP-Programm.
DEPENDENCIES
============
- Ruby >= 1.9.2p290, not tested with other versions
-- Node.js >= 0.5.6
+- Node.js >= 0.5.6; the binary is expected to be located at /usr/local/bin/node
HOWTO
@@ -17,17 +17,17 @@ HOWTO
GRAMMAR
=======
-S ::= P$
-P ::= id A X
- | loop id do P end X
-A ::= : B
-B ::= = C
-C ::= id D
- | number
-D ::= + number
- | - number
-X ::= ; P X | Epsilon
+- S ::= P$
+- P ::= id A X | loop id do P end X
+- A ::= : B
+- B ::= = C
+- C ::= id D | number
+- D ::= + number | - number
+- X ::= ; P X | Epsilon
+License
+=======
+FRUITLOOP is released under the MIT license: [www.opensource.org/licenses/MIT](www.opensource.org/licenses/MIT)
View
14 fruitloop.gemspec
@@ -0,0 +1,14 @@
+Gem::Specification.new do |s|
+ s.name = 'fruitloop'
+ s.version = '0.3'
+ s.has_rdoc = true
+ s.extra_rdoc_files = ['README.md', 'MIT-LICENSE']
+ s.summary = 'FRUITLOOP is an implementation of the LOOP programming language.'
+ s.description = 'FRUITLOOP is an implementation of the LOOP programming language.'
+ s.author = 'Thomas Hoefer'
+ s.email = 'mail@tomhoefer.de'
+ s.homepage = 'http://www.github.com/thoefer/fruitloop'
+ s.files = %w(MIT-LICENSE README.md Rakefile) + Dir.glob("{lib}/**/*")
+ s.require_path = "lib"
+end
+
View
16 lib/add.loop
@@ -1,16 +1,6 @@
-xa := 4;
-xb := 2;
+xa := 7;
+xb := 3;
loop xb do
xa := xa + 1
-end;
-
-
-xa := xa + 1;
-
-b := 3;
-loop b do
- b := b + 12;
- xa := xa + 1
-end
-
+end
View
8 lib/fruitloop.rb
@@ -0,0 +1,8 @@
+$:.unshift(File.join(File.dirname(__FILE__)))
+
+require "lexer"
+require "parser"
+
+lexer = Lexer.new
+parser = Parser.new(lexer)
+parser.parse_start
View
1 lib/gen/jsvisitor.rb
@@ -37,7 +37,6 @@ def visit_loop_end(node)
def run
compile "sys.puts(\"xa: \" + xa);"
nodejs = IO.popen("/usr/local/bin/node", "r+")
- p @target
nodejs.puts @target
nodejs.close_write
puts nodejs.gets
View
1 lib/main.rb
@@ -3,7 +3,6 @@
require "lexer"
require "parser"
-
lexer = Lexer.new
parser = Parser.new(lexer)
parser.parse_start
View
3 lib/mult.loop
@@ -1,5 +1,5 @@
a := a + 5;
-b := b + 4;
+b := b + 8;
loop a do
loop b do
@@ -7,4 +7,3 @@ loop a do
end
end
-
View
38 lib/parser.rb
@@ -21,19 +21,19 @@ def test_tokens
end
end
- # Parse-Methode für die Startproduktion
+ # Parsing method for the start production
def parse_start
consume_token
case lookahead
when TIdentifier, TLoop then
- @node_start = NodeStart.new # Startknoten des AST
+ @node_start = NodeStart.new # The AST´s root node
parse_p @node_start
match TTerminate
else
parse_error
end
- # Nachdem die Syntax OK ist den AST traversieren
+ # Evaluate AST after the syntax is good
traverse_ast
end
@@ -44,13 +44,13 @@ def parse_p parent_node
@node_assignment = NodeAssignment.new
@node_assignment.lvalue = lookahead
SymbolTable.add_id lookahead
- parent_node << @node_assignment # Zuweisungsknoten
+ parent_node << @node_assignment # Assignment node
match TIdentifier
parse_a
parse_x parent_node
when TLoop then
@node_loop = NodeLoop.new
- parent_node << @node_loop # Loopknoten
+ parent_node << @node_loop # Loop node
match TLoop
to = lookahead
semantic_error "loop variable must be defined" unless SymbolTable.get_id(to)
@@ -66,19 +66,19 @@ def parse_p parent_node
end
- # x kann nach Epsilon abgeleitet werden, daher...
+ # As x can evaluate to Epsilon...
def parse_x parent_node
case lookahead
- when TSemicolon then # ... neben dem Fall, dass es nicht Epsilon ist...
+ when TSemicolon then # ... besides the case that it is not Epsilon ...
match TSemicolon
parse_p parent_node
parse_x parent_node
- when TTerminate, TEnd, TSemicolon then # ... auch auf Follow-Menge "predicten".
- # Epsilon-Produktion
+ when TTerminate, TEnd, TSemicolon then # ... predict for the follow set.
+ # Epsilon production
else
- # Fehler - da aktueller Lookahead weder in
- # 1. First(x)
- # 2. Follow(x) falls Epsilon in First(x)
+ # Error - the current lookahead is neither in..
+ # 1. FIRST(x)
+ # 2. FOLLOW(x) if Epsilon in FIRST(x)
parse_error
end
end
@@ -110,11 +110,11 @@ def parse_c
case lookahead
when TIdentifier
SymbolTable.add_null_initializer lookahead
- @node_assignment.op1 = lookahead # Erster Operator einer Zuweisung
+ @node_assignment.op1 = lookahead # An assignment´s first operand
match TIdentifier
parse_d
when TNumber
- @node_assignment.rvalue = lookahead # Kurzzuweisung
+ @node_assignment.rvalue = lookahead # Short assignment
match TNumber
else
parse_error
@@ -127,7 +127,7 @@ def parse_d
when TBinOp then
@node_assignment.op = lookahead # Operand
match TBinOp
- @node_assignment.op2 = lookahead # Zweiter Operator einer Zuweisung
+ @node_assignment.op2 = lookahead # An assignment´s second operand
match TNumber
else
parse_error
@@ -137,9 +137,9 @@ def parse_d
private
- # Prüft ob das aktuelle Token eine Instanz von <which_class> ist, ansonsten
- # terminiert das Programm da ein Syntaxfehler vorliegt. Liest nach Prüfung das
- # nächste Token
+ # Checks if the current token is an instance of <which_class>. If this is not the case
+ # the programm terminates as an syntacial error occured. Reads the next token after the
+ # check was successful.
def match(which_class)
if lookahead.is_a?(which_class)
#p "Is: #{lookahead.class}, Expected: #{which_class}"
@@ -150,7 +150,7 @@ def match(which_class)
consume_token
end
- # Holt das nächste Token vom Scanner
+ # Returns the next token from the scanner
def consume_token
@lookahead = @lexer.input_token
@lookahead
View
4 lib/sub.loop
@@ -1,5 +1,5 @@
-xa := xa + 7;
-xb := xb + 1;
+xa := 7;
+xb := 1;
loop xb do
xa := xa - 1

0 comments on commit e66a7c7

Please sign in to comment.
Something went wrong with that request. Please try again.