|
@@ -1,76 +0,0 @@
|
|
-package me.hammerle.snuviscript;
|
|
|
|
-
|
|
|
|
-import me.hammerle.code.ISnuviLogger;
|
|
|
|
-import me.hammerle.code.ISnuviScheduler;
|
|
|
|
-import me.hammerle.code.Script;
|
|
|
|
-import me.hammerle.code.SnuviParser;
|
|
|
|
-import me.hammerle.exceptions.PreScriptException;
|
|
|
|
-import me.hammerle.math.Fraction;
|
|
|
|
-
|
|
|
|
-public class SnuviScript
|
|
|
|
-{
|
|
|
|
- public static void main(String[] args)
|
|
|
|
- {
|
|
|
|
- ISnuviLogger logger = new ISnuviLogger()
|
|
|
|
- {
|
|
|
|
- @Override
|
|
|
|
- public void printException(Exception ex, String function, Script s, int line)
|
|
|
|
- {
|
|
|
|
- System.out.println("Exception " + ex);
|
|
|
|
- System.out.println("function " + function);
|
|
|
|
- System.out.println("Line: " + line);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void printException(Exception ex, String function, String s, int line)
|
|
|
|
- {
|
|
|
|
- System.out.println("Exception " + ex);
|
|
|
|
- System.out.println("function " + function);
|
|
|
|
- System.out.println("Line: " + line);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void printWarning(String s)
|
|
|
|
- {
|
|
|
|
- System.out.println("Warning: " + s);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void printInfo(String s)
|
|
|
|
- {
|
|
|
|
- System.out.println("Info: " + s);
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- SnuviParser parser = new SnuviParser(logger, new ISnuviScheduler()
|
|
|
|
- {
|
|
|
|
- @Override
|
|
|
|
- public int scheduleTask(Runnable r)
|
|
|
|
- {
|
|
|
|
- System.out.println("Schedule");
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public int scheduleTask(Runnable r, long delay)
|
|
|
|
- {
|
|
|
|
- System.out.println("Schedule");
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- parser.registerConsumer("print", (o, sc) -> System.out.println(o[0]));
|
|
|
|
- parser.registerFunction("get", (o, sc) -> new Fraction(1));
|
|
|
|
-
|
|
|
|
- String s = "print(5*(-3));";
|
|
|
|
- System.out.println(s);
|
|
|
|
- System.out.println();
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- parser.startScript("test", s);
|
|
|
|
- }
|
|
|
|
- catch(PreScriptException ex)
|
|
|
|
- {
|
|
|
|
- logger.printException(ex, "none" , "test", ex.getLine());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|