Browse Source

new commands, experimental tokenizer (not used), removed fractions

Kajetan Johannes Hammerle 6 years ago
parent
commit
3bcb83e66c

+ 27 - 3
src/me/hammerle/snuviscript/SnuviScript.java

@@ -1,6 +1,7 @@
 package me.hammerle.snuviscript;
 
 import java.io.IOException;
+import java.util.List;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
@@ -8,6 +9,9 @@ import me.hammerle.snuviscript.code.ISnuviLogger;
 import me.hammerle.snuviscript.code.ISnuviScheduler;
 import me.hammerle.snuviscript.code.Script;
 import me.hammerle.snuviscript.code.SnuviParser;
+import me.hammerle.snuviscript.code.SnuviUtils;
+import me.hammerle.snuviscript.config.SnuviConfig;
+import me.hammerle.snuviscript.token.Tokenizer;
 
 public class SnuviScript
 {
@@ -60,8 +64,28 @@ public class SnuviScript
                 return 1;
             }
         };
-        SnuviParser parser = new SnuviParser(logger, scheduler);
-        parser.startScript(true, ".sbasic", "./test");    
-        parser.callEvent("testevent", null, null);
+        //SnuviParser parser = new SnuviParser(logger, scheduler);
+        //parser.startScript(true, ".sbasic", "./test");  
+        
+        List<String> list = SnuviUtils.readCode(".sbasic", "./test");
+        Tokenizer t = new Tokenizer(String.join("\n", list));
+        t.tokenize();
+        
+        //System.out.println("spawn - " + conf.getLocation("spawn"));
+        //parser.callEvent("testevent", null, null);      
     }  
+    
+    /*public static Location getSpawn()
+    {
+        // Player changeDimension, WorldServer, MinecraftServer
+        return KajetansMod.conf.getLocation("spawn");
+    }
+
+    public static void setSpawn(World w, Vec3d v, float yaw, float pitch)
+    {          
+        SimpleConfig conf = KajetansMod.conf;
+        conf.setLocation("spawn", new Location(w, v, yaw, pitch));
+        conf.save();
+        w.setSpawnPoint(new BlockPos(v.x, v.y, v.z));
+    }*/
 }

+ 1 - 14
src/me/hammerle/snuviscript/array/DynamicArray.java

@@ -6,7 +6,6 @@ import java.lang.reflect.Array;
 import me.hammerle.snuviscript.code.SnuviUtils;
 import me.hammerle.snuviscript.code.Script;
 import me.hammerle.snuviscript.variable.LocalVariable;
-import me.hammerle.snuviscript.math.Fraction;
 
 public class DynamicArray extends InputProvider
 {
@@ -68,22 +67,10 @@ public class DynamicArray extends InputProvider
         return Array.get(getLastArray(sc), input[input.length - 1].getInt(sc));
     }
     
-    @Override
-    public Fraction getFraction(Script sc) 
-    {
-        return (Fraction) get(sc);
-    }
-    
-    @Override
-    public int getInt(Script sc) 
-    {
-        return getFraction(sc).intValue();
-    }
-    
     @Override
     public double getDouble(Script sc) 
     {
-        return getFraction(sc).doubleValue();
+        return (double) get(sc);
     }
     
     @Override

+ 8 - 8
src/me/hammerle/snuviscript/code/Compiler.java

@@ -5,7 +5,7 @@ import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Stack;
-import me.hammerle.snuviscript.constants.ConstantFraction;
+import me.hammerle.snuviscript.constants.ConstantDouble;
 import me.hammerle.snuviscript.constants.ConstantNull;
 import me.hammerle.snuviscript.constants.ConstantString;
 import me.hammerle.snuviscript.array.DynamicArray;
@@ -15,7 +15,6 @@ import me.hammerle.snuviscript.variable.LocalArrayVariable;
 import me.hammerle.snuviscript.variable.LocalVariable;
 import me.hammerle.snuviscript.variable.Variable;
 import me.hammerle.snuviscript.exceptions.PreScriptException;
-import me.hammerle.snuviscript.math.Fraction;
 
 public class Compiler 
 {
@@ -333,11 +332,11 @@ public class Compiler
         
         Instruction[] input = code.toArray(new Instruction[code.size()]);
         
-        for(Instruction in : input)
+        /*for(Instruction in : input)
         {
             System.out.println(in);
         }
-        System.out.println("__________________________________");
+        System.out.println("__________________________________");*/
         /*labels.entrySet().stream().forEach((e) -> 
         {
             System.out.println("LABEL " + e.getKey() + " " + e.getValue());
@@ -650,7 +649,7 @@ public class Compiler
         }
         else if(SnuviUtils.isNumber(input))
         {
-            return new ConstantFraction(Fraction.fromDouble(Double.parseDouble(input)));
+            return new ConstantDouble(Double.parseDouble(input));
         }
         else if(SnuviUtils.isFunction(input))
         {
@@ -690,7 +689,8 @@ public class Compiler
         {
             return null;
         }
-        else if(input.equals("true"))
+        input = input.trim();
+        if(input.equals("true"))
         {
             return true;
         }
@@ -704,7 +704,7 @@ public class Compiler
         }
         else if(SnuviUtils.isNumber(input))
         {
-            return Fraction.fromDouble(Double.parseDouble(input));
+            return Double.parseDouble(input);
         }
         else if(input.startsWith("\"") && input.endsWith("\""))
         {
@@ -790,7 +790,7 @@ public class Compiler
         
         if(input.length == 3)
         {
-            realInput[3] = new ConstantFraction(new Fraction(1));
+            realInput[3] = new ConstantDouble(1.0);
         }
         
         JumpData jump = new JumpData(code.size());

+ 1 - 14
src/me/hammerle/snuviscript/code/Function.java

@@ -1,6 +1,5 @@
 package me.hammerle.snuviscript.code;
 
-import me.hammerle.snuviscript.math.Fraction;
 import me.hammerle.snuviscript.variable.Variable;
 import me.hammerle.snuviscript.variable.ArrayVariable;
 import me.hammerle.snuviscript.variable.LocalArrayVariable;
@@ -51,22 +50,10 @@ public class Function extends InputProvider
         return null;
     }
     
-    @Override
-    public Fraction getFraction(Script sc)
-    {
-        return (Fraction) function.execute(sc, input);
-    }
-    
-    @Override
-    public int getInt(Script sc)
-    {
-        return ((Number) function.execute(sc, input)).intValue();
-    }
-    
     @Override
     public double getDouble(Script sc) 
     {
-        return ((Number) function.execute(sc, input)).doubleValue();
+        return (double) function.execute(sc, input);
     }
     
     @Override

+ 189 - 109
src/me/hammerle/snuviscript/code/FunctionLoader.java

@@ -16,6 +16,7 @@ import java.util.GregorianCalendar;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Objects;
 import java.util.Set;
 import java.util.function.BiFunction;
@@ -26,7 +27,6 @@ import me.hammerle.snuviscript.exceptions.AssertionException;
 import me.hammerle.snuviscript.exceptions.FileIOException;
 import me.hammerle.snuviscript.variable.ArrayVariable;
 import me.hammerle.snuviscript.variable.Variable;
-import me.hammerle.snuviscript.math.Fraction;
 
 public class FunctionLoader 
 {
@@ -129,55 +129,75 @@ public class FunctionLoader
         // bit
         // --------------------------------------------------------------------- 
         
-        registerFunction(">>", (sc, in) -> in[0].getFraction(sc).rightShift(in[1].getInt(sc)));
-        registerFunction("<<", (sc, in) -> in[0].getFraction(sc).leftShift(in[1].getInt(sc)));
-        registerFunction("&", (sc, in) -> in[0].getFraction(sc).and(in[1].getFraction(sc)));
-        registerFunction("|", (sc, in) -> in[0].getFraction(sc).or(in[1].getFraction(sc)));
-        registerFunction("^", (sc, in) -> in[0].getFraction(sc).xor(in[1].getFraction(sc)));
-        registerFunction("~", (sc, in) -> in[0].getFraction(sc).invertBits());
-        registerFunction("bit.set", (sc, in) -> in[0].getFraction(sc).setBit(in[1].getInt(sc)));
-        registerFunction("bit.unset", (sc, in) -> in[0].getFraction(sc).unsetBit(in[1].getInt(sc)));
-        registerFunction("bit.get", (sc, in) -> in[0].getFraction(sc).getBit(in[1].getInt(sc)));
+        registerFunction(">>", (sc, in) -> (double) (in[0].getInt(sc) >> in[1].getInt(sc)));
+        registerFunction("<<", (sc, in) -> (double) (in[0].getInt(sc) << in[1].getInt(sc)));
+        registerFunction("&", (sc, in) -> (double) (in[0].getInt(sc) & in[1].getInt(sc)));
+        registerFunction("|", (sc, in) -> (double) (in[0].getInt(sc) | in[1].getInt(sc)));
+        registerFunction("^", (sc, in) -> (double) (in[0].getInt(sc) ^ in[1].getInt(sc)));
+        registerFunction("~", (sc, in) -> (double) (~in[0].getInt(sc)));
+        registerFunction("bit.set", (sc, in) -> (double) (in[0].getInt(sc) | (1 << (in[1].getInt(sc)))));
+        registerFunction("bit.unset", (sc, in) -> (double) (in[0].getInt(sc) & (~(1 << (in[1].getInt(sc))))));
+        registerFunction("bit.get", (sc, in) -> (in[0].getInt(sc) & (1 << (in[1].getInt(sc)))) != 0);
         
         // ---------------------------------------------------------------------    
         // math
         // ---------------------------------------------------------------------    
-        registerFunction("%", (sc, in) -> new Fraction(in[0].getInt(sc) % in[1].getInt(sc)));
+        registerFunction("%", (sc, in) -> (double) (in[0].getInt(sc) % in[1].getInt(sc)));
         registerAlias("%", "math.mod");
-        registerFunction("math.abs", (sc, in) -> in[0].getFraction(sc).abs());
-        registerFunction("math.pow", (sc, in) -> in[0].getFraction(sc).power(in[1].getFraction(sc)));
-        registerFunction("math.root", (sc, in) -> in[0].getFraction(sc).power(in[1].getFraction(sc).invert()));
-        registerFunction("math.sin", (sc, in) -> in[0].getFraction(sc).sin());
-        registerFunction("math.cos", (sc, in) -> in[0].getFraction(sc).cos());
-        registerFunction("math.tan", (sc, in) -> in[0].getFraction(sc).tan());
-        registerFunction("math.sin", (sc, in) -> in[0].getFraction(sc).sin());
-        registerFunction("math.acos", (sc, in) -> in[0].getFraction(sc).acos());
-        registerFunction("math.atan", (sc, in) -> in[0].getFraction(sc).atan());
-        registerFunction("math.asin", (sc, in) -> in[0].getFraction(sc).asin());
-        registerFunction("math.e", (sc, in) -> Fraction.E);
-        registerFunction("math.pi", (sc, in) -> Fraction.PI);
-        registerFunction("math.ln", (sc, in) -> in[0].getFraction(sc).log());
-        registerFunction("math.log", (sc, in) -> in[0].getFraction(sc).log10());
-        registerFunction("math.random", (sc, in) -> new Fraction(SnuviUtils.randomInt(in[0].getInt(sc), in[1].getInt(sc))));
-        registerFunction("math.round", (sc, in) -> in[0].getFraction(sc).round());
-        registerFunction("math.rounddown", (sc, in) -> in[0].getFraction(sc).floor());
-        registerFunction("math.roundup", (sc, in) -> in[0].getFraction(sc).ceil());
-        registerFunction("math.roundcomma", (sc, in) -> in[0].getFraction(sc).round(in[1].getInt(sc)));
+        registerFunction("math.abs", (sc, in) -> Math.abs(in[0].getDouble(sc)));
+        registerFunction("math.pow", (sc, in) -> Math.pow(in[0].getDouble(sc), in[1].getDouble(sc)));
+        registerFunction("math.root", (sc, in) -> Math.pow(in[0].getDouble(sc), 1.0 / in[1].getDouble(sc)));
+        registerFunction("math.sqrt", (sc, in) -> Math.sqrt(in[0].getDouble(sc)));
+        registerFunction("math.hypot", (sc, in) -> Math.hypot(in[0].getDouble(sc), in[1].getDouble(sc)));
+        registerFunction("math.sin", (sc, in) -> Math.sin(in[0].getDouble(sc)));
+        registerFunction("math.cos", (sc, in) -> Math.cos(in[0].getDouble(sc)));
+        registerFunction("math.tan", (sc, in) -> Math.tan(in[0].getDouble(sc)));
+        registerFunction("math.sin", (sc, in) -> Math.sin(in[0].getDouble(sc)));
+        registerFunction("math.acos", (sc, in) -> Math.acos(in[0].getDouble(sc)));
+        registerFunction("math.atan", (sc, in) -> Math.atan(in[0].getDouble(sc)));
+        registerFunction("math.asin", (sc, in) -> Math.asin(in[0].getDouble(sc)));
+        registerFunction("math.e", (sc, in) -> Math.E);
+        registerFunction("math.pi", (sc, in) -> Math.PI);
+        registerFunction("math.ln", (sc, in) -> Math.log(in[0].getDouble(sc)));
+        registerFunction("math.log", (sc, in) -> Math.log10(in[0].getDouble(sc)));
+        registerFunction("math.random", (sc, in) -> (double) SnuviUtils.randomInt(in[0].getInt(sc), in[1].getInt(sc)));
+        registerFunction("math.round", (sc, in) -> (double) Math.round(in[0].getDouble(sc)));
+        registerFunction("math.rounddown", (sc, in) -> Math.floor(in[0].getDouble(sc)));
+        registerFunction("math.roundup", (sc, in) -> Math.ceil(in[0].getDouble(sc)));
+        registerFunction("math.roundcomma", (sc, in) -> 
+        {
+            double d = in[0].getDouble(sc);
+            int factor = (int) Math.pow(10, in[1].getInt(sc));
+            return (double) (((int) (d * factor)) / factor);
+        });
         
         // ---------------------------------------------------------------------  
         // lists
         // ---------------------------------------------------------------------    
         registerFunction("list.new", (sc, in) ->     
         {
+            if(in.length == 0)
+            {
+                return new ArrayList<>();
+            }
             in[0].set(sc, new ArrayList<>());
             return Void.TYPE;
         });
         registerFunction("list.exists", (sc, in) -> in[0].get(sc) instanceof List);
         registerFunction("list.add", (sc, in) -> ((List) in[0].get(sc)).add(in[1].get(sc)));
+        registerFunction("list.addall", (sc, in) -> 
+        {
+            List list = ((List) in[0].get(sc));
+            for(int i = 1; i < in.length; i++)
+            {
+                list.add(in[i].get(sc));
+            }
+            return Void.TYPE;
+        });
         registerFunction("list.remove", (sc, in) -> ((List) in[0].get(sc)).remove(in[1].get(sc)));
         registerFunction("list.removeindex", (sc, in) -> ((List) in[0].get(sc)).remove(in[1].getInt(sc)));
         registerFunction("list.contains", (sc, in) -> ((List) in[0].get(sc)).contains(in[1].get(sc)));
-        registerFunction("list.getsize", (sc, in) -> new Fraction(((List) in[0].get(sc)).size()));
+        registerFunction("list.getsize", (sc, in) -> (double) ((List) in[0].get(sc)).size());
         registerFunction("list.getindex", (sc, in) -> ((List) in[0].get(sc)).get(in[1].getInt(sc)));
         registerAlias("list.getindex", "list.get");
         registerFunction("list.setindex", (sc, in) -> ((List) in[0].get(sc)).set(in[1].getInt(sc), in[2].get(sc)));
@@ -186,7 +206,7 @@ public class FunctionLoader
             ((List) in[0].get(sc)).clear();
             return Void.TYPE;
         });
-        registerFunction("list.getindexof", (sc, in) -> new Fraction(((List) in[0].get(sc)).indexOf(in[1].get(sc))));
+        registerFunction("list.getindexof", (sc, in) -> (double) ((List) in[0].get(sc)).indexOf(in[1].get(sc)));
         registerFunction("list.sort", (sc, in) ->     
         {
             Collections.sort(((List<Object>) in[0].get(sc)), (Object o1, Object o2) -> ((Comparable) o1).compareTo(o2));
@@ -214,7 +234,7 @@ public class FunctionLoader
             }
             return Void.TYPE;
         });
-        registerFunction("array.getsize", (sc, in) -> new Fraction(Array.getLength(in[0].getArray(sc))));
+        registerFunction("array.getsize", (sc, in) -> (double) Array.getLength(in[0].getArray(sc)));
         
         /*
         registerFunction("array.swap", (sc, in) ->                                           
@@ -272,6 +292,10 @@ public class FunctionLoader
         // --------------------------------------------------------------------- 
         registerFunction("map.new", (sc, in) ->     
         {
+            if(in.length == 0)
+            {
+                return new HashMap<>();
+            }
             in[0].set(sc, new HashMap<>());
             return Void.TYPE;
         });
@@ -279,7 +303,7 @@ public class FunctionLoader
         registerFunction("map.add", (sc, in) -> ((Map) in[0].get(sc)).put(in[1].get(sc), in[2].get(sc)));
         registerFunction("map.remove", (sc, in) -> ((Map) in[0].get(sc)).remove(in[1].get(sc)));
         registerFunction("map.contains", (sc, in) -> ((Map) in[0].get(sc)).containsKey(in[1].get(sc)));
-        registerFunction("map.getsize", (sc, in) -> new Fraction(((Map) in[0].get(sc)).size()));
+        registerFunction("map.getsize", (sc, in) -> (double) ((Map) in[0].get(sc)).size());
         registerFunction("map.get", (sc, in) -> ((Map) in[0].get(sc)).get(in[1].get(sc)));
         registerFunction("map.getordefault", (sc, in) -> ((Map) in[0].get(sc)).getOrDefault(in[1].get(sc), in[2].get(sc)));
         registerFunction("map.clear", (sc, in) ->     
@@ -303,14 +327,27 @@ public class FunctionLoader
         // --------------------------------------------------------------------- 
         registerFunction("set.new", (sc, in) ->     
         {
+            if(in.length == 0)
+            {
+                return new HashSet<>();
+            }
             in[0].set(sc, new HashSet<>());
             return Void.TYPE;
         });
         registerFunction("set.exists", (sc, in) -> in[0].get(sc) instanceof Set);
         registerFunction("set.add", (sc, in) -> ((Set) in[0].get(sc)).add(in[1].get(sc)));
+        registerFunction("set.addall", (sc, in) -> 
+        {
+            Set set = ((Set) in[0].get(sc));
+            for(int i = 1; i < in.length; i++)
+            {
+                set.add(in[i].get(sc));
+            }
+            return Void.TYPE;
+        });
         registerFunction("set.remove", (sc, in) -> ((Set) in[0].get(sc)).remove(in[1].get(sc)));
         registerFunction("set.contains", (sc, in) -> ((Set) in[0].get(sc)).contains(in[1].get(sc)));
-        registerFunction("set.getsize", (sc, in) -> new Fraction(((Set) in[0].get(sc)).size()));
+        registerFunction("set.getsize", (sc, in) -> (double) ((Set) in[0].get(sc)).size());
         registerFunction("set.tolist", (sc, in) ->     
         {
             in[0].set(sc, ((Set) in[1].get(sc)).stream().collect(Collectors.toList()));
@@ -323,12 +360,13 @@ public class FunctionLoader
         registerFunction("time.new", (sc, in) ->       
         {
             GregorianCalendar cal = GregorianCalendar.from(ZonedDateTime.now());
-            cal.setTimeInMillis(in[1].getFraction(sc).longValue());
+            cal.setTimeInMillis(in[1].getLong(sc));
             in[0].set(sc, cal);
             return Void.TYPE;
         });
-        registerFunction("time.getmillis", (sc, in) -> new Fraction(System.currentTimeMillis()));
-        registerFunction("time.from", (sc, in) -> new Fraction(((GregorianCalendar) in[0].get(sc)).getTimeInMillis()));
+        registerFunction("time.getmillis", (sc, in) -> (double) System.currentTimeMillis());
+        registerFunction("time.getnanos", (sc, in) -> (double) System.nanoTime());
+        registerFunction("time.from", (sc, in) -> (double) ((GregorianCalendar) in[0].get(sc)).getTimeInMillis());
         registerFunction("time.nextday", (sc, in) ->         
         {
             GregorianCalendar cal = (GregorianCalendar) in[0].get(sc);
@@ -339,26 +377,18 @@ public class FunctionLoader
             cal.set(Calendar.MILLISECOND, 0);
             return Void.TYPE;
         });   
-        registerFunction("time.getyear", (sc, in) -> new Fraction(((GregorianCalendar) in[0].get(sc)).get(Calendar.YEAR)));
-        registerFunction("time.getmonth", (sc, in) -> new Fraction(((GregorianCalendar) in[0].get(sc)).get(Calendar.MONTH) + 1));
-        registerFunction("time.getday", (sc, in) -> new Fraction(((GregorianCalendar) in[0].get(sc)).get(Calendar.DAY_OF_MONTH)));
-        registerFunction("time.gethour", (sc, in) -> new Fraction(((GregorianCalendar) in[0].get(sc)).get(Calendar.HOUR_OF_DAY)));
-        registerFunction("time.getminute", (sc, in) -> new Fraction(((GregorianCalendar) in[0].get(sc)).get(Calendar.MINUTE)));
-        registerFunction("time.getsecond", (sc, in) -> new Fraction(((GregorianCalendar) in[0].get(sc)).get(Calendar.SECOND)));
+        registerFunction("time.getyear", (sc, in) -> (double) ((GregorianCalendar) in[0].get(sc)).get(Calendar.YEAR));
+        registerFunction("time.getmonth", (sc, in) -> (double) (((GregorianCalendar) in[0].get(sc)).get(Calendar.MONTH) + 1));
+        registerFunction("time.getday", (sc, in) -> (double) (((GregorianCalendar) in[0].get(sc)).get(Calendar.DAY_OF_MONTH)));
+        registerFunction("time.gethour", (sc, in) -> (double) ((GregorianCalendar) in[0].get(sc)).get(Calendar.HOUR_OF_DAY));
+        registerFunction("time.getminute", (sc, in) -> (double) ((GregorianCalendar) in[0].get(sc)).get(Calendar.MINUTE));
+        registerFunction("time.getsecond", (sc, in) -> (double) ((GregorianCalendar) in[0].get(sc)).get(Calendar.SECOND));
               
         // ---------------------------------------------------------------------    
         // text
         // ---------------------------------------------------------------------   
         registerFunction("text.matches", (sc, in) -> in[0].getString(sc).matches(in[1].getString(sc)));      
-        registerFunction("text.number", (sc, in) -> 
-        {
-            Fraction f = in[0].getFraction(sc);
-            if(f.doubleValue() == f.longValue())
-            {
-                return String.valueOf(f.longValue()); 
-            }
-            return String.valueOf(f.doubleValue()); 
-        });
+        registerFunction("text.number", (sc, in) -> SnuviUtils.toString(in[0].getDouble(sc)));
         registerFunction("text.class", (sc, in) -> in[0].get(sc).getClass().getSimpleName());      
         registerFunction("text.tolowercase", (sc, in) -> SnuviUtils.connect(sc, in, 0).toLowerCase());
         registerAlias("text.tolowercase", "tolowercase");
@@ -366,17 +396,48 @@ public class FunctionLoader
         registerAlias("text.touppercase", "touppercase");
         registerFunction("text.split", (sc, in) ->      
         {
-            in[0].set(sc, Arrays.stream(SnuviUtils.connect(sc, in, 2).split(in[1].getString(sc))).map(s -> Compiler.convert(s)).collect(Collectors.toList()));
+            String[] parts = SnuviUtils.connect(sc, in, 2).split(in[1].getString(sc));
+            ArrayList<Object> list = new ArrayList<>();
+            for(String part : parts)
+            {
+                list.add(Compiler.convert(part));
+            }
+            in[0].set(sc, list);
             return Void.TYPE;
         });  
         registerAlias("text.split", "split");
-        registerFunction("text.concatlist", (sc, in) -> ((List<Object>) in[0].get(sc)).stream().limit(in[3].getInt(sc) + 1).skip(in[2].getInt(sc)).map(o -> String.valueOf(o)).collect(Collectors.joining(in[1].getString(sc))));       
+        registerFunction("text.concatlist", (sc, in) ->     
+        {
+            StringBuilder sb = new StringBuilder();
+            List<Object> list = (List<Object>) in[0].get(sc);
+            String splitter = in[1].getString(sc);
+            Iterator<Object> iter = list.iterator();
+            int from = in[2].getInt(sc);
+            int to = Math.min(in[3].getInt(sc), list.size() - 1);
+            to -= from;
+            while(iter.hasNext() && from > 0)
+            {
+                iter.next();
+                from--;
+            }
+            while(iter.hasNext() && to > 0)
+            {
+                sb.append(iter.next());
+                sb.append(splitter);
+                to--;
+            }
+            if(iter.hasNext() && to == 0)
+            {
+                sb.append(iter.next());
+            }
+            return sb.toString();
+        });       
         registerAlias("text.concatlist", "concatlist");
         registerFunction("text.concat", (sc, in) -> SnuviUtils.connect(sc, in, 0)); 
         registerAlias("text.concat", "concat");
         registerFunction("text", (sc, in) -> String.valueOf(in[0].get(sc)));       
         registerFunction("text.substring", (sc, in) -> in[0].getString(sc).substring(in[1].getInt(sc), in[2].getInt(sc))); 
-        registerFunction("text.length", (sc, in) ->  in[0].getString(sc).length()); 
+        registerFunction("text.length", (sc, in) ->  (double) in[0].getString(sc).length()); 
         registerFunction("text.startswith", (sc, in) -> in[0].getString(sc).startsWith(in[1].getString(sc), in[2].getInt(sc))); 
         registerFunction("text.endswith", (sc, in) -> in[0].getString(sc).endsWith(in[1].getString(sc))); 
         registerFunction("text.contains", (sc, in) ->  in[0].getString(sc).contains(in[1].getString(sc))); 
@@ -385,7 +446,7 @@ public class FunctionLoader
         registerFunction("text.replace", (sc, in) -> in[0].getString(sc).replace(in[1].getString(sc), in[2].getString(sc)));
         registerFunction("text.trim", (sc, in) -> in[0].getString(sc).trim());
         registerFunction("text.charat", (sc, in) -> String.valueOf(in[0].getString(sc).charAt(in[1].getInt(sc))));
-        registerFunction("text.charcode", (sc, in) -> new Fraction(in[0].getString(sc).charAt(in[1].getInt(sc))));
+        registerFunction("text.charcode", (sc, in) -> (double) in[0].getString(sc).charAt(in[1].getInt(sc)));
         registerFunction("text.fromcode", (sc, in) -> String.valueOf((char) in[0].getInt(sc)));
         
         // -------------------------------------------------------------------------------    
@@ -470,32 +531,20 @@ public class FunctionLoader
             return Void.TYPE;
         });
         registerFunction("config.getbool", (sc, in) -> ((SnuviConfig) in[0].get(sc)).getBoolean(in[1].getString(sc), in[2].getBoolean(sc)));
-        registerFunction("config.getfraction", (sc, in) -> ((SnuviConfig) in[0].get(sc)).getFraction(in[1].getString(sc), in[2].getFraction(sc)));
+        registerFunction("config.getdouble", (sc, in) -> ((SnuviConfig) in[0].get(sc)).getDouble(in[1].getString(sc), in[2].getDouble(sc)));
         registerFunction("config.getstring", (sc, in) -> ((SnuviConfig) in[0].get(sc)).getString(in[1].getString(sc), in[2].getString(sc)));
         
         // ---------------------------------------------------------------------    
         // commands without library
         // ---------------------------------------------------------------------   
         // elementary calculating
-        registerFunction("+", (sc, in) -> 
-        {
-            return in[0].getFraction(sc).add(in[1].getFraction(sc));
-        });
+        registerFunction("+", (sc, in) -> in[0].getDouble(sc) + in[1].getDouble(sc));
         registerAlias("+", "add");
-        registerFunction("-", (sc, in) -> 
-        {
-            return in[0].getFraction(sc).sub(in[1].getFraction(sc));
-        });
+        registerFunction("-", (sc, in) -> in[0].getDouble(sc) - in[1].getDouble(sc));
         registerAlias("-", "sub");
-        registerFunction("*", (sc, in) -> 
-        {
-            return in[0].getFraction(sc).mul(in[1].getFraction(sc));
-        });
+        registerFunction("*", (sc, in) -> in[0].getDouble(sc) * in[1].getDouble(sc));
         registerAlias("*", "mul");
-        registerFunction("/", (sc, in) -> 
-        {
-            return in[0].getFraction(sc).div(in[1].getFraction(sc));
-        });
+        registerFunction("/", (sc, in) -> in[0].getDouble(sc) / in[1].getDouble(sc));
         registerAlias("/", "div");
 
         // var setter
@@ -506,78 +555,78 @@ public class FunctionLoader
         });
         registerFunction("+=", (sc, in) -> 
         {
-            in[0].set(sc, in[0].getFraction(sc).add(in[1].getFraction(sc)));
+            in[0].set(sc, in[0].getDouble(sc) + in[1].getDouble(sc));
             return Void.TYPE;
         });
         registerFunction("++", (sc, in) -> 
         {
-            Fraction f = in[0].getFraction(sc);
-            in[0].set(sc, f.add(new Fraction(1)));
-            return f;
+            double d = in[0].getDouble(sc);
+            in[0].set(sc, d + 1.0);
+            return d;
         });
         registerAlias("++", "inc");
         registerFunction("p+", (sc, in) -> 
         {
-            Fraction f = in[0].getFraction(sc).add(new Fraction(1));
-            in[0].set(sc, f);
-            return f;
+            double d = in[0].getDouble(sc) + 1.0;
+            in[0].set(sc, d);
+            return d;
         });
         registerFunction("-=", (sc, in) -> 
         {
-            in[0].set(sc, in[0].getFraction(sc).sub(in[1].getFraction(sc)));
+            in[0].set(sc, in[0].getDouble(sc) - in[1].getDouble(sc));
             return Void.TYPE;
         });
         registerFunction("--", (sc, in) -> 
         {
-            Fraction f = in[0].getFraction(sc);
-            in[0].set(sc, f.sub(new Fraction(1)));
-            return f;
+            double d = in[0].getDouble(sc);
+            in[0].set(sc, d - 1.0);
+            return d;
         });
         registerAlias("--", "dec");
         registerFunction("p-", (sc, in) -> 
         {
-            Fraction f = in[0].getFraction(sc).sub(new Fraction(1));
-            in[0].set(sc, f);
-            return f;
+            double d = in[0].getDouble(sc) - 1.0;
+            in[0].set(sc, d);
+            return d;
         });
         registerFunction("*=", (sc, in) -> 
         {
-            in[0].set(sc, in[0].getFraction(sc).mul(in[1].getFraction(sc)));
+            in[0].set(sc, in[0].getDouble(sc) * in[1].getDouble(sc));
             return Void.TYPE;
         });
         registerFunction("/=", (sc, in) -> 
         {
-            in[0].set(sc, in[0].getFraction(sc).div(in[1].getFraction(sc)));
+            in[0].set(sc, in[0].getDouble(sc) / in[1].getDouble(sc));
             return Void.TYPE;
         });
         registerFunction("%=", (sc, in) -> 
         {
-            in[0].set(sc, new Fraction(in[0].getInt(sc) % in[1].getInt(sc)));
+            in[0].set(sc, (double) (in[0].getInt(sc) % in[1].getInt(sc)));
             return Void.TYPE;
         });
         registerFunction("<<=", (sc, in) -> 
         {
-            in[0].set(sc, in[0].getFraction(sc).leftShift(in[1].getInt(sc)));
+            in[0].set(sc, (double) (in[0].getInt(sc) << in[1].getInt(sc)));
             return Void.TYPE;
         });
         registerFunction(">>=", (sc, in) -> 
         {
-            in[0].set(sc, in[0].getFraction(sc).rightShift(in[1].getInt(sc)));
+            in[0].set(sc, (double) (in[0].getInt(sc) >> in[1].getInt(sc)));
             return Void.TYPE;
         });
         registerFunction("&=", (sc, in) -> 
         {
-            in[0].set(sc, in[0].getFraction(sc).and(in[1].getFraction(sc)));
+            in[0].set(sc, (double) (in[0].getInt(sc) & in[1].getInt(sc)));
             return Void.TYPE;
         });
         registerFunction("^=", (sc, in) -> 
         {
-            in[0].set(sc, in[0].getFraction(sc).xor(in[1].getFraction(sc)));
+            in[0].set(sc, (double) (in[0].getInt(sc) ^ in[1].getInt(sc)));
             return Void.TYPE;
         });
         registerFunction("|=", (sc, in) -> 
         {
-            in[0].set(sc, in[0].getFraction(sc).or(in[1].getFraction(sc)));
+            in[0].set(sc, (double) (in[0].getInt(sc) | in[1].getInt(sc)));
             return Void.TYPE;
         });
         
@@ -621,7 +670,16 @@ public class FunctionLoader
         {
             sc.currentLine = sc.labels.get(in[0].getString(sc));
             return Void.TYPE;
-        });       
+        });   
+        registerFunction("ignoregoto", (sc, in) -> 
+        {
+            Integer i = sc.labels.get(in[0].getString(sc));
+            if(i != null)
+            {
+                sc.currentLine = i;
+            }
+            return Void.TYPE;
+        }); 
         registerFunction("sgoto", (sc, in) -> 
         {
             if(sc.subScript)
@@ -719,9 +777,9 @@ public class FunctionLoader
         registerFunction("for", (sc, in) -> 
         {
             // for(var, start, end, step)
-            Fraction start = in[1].getFraction(sc);
+            double start = in[1].getDouble(sc);
             in[0].set(sc, start);           
-            if(start.compareTo(in[2].getFraction(sc)) > 0)
+            if(start > in[2].getDouble(sc))
             {
                 sc.currentLine += in[4].getInt(sc);
             }
@@ -732,9 +790,9 @@ public class FunctionLoader
             int line = sc.currentLine + in[0].getInt(sc);
             InputProvider[] f = sc.code[line].getParameters();
             // for(var, start, end, step)
-            Fraction current = f[0].getFraction(sc).add(f[3].getFraction(sc));
+            double current = f[0].getDouble(sc) + f[3].getDouble(sc);
             f[0].set(sc, current);
-            if(current.compareTo(f[2].getFraction(sc)) <= 0)
+            if(current <= f[2].getDouble(sc))
             {
                 sc.currentLine = line;
             }
@@ -757,21 +815,41 @@ public class FunctionLoader
         registerAlias("==", "equals");
         registerFunction("!=", (sc, in) -> !Objects.equals(in[0].get(sc), in[1].get(sc)));
         registerAlias("!=", "notequal");
-        registerFunction("<", (sc, in) -> in[0].getFraction(sc).compareTo(in[1].getFraction(sc)) < 0);
+        registerFunction("<", (sc, in) -> in[0].getDouble(sc) < in[1].getDouble(sc));
         registerAlias("<", "less");
-        registerFunction(">", (sc, in) -> in[0].getFraction(sc).compareTo(in[1].getFraction(sc)) > 0);
+        registerFunction(">", (sc, in) -> in[0].getDouble(sc) > in[1].getDouble(sc));
         registerAlias(">", "greater");
-        registerFunction("<=", (sc, in) -> in[0].getFraction(sc).compareTo(in[1].getFraction(sc)) <= 0);
+        registerFunction("<=", (sc, in) -> in[0].getDouble(sc) <= in[1].getDouble(sc));
         registerAlias("<=", "lessequal");
-        registerFunction(">=", (sc, in) -> in[0].getFraction(sc).compareTo(in[1].getFraction(sc)) >= 0);
+        registerFunction(">=", (sc, in) -> in[0].getDouble(sc) >= in[1].getDouble(sc));
         registerAlias(">=", "greaterequal");
         registerFunction("!", (sc, in) -> !in[0].getBoolean(sc));
         registerAlias("!", "invert");
         
         // logical stuff
-        registerFunction("&&", (sc, in) -> Arrays.stream(in).map(i -> i.getBoolean(sc)).allMatch(s -> s));
+        registerFunction("&&", (sc, in) -> 
+        {
+            for(InputProvider i : in)
+            {
+                if(!i.getBoolean(sc))
+                {
+                    return false;
+                }
+            }
+            return true;
+        });
         registerAlias("&&", "and");
-        registerFunction("||", (sc, in) -> Arrays.stream(in).map(i -> i.getBoolean(sc)).anyMatch(s -> s));
+        registerFunction("||", (sc, in) -> 
+        {
+            for(InputProvider i : in)
+            {
+                if(i.getBoolean(sc))
+                {
+                    return true;
+                }
+            }
+            return false;
+        });
         registerAlias( "||", "or");
         
         // non grouped stuff
@@ -821,9 +899,10 @@ public class FunctionLoader
         registerFunction("islong", (sc, in) ->                                           
         {
             Object o = in[0].get(sc);
-            if(o instanceof Fraction)
+            if(o instanceof Double)
             {
-                return ((Fraction) o).isLong();
+                double d = (Double) o;
+                return d == (long) d;
             }
             return false;
         });
@@ -835,5 +914,6 @@ public class FunctionLoader
             }
             return Void.TYPE;
         });
+        registerFunction("class", (sc, in) -> in[0].get(sc).getClass());    
     }
 }

+ 18 - 4
src/me/hammerle/snuviscript/code/InputProvider.java

@@ -1,7 +1,6 @@
 package me.hammerle.snuviscript.code;
 
 import me.hammerle.snuviscript.variable.Variable;
-import me.hammerle.snuviscript.math.Fraction;
 
 public abstract class InputProvider 
 {
@@ -10,14 +9,29 @@ public abstract class InputProvider
         throw new ClassCastException();
     }
     
-    public Fraction getFraction(Script sc)
+    public byte getByte(Script sc)
     {
-        throw new ClassCastException();
+        return (byte) getDouble(sc);
+    }
+    
+    public short getShort(Script sc)
+    {
+        return (short) getDouble(sc);
     }
     
     public int getInt(Script sc)
     {
-        throw new ClassCastException();
+        return (int) getDouble(sc);
+    }
+    
+    public long getLong(Script sc)
+    {
+        return (long) getDouble(sc);
+    }
+    
+    public float getFloat(Script sc)
+    {
+        return (float) getDouble(sc);
     }
     
     public double getDouble(Script sc)

+ 0 - 3
src/me/hammerle/snuviscript/code/JumpData.java

@@ -1,8 +1,5 @@
 package me.hammerle.snuviscript.code;
 
-import me.hammerle.snuviscript.code.InputProvider;
-import me.hammerle.snuviscript.code.Script;
-
 public class JumpData extends InputProvider
 {
     private int jump;

+ 2 - 17
src/me/hammerle/snuviscript/code/SignInverter.java

@@ -1,8 +1,5 @@
 package me.hammerle.snuviscript.code;
 
-import me.hammerle.snuviscript.code.Script;
-import me.hammerle.snuviscript.math.Fraction;
-
 public class SignInverter extends InputProvider
 {
     private final InputProvider input;
@@ -15,25 +12,13 @@ public class SignInverter extends InputProvider
     @Override
     public Object get(Script sc) 
     {
-        return ((Fraction) input.get(sc)).invertSign();
-    }
-    
-    @Override
-    public Fraction getFraction(Script sc) 
-    {
-        return input.getFraction(sc).invertSign();
-    }
-    
-    @Override
-    public int getInt(Script sc) 
-    {
-        return input.getFraction(sc).invertSign().intValue();
+        return -input.getDouble(sc);
     }
     
     @Override
     public double getDouble(Script sc) 
     {
-        return input.getFraction(sc).invertSign().doubleValue();
+        return -input.getDouble(sc);
     }
     
     @Override

+ 4 - 1
src/me/hammerle/snuviscript/code/SnuviParser.java

@@ -129,13 +129,16 @@ public class SnuviParser
             Script sc = new Script(this, code, simpleName, paths[0], idCounter++, onStart, onTerm, rEventBroadcast);
             scripts.put(sc.id, sc);
             sc.onStart();
+            //long l = System.nanoTime();
             sc.run();
+            //l = System.nanoTime() - l;
+            //System.out.println("time " + l);
             term();
             return sc;
         }
         catch(PreScriptException ex)
         {
-            logger.print(ex.getLocalizedMessage(), ex, null, paths[0], null, ex.getLine() + 1);
+            logger.print(ex.getLocalizedMessage(), ex, null, paths[0], null, ex.getEndLine() + 1);
             return null;
         }
     }

+ 27 - 16
src/me/hammerle/snuviscript/code/SnuviUtils.java

@@ -6,14 +6,11 @@ import java.lang.reflect.Array;
 import java.nio.charset.MalformedInputException;
 import java.nio.file.Files;
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Random;
 import java.util.regex.Pattern;
-import java.util.stream.Collectors;
 import me.hammerle.snuviscript.exceptions.PreScriptException;
 
 public class SnuviUtils 
@@ -26,7 +23,7 @@ public class SnuviUtils
     }
     
     // - in the number is handled somewhere else
-    private static final Pattern NUMBER_PATTERN = Pattern.compile("^[0-9]*[.]{0,1}[0-9]*");
+    private static final Pattern NUMBER_PATTERN = Pattern.compile("^[-]{0,1}[0-9]*[.]{0,1}[0-9]*");
     
     public static boolean isNumber(String s)
     {
@@ -47,6 +44,15 @@ public class SnuviUtils
         return ARRAY_PATTERN.matcher(s).matches();
     }
     
+    public static String toString(double d)
+    {
+        if(d == (int) d)
+        {
+            return String.valueOf((int) d);
+        }
+        return String.valueOf(d);
+    }
+    
     // -------------------------------------------------------------------------
     // line splitter
     // -------------------------------------------------------------------------
@@ -225,22 +231,27 @@ public class SnuviUtils
     
     public static String connect(Script sc, InputProvider[] c, int skip)
     {
-        return Arrays.stream(c, skip, c.length).map(o -> o.getString(sc)).collect(Collectors.joining());
-    }
-    
-    public static String connect(Collection<Object> c, int skip)
-    {
-        return c.stream().skip(skip).map(o -> o.toString()).collect(Collectors.joining());
+        StringBuilder sb = new StringBuilder();
+        for(int i = skip; i < c.length; i++)
+        {
+            sb.append(c[i].getString(sc));
+        }
+        return sb.toString();
     }
     
     public static String connect(Script sc, InputProvider[] c, String s, int skip)
     {
-        return Arrays.stream(c, skip, c.length).map(o -> o.getString(sc)).collect(Collectors.joining(s));
-    }
-    
-    public static String connect(Collection<Object> c, String s, int skip)
-    {
-        return c.stream().skip(skip).map(o -> String.valueOf(o)).collect(Collectors.joining(s));
+        StringBuilder sb = new StringBuilder();
+        if(skip < c.length)
+        {
+            sb.append(c[skip].getString(sc));
+        }
+        for(int i = skip + 1; i < c.length; i++)
+        {
+            sb.append(s);
+            sb.append(c[i].getString(sc));
+        }
+        return sb.toString();
     }
     
     // -------------------------------------------------------------------------

+ 5 - 10
src/me/hammerle/snuviscript/config/SnuviConfig.java

@@ -11,7 +11,6 @@ import java.util.stream.Collectors;
 import me.hammerle.snuviscript.code.ISnuviLogger;
 import me.hammerle.snuviscript.code.Script;
 import me.hammerle.snuviscript.code.Compiler;
-import me.hammerle.snuviscript.math.Fraction;
 
 public class SnuviConfig
 {            
@@ -72,7 +71,7 @@ public class SnuviConfig
                     print(s);
                 }
                 else
-                {
+                {                
                     conf.put(s.substring(0, b).trim(), Compiler.convert(s.substring(b + 1)));
                 }
             });
@@ -171,6 +170,7 @@ public class SnuviConfig
         }
         catch(ClassCastException ex)
         {
+            ex.printStackTrace();
             return error;
         }
     }
@@ -187,22 +187,17 @@ public class SnuviConfig
     
     public final float getFloat(String key, float error)
     {
-        return get(key, Fraction.class, Fraction.fromDouble(error)).floatValue();
+        return get(key, Double.class, (double) error).floatValue();
     }
     
     public final double getDouble(String key, double error)
     {
-        return get(key, Fraction.class, Fraction.fromDouble(error)).doubleValue();
+        return get(key, Double.class, error);
     }
     
     public final int getInt(String key, int error)
     {
-        return get(key, Fraction.class, Fraction.fromDouble(error)).intValue();
-    }
-    
-    public final Fraction getFraction(String key, Fraction error)
-    {
-        return get(key, Fraction.class, error);
+        return get(key, Double.class, (double) error).intValue();
     }
     
     public final boolean getBoolean(String key, boolean error)

+ 39 - 0
src/me/hammerle/snuviscript/constants/ConstantDouble.java

@@ -0,0 +1,39 @@
+package me.hammerle.snuviscript.constants;
+
+import me.hammerle.snuviscript.code.InputProvider;
+import me.hammerle.snuviscript.code.Script;
+import me.hammerle.snuviscript.code.SnuviUtils;
+
+public class ConstantDouble extends InputProvider
+{
+    private final double d;
+    
+    public ConstantDouble(double f)
+    {
+        this.d = f;
+    }
+    
+    @Override
+    public Object get(Script sc)
+    {
+        return d;
+    }
+    
+    @Override
+    public double getDouble(Script sc)
+    {
+        return d;
+    }
+    
+    @Override
+    public String getString(Script sc)
+    {
+        return SnuviUtils.toString(d);
+    }
+
+    @Override
+    public String toString() 
+    {
+        return SnuviUtils.toString(d);
+    }
+}

+ 0 - 51
src/me/hammerle/snuviscript/constants/ConstantFraction.java

@@ -1,51 +0,0 @@
-package me.hammerle.snuviscript.constants;
-
-import me.hammerle.snuviscript.code.InputProvider;
-import me.hammerle.snuviscript.code.Script;
-import me.hammerle.snuviscript.math.Fraction;
-
-public class ConstantFraction extends InputProvider
-{
-    private final Fraction f;
-    
-    public ConstantFraction(Fraction f)
-    {
-        this.f = f;
-    }
-    
-    @Override
-    public Object get(Script sc)
-    {
-        return f;
-    }
-    
-    @Override
-    public Fraction getFraction(Script sc)
-    {
-        return f;
-    }
-    
-    @Override
-    public int getInt(Script sc)
-    {
-        return f.intValue();
-    }
-    
-    @Override
-    public double getDouble(Script sc)
-    {
-        return f.doubleValue();
-    }
-    
-    @Override
-    public String getString(Script sc)
-    {
-        return String.valueOf(f);
-    }
-
-    @Override
-    public String toString() 
-    {
-        return String.valueOf(f);
-    }
-}

+ 0 - 7
src/me/hammerle/snuviscript/constants/ConstantNull.java

@@ -3,7 +3,6 @@ package me.hammerle.snuviscript.constants;
 import me.hammerle.snuviscript.code.InputProvider;
 import me.hammerle.snuviscript.code.Script;
 import me.hammerle.snuviscript.variable.Variable;
-import me.hammerle.snuviscript.math.Fraction;
 
 public class ConstantNull extends InputProvider
 {
@@ -19,12 +18,6 @@ public class ConstantNull extends InputProvider
         return null;
     }
     
-    @Override
-    public Fraction getFraction(Script sc)
-    {
-        return null;
-    }
-    
     @Override
     public String getString(Script sc)
     {

+ 17 - 5
src/me/hammerle/snuviscript/exceptions/PreScriptException.java

@@ -2,16 +2,28 @@ package me.hammerle.snuviscript.exceptions;
 
 public class PreScriptException extends RuntimeException
 {
-    private final int line;
+    private final int startLine;
+    private final int endLine;
     
-    public PreScriptException(String message, int line) 
+    public PreScriptException(String message, int startLine, int endLine) 
     {
         super(message);
-        this.line = line;
+        this.endLine = endLine;
+        this.startLine = startLine;
+    }
+    
+    public PreScriptException(String message, int endLine) 
+    {
+        this(message, -1, endLine);
+    }
+    
+    public int getStartLine()
+    {
+        return startLine;
     }
 
-    public int getLine()
+    public int getEndLine()
     {
-        return line;
+        return endLine;
     }
 }

+ 0 - 695
src/me/hammerle/snuviscript/math/Fraction.java

@@ -1,695 +0,0 @@
-package me.hammerle.snuviscript.math;
-
-import java.util.TreeSet;
-
-public final class Fraction extends Number implements Comparable<Fraction>
-{
-    private final long numerator;
-    private final long denominator;
-    
-    public Fraction(long numerator, long denominator)
-    {
-        if(denominator == 0)
-        {
-            throw new ArithmeticException();
-        }
-        
-        if(denominator != 1)
-        {
-            long divisor = getGreatestCommonDivisor(numerator, denominator);
-            if(divisor != 1)
-            {
-                denominator /= divisor;
-                numerator /= divisor;
-            }
-        }
-        
-        // short fraction
-        if(denominator < 0)
-        {
-            this.denominator = -denominator;
-            this.numerator = -numerator;
-        }
-        else
-        {
-            this.denominator = denominator;
-            this.numerator = numerator;
-        }
-    }
-    
-    public Fraction(long numerator)
-    {
-        this(numerator, 1);
-    }
-    
-    private static final long DOUBLE_FACTOR = 10000000000l;
-    
-    public static Fraction fromDouble(double d)
-    {
-        if(d == (long) d)
-        {
-            return new Fraction((long) d);
-        }
-        return new Fraction(Math.round(d * DOUBLE_FACTOR), DOUBLE_FACTOR);
-    }
-    
-    // -------------------------------------------------------------------------
-    // constants, chain fractions
-    // ------------------------------------------------------------------------- 
-    
-    public static final Fraction PI = Fraction.getChainFraction(
-              //3,7,15,1,292,1,1,1,2,1,3,1,14,2,1,1,2,2,2,2,1,84,2,1,1,15,3,13,1,4,2,6,6
-                3,7,15,1,292,1,1,1,2,1,3,1,14,2,1);
-    public static final Fraction E = Fraction.getChainFraction(
-              //2,1,2,1,1,4,1,1,6,1,1,8,1,1,10,1,1,12,1,1,14,1,1,16,...
-                2,1,2,1,1,4,1,1,6,1,1,8,1,1,10,1,1,12,1,1,14);
-    
-    public static Fraction getChainFraction(int... ints)
-    {
-        if(ints.length == 1)
-        {
-            return new Fraction(ints[0]);
-        }
-        return new Fraction(ints[0]).add(getChainFractionPart(1, ints));
-    }
-    
-    private static Fraction getChainFractionPart(int index, int... ints)
-    {
-        if(index + 1 == ints.length)
-        {
-            return new Fraction(1, ints[index]);
-        }
-        return new Fraction(ints[index]).add(getChainFractionPart(index + 1, ints)).invert();
-    }
-    
-    // -------------------------------------------------------------------------
-    // basic calculating
-    // ------------------------------------------------------------------------- 
-    
-    public Fraction add(Fraction f)
-    {
-        if(denominator == f.denominator)
-        {
-            return new Fraction(Math.addExact(numerator, f.numerator), denominator);
-        }
-        else
-        {
-            long l = getLeastCommonMultiple(denominator, f.denominator);
-            return new Fraction(Math.addExact(Math.multiplyExact(numerator, l / denominator),
-                    Math.multiplyExact(f.numerator, l / f.denominator)), l);
-        }
-    }
-    
-    public Fraction mul(Fraction f)
-    {
-        return new Fraction(Math.multiplyExact(numerator, f.numerator), 
-                Math.multiplyExact(denominator, f.denominator));
-    }
-    
-    public Fraction sub(Fraction f)
-    {
-        return add(f.invertSign());
-    }
-    
-    public Fraction div(Fraction f)
-    {
-        return mul(f.invert());
-    }
-    
-    // -------------------------------------------------------------------------
-    // roots, power
-    // ------------------------------------------------------------------------- 
-    
-    private static long power(long l, long power)
-    {
-        if(power == 1)
-        {
-            return l;
-        }
-        else if(power == 2)
-        {
-            return l * l;
-        }
-        long factor = 1;
-        if(l < 0)
-        {
-            factor = (power & 1) == 1 ? -1 : 1;
-            l = -l;
-        }
-        long prod = 1;
-        while(power > 0)
-        {
-            if((power & 1) == 1)
-            {
-                prod = Math.multiplyExact(prod, l);
-            }
-            power = power >> 1;
-            l = Math.multiplyExact(l, l);
-        }
-        if(factor == -1)
-        {
-            return -prod;
-        }
-        return prod;
-    }
-    
-    private static long rootOfLong(long l, long root)
-    {
-        if(l == 0 || l == 1)
-        {
-            return l;
-        }
-        try
-        {
-            TreeSet<Long> tree = new TreeSet<>();
-            long currentValue = l >> 1; // taking half as start value
-            long an = currentValue;
-            do
-            {
-                tree.add(currentValue);
-                currentValue = currentValue - (currentValue / root) + an / power(currentValue, root - 1); 
-            }
-            while(!tree.contains(currentValue));
-            return currentValue;
-        }
-        catch(ArithmeticException ex)
-        {
-            return 0;
-        } 
-    }
-    
-    private Fraction root(long root)
-    {
-        if(root == 1)
-        {
-            return this.copy();
-        }
-        // Getting nice start value
-        Fraction currentValue;
-        Fraction n = new Fraction(root);
-        Fraction an = this.div(n);
-
-        Fraction newFraction = new Fraction(rootOfLong(numerator, root), rootOfLong(denominator, root));
-        root--;
-        try
-        {
-            do
-            {
-                currentValue = newFraction;
-                newFraction = currentValue.sub(currentValue.div(n)).add(an.div(currentValue.power(root)));              
-            }
-            while(!newFraction.equals(currentValue));
-        }
-        catch(ArithmeticException ex)
-        {
-        }
-        return newFraction;
-    }
-    
-    public Fraction power(Fraction f)
-    {
-        if(numerator < 0 && f.denominator != 1)
-        {
-            throw new ArithmeticException("root of negative fraction");
-        }
-        try
-        {
-            if(f.numerator == 0)
-            {
-                return new Fraction(1);
-            }
-            else if(f.numerator < 0)
-            {
-                return this.invert().power(-f.numerator).root(f.denominator);
-            }
-            return this.power(f.numerator).root(f.denominator);
-        }
-        catch(ArithmeticException ex)
-        {
-            return fromDouble(Math.pow(this.doubleValue(), f.doubleValue()));
-        }
-    }
-    
-    private Fraction power(long p)
-    {
-        if(p < 0)
-        {
-            p = -p;
-            invert();
-        }
-        else if(p == 1)
-        {
-            return this.copy();
-        }
-        long prodn = 1;
-        long prodd = 1;
-        long n = numerator;
-        long d = denominator;
-        while(p > 0)
-        {
-            if((p & 1) == 1)
-            {
-                prodn = Math.multiplyExact(prodn, n);
-                prodd = Math.multiplyExact(prodd, d);
-            }
-            p = p >> 1;
-            n = Math.multiplyExact(n, n);
-            d = Math.multiplyExact(d, d);
-        }
-        return new Fraction(prodn, prodd);
-    }
-    
-    // -------------------------------------------------------------------------
-    // inverting
-    // -------------------------------------------------------------------------
-    
-    public Fraction invertSign()
-    {
-        return new Fraction(-numerator, denominator);
-    }
-    
-    public Fraction invert()
-    {
-        if(numerator == 0)
-        {
-            throw new ArithmeticException();
-        }
-        else if(numerator < 0)
-        {
-            return new Fraction(-denominator, -numerator);
-        }
-        return new Fraction(denominator, numerator);
-    }
-    
-    public boolean isNegative()
-    {
-        return numerator < 0;
-    }
-    
-    public boolean isLong()
-    {
-        return denominator == 1;
-    }
-    
-    // -------------------------------------------------------------------------
-    // functions from math library
-    // -------------------------------------------------------------------------
-    
-    public Fraction abs()
-    {
-        return new Fraction(Math.abs(numerator), denominator);
-    }
-    
-    public Fraction acos()
-    {
-        return Fraction.fromDouble(Math.acos(doubleValue()));
-    }
-    
-    public Fraction asin()
-    {
-        return Fraction.fromDouble(Math.asin(doubleValue()));
-    }
-    
-    public Fraction atan()
-    {
-        return Fraction.fromDouble(Math.atan(doubleValue()));
-    }
-    
-    public Fraction atan2(Fraction f)
-    {
-        return Fraction.fromDouble(Math.atan2(doubleValue(), f.doubleValue()));
-    }
-    
-    public Fraction cbrt()
-    {
-        return this.power(new Fraction(1, 3));
-    }
-    
-    public Fraction ceil()
-    {
-        return Fraction.fromDouble(Math.ceil(doubleValue()));
-    }
-    
-    public Fraction cos()
-    {
-        return Fraction.fromDouble(Math.cos(doubleValue()));
-    }
-    
-    public Fraction cosh()
-    {
-        return Fraction.fromDouble(Math.cosh(doubleValue()));
-    }
-    
-    public Fraction floor()
-    {
-        return Fraction.fromDouble(Math.floor(doubleValue()));
-    }
-    
-    public Fraction log()
-    {
-        return Fraction.fromDouble(Math.log(doubleValue()));
-    }
-    
-    public Fraction log10()
-    {
-        return Fraction.fromDouble(Math.log10(doubleValue()));
-    }
-    
-    public Fraction log1p()
-    {
-        return Fraction.fromDouble(Math.log1p(doubleValue()));
-    }
-    
-    public Fraction max(Fraction f)
-    {
-        if(this.compareTo(f) < 0)
-        {
-            return f;
-        }
-        return this;
-    }
-    
-    public Fraction min(Fraction f)
-    {
-        if(this.compareTo(f) > 0)
-        {
-            return f;
-        }
-        return this;
-    }
-    
-    public Fraction rint()
-    {
-        return Fraction.fromDouble(Math.rint(doubleValue()));
-    }
-    
-    public Fraction round()
-    {
-        return Fraction.fromDouble(Math.round(doubleValue()));
-    }
-    
-    public Fraction round(int times)
-    {
-        if(times < 0)
-        {
-            throw new IllegalArgumentException("a positive number of decimal points is needed");
-        }
-        int factor = 1;
-        while(times > 0)
-        {
-            factor *= 10;
-            times--;
-        }
-        double d = doubleValue() * factor;
-        return new Fraction(Math.round(d), factor);
-    }
-    
-    public Fraction signum()
-    {
-        if(numerator < 0)
-        {
-            return new Fraction(-1);
-        }
-        return new Fraction(1);
-    }
-    
-    public Fraction sin()
-    {
-        return Fraction.fromDouble(Math.sin(doubleValue()));
-    }
-    
-    public Fraction sinh()
-    {
-        return Fraction.fromDouble(Math.sinh(doubleValue()));
-    }
-    
-    public Fraction tan()
-    {
-        return Fraction.fromDouble(Math.tan(doubleValue()));
-    }
-    
-    public Fraction tanh()
-    {
-        return Fraction.fromDouble(Math.tanh(doubleValue()));
-    }
-    
-    public Fraction toDegrees()
-    {
-        return Fraction.fromDouble(Math.toDegrees(doubleValue()));
-    }
-    
-    public Fraction toRadians()
-    {
-        return Fraction.fromDouble(Math.toRadians(doubleValue()));
-    }
-    
-    // -------------------------------------------------------------------------
-    // simplifying
-    // ------------------------------------------------------------------------- 
-    
-    public Fraction simplify(int times)
-    {
-        if(denominator == 1)
-        {
-            return this.copy();
-        }
-        long d = denominator;
-        long n = numerator;
-        int switcher = -1;
-        for(int i = 0; i < times; i++)
-        {
-            if(switcher == -1 && d == 1)
-            {
-                d = (d & 1) == 1 ? d + 1: d;
-                n = (n & 1) == 1 ? n + 1 : n;
-                switcher = -1;
-            }
-            else if(switcher == 1 && d == -1)
-            {
-                d = (d & 1) == 1 ? d - 1: d;
-                n = (n & 1) == 1 ? n - 1 : n;
-                switcher = 1;
-            }
-            else
-            {
-                d = (d & 1) == 1 ? d + switcher: d;
-                n = (n & 1) == 1 ? n + switcher : n;
-                switcher = -switcher;
-            }
-            
-            if(d != 1)
-            {
-                long divisor = getGreatestCommonDivisor(n, d);
-                //System.out.println("DIV: " + divisor);
-                if(divisor != 1)
-                {
-                    d /= divisor;
-                    n /= divisor;
-                }
-            }
-        }
-        return new Fraction(n, d);
-    }
-    
-    private long getGreatestCommonDivisor(long i, long n)
-    {
-        if(i == 0)
-        {
-            return n;
-        }
-        if(i < 0)
-        {
-            i = -i;
-        }
-        if(n < 0)
-        {
-            n = -n;
-        }
-        long helper;
-        while(true)
-        {
-            if(i < n)
-            {
-                helper = i;
-                i = n;
-                n = helper;
-            }
-            i = i % n;
-            if(i == 0)
-            {
-                return n;
-            }
-        }
-    }
-    
-    private long getLeastCommonMultiple(long i, long n)
-    {
-        return Math.abs(Math.multiplyExact(i, n)) / getGreatestCommonDivisor(i, n);
-    }
-    
-    // -------------------------------------------------------------------------
-    // basic stuff
-    // ------------------------------------------------------------------------- 
-    
-    @Override
-    public String toString() 
-    {
-        if(denominator == 1)
-        {
-            return String.valueOf(numerator);
-        }
-        return numerator + " / " + denominator;
-    }
-
-    private Fraction copy()
-    {
-        return new Fraction(numerator, denominator);
-    }
-
-    @Override
-    public boolean equals(Object o) 
-    {
-        if(o == null)
-        {
-            return false;
-        }
-        else if(o.getClass() != Fraction.class)
-        {
-            return false;
-        }
-        Fraction f = (Fraction) o;
-        return numerator == f.numerator && denominator == f.denominator;
-    }
-
-    @Override
-    public int hashCode() 
-    {
-        int hash = 3;
-        hash = 97 * hash + (int) (this.numerator ^ (this.numerator >>> 32));
-        hash = 97 * hash + (int) (this.denominator ^ (this.denominator >>> 32));
-        return hash;
-    }
-
-    @Override
-    public int compareTo(Fraction f) 
-    {
-        if(f.numerator < 0 && numerator >= 0)
-        {
-            return 1;
-        }
-        else if(f.numerator >= 0 && numerator < 0)
-        {
-            return -1;
-        }
-        else
-        {
-            long i = f.sub(this).numerator;
-            if(i == 0)
-            {
-                return 0;
-            }
-            else if(i < 0)
-            {
-                return 1;
-            }
-            else
-            {
-                return -1;
-            }
-        }
-    }
-    
-    // -------------------------------------------------------------------------
-    // bit stuff
-    // -------------------------------------------------------------------------
-    
-    private void noFraction()
-    {
-        if(denominator != 1 && numerator != 0)
-        {
-            throw new UnsupportedOperationException("the number must not be a fraction");
-        }
-    }
-    
-    public Fraction rightShift(int times)
-    {
-        noFraction();
-        return new Fraction(numerator >> times);
-    }
-    
-    public Fraction leftShift(int times)
-    {
-        noFraction();
-        return new Fraction(numerator << times);
-    }
-    
-    public Fraction and(Fraction f)
-    {
-        noFraction();
-        return new Fraction(numerator & f.numerator);
-    }
-    
-    public Fraction or(Fraction f)
-    {
-        noFraction();
-        return new Fraction(numerator | f.numerator);
-    }
-    
-    public Fraction xor(Fraction f)
-    {
-        noFraction();
-        return new Fraction(numerator ^ f.numerator);
-    }
-    
-    public Fraction invertBits()
-    {
-        noFraction();
-        return new Fraction(~numerator);
-    }
-
-    public Fraction setBit(int n)
-    {
-        noFraction();
-        return new Fraction(numerator | 1 << n);
-    }
-    
-    public Fraction unsetBit(int n)
-    {
-        noFraction();
-        return new Fraction(numerator & ~(1 << n));
-    }   
-    
-    public boolean getBit(int n)
-    {
-        noFraction();
-        return (numerator & (1 << n)) != 0;
-    }
-    
-    // -------------------------------------------------------------------------
-    // number stuff
-    // ------------------------------------------------------------------------- 
-
-    @Override
-    public int intValue() 
-    {
-        return (int) longValue();
-    }
-
-    @Override
-    public long longValue()
-    {
-        return numerator / denominator;
-    }
-
-    @Override
-    public float floatValue() 
-    {
-        return (float) doubleValue();
-    }
-
-    @Override
-    public double doubleValue()
-    {
-        return numerator / (double) denominator;
-    }
-}

+ 11 - 0
src/me/hammerle/snuviscript/token/Parser.java

@@ -0,0 +1,11 @@
+package me.hammerle.snuviscript.token;
+
+import java.util.LinkedList;
+
+public class Parser 
+{
+    public Parser(LinkedList<TokenData> data)
+    {
+        
+    }
+}

+ 62 - 0
src/me/hammerle/snuviscript/token/Token.java

@@ -0,0 +1,62 @@
+package me.hammerle.snuviscript.token;
+
+public enum Token
+{
+    VAR,
+    INT,
+    DOUBLE,
+    LABEL,
+    
+    INC, // ++
+    DEC, // --
+    INVERT, // !
+    BIT_INVERT, // ~
+    MUL, // *
+    DIV, // /
+    MOD, // %
+    ADD, // +
+    SUB, // -
+    LEFT_SHIFT, // <<
+    RIGHT_SHIFT, // >>
+    SMALLER, // <
+    SMALLER_EQUAL, // <=
+    GREATER, // >
+    GREATER_EQUAL, // >=
+    EQUAL, // ==
+    NOT_EQUAL, // !=
+    BIT_AND, // &
+    BIT_XOR, // ^
+    BIT_OR, // |
+    AND, // &&
+    OR, // ||
+    SET, // =
+    ADD_SET, // +=
+    SUB_SET, // -=
+    MUL_SET, // *=
+    DIV_SET, // /=
+    MOD_SET, // %=
+    LEFT_SHIFT_SET, // <<=
+    RIGHT_SHIFT_SET, // >>=
+    BIT_AND_SET, // &=
+    BIT_XOR_SET, // ^=
+    BIT_OR_SET, // |=
+    COMMA, // ,
+    OPEN_BRACKET, // (
+    CLOSE_BRACKET, // )
+    OPEN_SQUARE_BRACKET, // [
+    CLOSE_SQUARE_BRACKET, // ]
+    OPEN_CURVED_BRACKET, // {
+    CLOSE_CURVED_BRACKET, // }
+    SEMICOLON, // ;
+    
+    IF,
+    ELSE,
+    FOR,
+    WHILE,
+    FUNCTION,
+    BREAK,
+    CONTINUE,
+    RETURN,
+    GOTO,
+    GOSUB
+}

+ 36 - 0
src/me/hammerle/snuviscript/token/TokenData.java

@@ -0,0 +1,36 @@
+package me.hammerle.snuviscript.token;
+
+public class TokenData 
+{
+    private final Token t;
+    private final int line;
+    private final Object o;
+    
+    public TokenData(Token t, int line, Object o)
+    {
+        this.t = t;
+        this.line = line;
+        this.o = o;
+    }
+    
+    public TokenData(Token t, int line)
+    {
+        this(t, line, null);
+    }
+
+    @Override
+    public String toString() 
+    {
+        StringBuilder sb = new StringBuilder();
+        sb.append(t);
+        sb.append('(');
+        sb.append(line);
+        if(o != null)
+        {
+            sb.append(", ");
+            sb.append(o);
+        }
+        sb.append(')');
+        return sb.toString();
+    }
+}

+ 365 - 0
src/me/hammerle/snuviscript/token/Tokenizer.java

@@ -0,0 +1,365 @@
+package me.hammerle.snuviscript.token;
+
+import java.util.LinkedList;
+import me.hammerle.snuviscript.exceptions.PreScriptException;
+
+public class Tokenizer 
+{
+    private final char[] code;
+    private int line;
+    
+    private final LinkedList<TokenData> data;
+    
+    public Tokenizer(String code)
+    {
+        this.code = code.toCharArray();
+        this.data = new LinkedList<>();
+    }
+    
+    private void addToken(Token t)
+    {
+        data.add(new TokenData(t, line));
+    }
+    
+    private void addToken(Token t, Object o)
+    {
+        data.add(new TokenData(t, line, o));
+    }
+    
+    public void tokenize()
+    {
+        line = 0;
+        for(int index = 0; index < code.length; index++)
+        {
+            if(Character.isLetter(code[index]))
+            {
+                int old = index;
+                index++;
+                while(index < code.length && Character.isLetterOrDigit(code[index]))
+                {
+                    index++;
+                }
+                String s = new String(code, old, index - old);
+                switch(s)
+                {
+                    case "if": addToken(Token.IF); break;
+                    case "else": addToken(Token.ELSE); break;
+                    case "for": addToken(Token.FOR); break;
+                    case "while": addToken(Token.WHILE); break;
+                    case "function": addToken(Token.FUNCTION); break;
+                    case "break": addToken(Token.BREAK); break;
+                    case "continue": addToken(Token.CONTINUE); break;
+                    case "return": addToken(Token.RETURN); break;
+                    case "goto": addToken(Token.GOTO); break;
+                    case "gosub": addToken(Token.GOSUB); break;
+                    default:
+                        addToken(Token.VAR, s);
+                }
+                index--;
+            }
+            else if(Character.isDigit(code[index]))
+            {
+                int value = code[index] - '0';
+                index++;
+                boolean b = true;
+                while(index < code.length)
+                {
+                    if(Character.isDigit(code[index]))
+                    {
+                        if(value <= (2147483647 - code[index] + '0') / 10)
+                        {
+                            value = value * 10 + code[index] - '0';
+                        }
+                        else
+                        {
+                            throw new PreScriptException("int to big", line);
+                        }
+                    }
+                    else if(code[index] == '.')
+                    {
+                        index++;
+                        double dValue = value;
+                        double factor = 10.0;
+                        while(index < code.length)
+                        {
+                            if(Character.isDigit(code[index]))
+                            {
+                                dValue = dValue + (code[index] - '0') / factor;
+                                factor *= 10.0;
+                            }
+                            else
+                            {
+                                break;
+                            }
+                            index++;
+                        }
+                        addToken(Token.DOUBLE, dValue);
+                        b = false;
+                        break;
+                    }
+                    else
+                    {
+                        break;
+                    }
+                    index++;
+                }
+                if(b)
+                {
+                    addToken(Token.INT, value);
+                }
+                index--;
+            }
+            else
+            {
+                int startLine = line;
+                try
+                {
+                    switch(code[index])
+                    {
+                        case '\n':
+                            line++;
+                            break;
+                        case '@':
+                            int old = index;
+                            index++;
+                            while(index < code.length && Character.isLetterOrDigit(code[index]))
+                            {
+                                index++;
+                            }
+                            addToken(Token.LABEL, new String(code, old, index - old));
+                            index--;
+                            break;
+                        case '+':
+                            switch(code[index + 1])
+                            {
+                                case '+':
+                                    addToken(Token.INC);
+                                    index++;
+                                    break;
+                                case '=':
+                                    addToken(Token.ADD_SET);
+                                    index++;
+                                    break;
+                                default:
+                                    addToken(Token.ADD);
+                            }
+                            break;
+                        case '-':
+                            switch(code[index + 1])
+                            {
+                                case '-':
+                                    addToken(Token.DEC);
+                                    index++;
+                                    break;
+                                case '=':
+                                    addToken(Token.SUB_SET);
+                                    index++;
+                                    break;
+                                default:
+                                    addToken(Token.SUB);
+                            }
+                            break;
+                        case '*':
+                            if(code[index + 1] == '=')
+                            {
+                                addToken(Token.MUL_SET);
+                                index++;
+                            }
+                            else
+                            {
+                                addToken(Token.MUL);
+                            }
+                            break;
+                        case '/':
+                            switch(code[index + 1])
+                            {
+                                case '/':
+                                    index += 2;
+                                    while(code[index] != '\n')
+                                    {
+                                        index++;
+                                    }
+                                    index--;
+                                    break;
+                                case '*':
+                                    index += 2;
+                                    while(code[index] != '*' && code[index + 1] != '/')
+                                    {
+                                        if(code[index] == '\n')
+                                        {
+                                            line++;
+                                        }
+                                        index++;
+                                    }
+                                    index++;
+                                    break;
+                                case '=':
+                                    addToken(Token.DIV_SET);
+                                    index++;
+                                    break;
+                                default:
+                                    addToken(Token.DIV);
+                            }
+                            break;
+                        case '!':
+                            if(code[index + 1] == '=')
+                            {
+                                addToken(Token.NOT_EQUAL);
+                                index++;
+                                break;
+                            }
+                            else
+                            {
+                                addToken(Token.INVERT);
+                            }
+                            break;
+                        case '~':
+                            addToken(Token.BIT_INVERT);
+                            break;
+                        case '%':
+                            if(code[index + 1] == '=')
+                            {
+                                addToken(Token.MOD_SET);
+                                index++;
+                            }
+                            else
+                            {
+                                addToken(Token.MOD);
+                            }
+                            break;
+                        case '<':
+                            switch(code[index + 1])
+                            {
+                                case '<':
+                                    if(code[index + 2] == '=')
+                                    {
+                                        addToken(Token.LEFT_SHIFT_SET);
+                                        index += 2;
+                                    }
+                                    else
+                                    {
+                                        addToken(Token.LEFT_SHIFT);
+                                        index++;
+                                    }
+                                    break;
+                                case '=':
+                                    addToken(Token.SMALLER_EQUAL);
+                                    index++;
+                                    break;
+                                default:
+                                    addToken(Token.SMALLER);
+                            }
+                            break;
+                        case '>':
+                            switch(code[index + 1])
+                            {
+                                case '>':
+                                    if(code[index + 2] == '=')
+                                    {
+                                        addToken(Token.RIGHT_SHIFT_SET);
+                                        index += 2;
+                                    }
+                                    else
+                                    {
+                                        addToken(Token.RIGHT_SHIFT);
+                                        index++;
+                                    }
+                                    break;
+                                case '=':
+                                    addToken(Token.GREATER_EQUAL);
+                                    index++;
+                                    break;
+                                default:
+                                    addToken(Token.GREATER);
+                            }
+                            break;
+                        case '=':
+                            if(code[index + 1] == '=')
+                            {
+                                addToken(Token.EQUAL);
+                                index++;
+                                break;
+                            }
+                            else
+                            {
+                                addToken(Token.SET);
+                            }
+                            break;
+                        case '&':
+                            switch(code[index + 1])
+                            {
+                                case '&':
+                                    addToken(Token.AND);
+                                    index++;
+                                    break;
+                                case '=':
+                                    addToken(Token.BIT_AND_SET);
+                                    index++;
+                                    break;
+                                default:
+                                    addToken(Token.BIT_AND);
+                            }
+                            break;
+                        case '^':
+                            if(code[index + 1] == '=')
+                            {
+                                addToken(Token.BIT_XOR_SET);
+                                index++;
+                                break;
+                            }
+                            else
+                            {
+                                addToken(Token.BIT_XOR);
+                            }
+                            break;
+                        case '|':
+                            switch(code[index + 1])
+                            {
+                                case '|':
+                                    addToken(Token.OR);
+                                    index++;
+                                    break;
+                                case '=':
+                                    addToken(Token.BIT_OR_SET);
+                                    index++;
+                                    break;
+                                default:
+                                    addToken(Token.BIT_OR);
+                            }
+                            break;
+                        case ',':
+                            addToken(Token.COMMA);
+                            break;
+                        case '(':
+                            addToken(Token.OPEN_BRACKET);
+                            break;
+                        case ')':
+                            addToken(Token.CLOSE_BRACKET);
+                            break;
+                        case '[':
+                            addToken(Token.OPEN_SQUARE_BRACKET);
+                            break;
+                        case ']':
+                            addToken(Token.CLOSE_SQUARE_BRACKET);
+                            break;
+                        case '{':
+                            addToken(Token.OPEN_CURVED_BRACKET);
+                            break;
+                        case '}':
+                            addToken(Token.CLOSE_CURVED_BRACKET);
+                            break;
+                        case ';':
+                            addToken(Token.SEMICOLON);
+                            break;
+                    }
+                }
+                catch(ArrayIndexOutOfBoundsException ex)
+                {
+                    throw new PreScriptException("unexpected code end", startLine, line);
+                }
+            }
+        }
+        
+        data.forEach(d -> System.out.println(d));
+    }
+}

+ 0 - 13
src/me/hammerle/snuviscript/variable/LocalVariable.java

@@ -2,7 +2,6 @@ package me.hammerle.snuviscript.variable;
 
 import java.util.HashMap;
 import me.hammerle.snuviscript.code.Script;
-import me.hammerle.snuviscript.math.Fraction;
 
 public class LocalVariable extends Variable
 {
@@ -23,18 +22,6 @@ public class LocalVariable extends Variable
         return getVariable(sc).get(sc);
     }
     
-    @Override
-    public Fraction getFraction(Script sc)
-    {
-        return getVariable(sc).getFraction(sc);
-    }
-    
-    @Override
-    public int getInt(Script sc)
-    {
-        return getVariable(sc).getInt(sc);
-    }
-    
     @Override
     public double getDouble(Script sc)
     {

+ 1 - 14
src/me/hammerle/snuviscript/variable/Variable.java

@@ -2,7 +2,6 @@ package me.hammerle.snuviscript.variable;
 
 import me.hammerle.snuviscript.code.Script;
 import me.hammerle.snuviscript.code.InputProvider;
-import me.hammerle.snuviscript.math.Fraction;
 
 public class Variable extends InputProvider
 {
@@ -32,22 +31,10 @@ public class Variable extends InputProvider
         return o;
     }
     
-    @Override
-    public Fraction getFraction(Script sc)
-    {
-        return (Fraction) o;
-    }
-    
-    @Override
-    public int getInt(Script sc)
-    {
-        return getFraction(sc).intValue();
-    }
-    
     @Override
     public double getDouble(Script sc)
     {
-        return getFraction(sc).doubleValue();
+        return (double) o;
     }
     
     @Override

+ 7 - 14
test.sbasic

@@ -1,16 +1,9 @@
-print("start");
-if(true) {
-  print(1);
-  if(false) {
-    print(2);
-  }
-  print(3);
-}
-elseif(3 < 4)
+wusi = 7483647.3;
+hallo = 2147483647;
+wusi++;
+b = wusi - 3;
+if(wusi < b && wusi == 53)
 {
-    print(5);
-} 
-else {
-  print(4);
+    print(a);
 }
-print("ende");
+print(b);

+ 0 - 3
translation

@@ -1,3 +0,0 @@
-Translation from SnuviScript to SnuviScriptRecoded
-
-else, try, catch, break, continue must be without ()