-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a48879
commit 2ec0b0a
Showing
8 changed files
with
104 additions
and
300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.kingmang.lazurite; | ||
|
||
import com.kingmang.lazurite.LZREx.LZRExeption; | ||
import com.kingmang.lazurite.core.CallStack; | ||
import com.kingmang.lazurite.parser.pars.Lexer; | ||
import com.kingmang.lazurite.parser.pars.Token; | ||
import com.kingmang.lazurite.parser.pars.Parser; | ||
import com.kingmang.lazurite.parser.ast.MStatement; | ||
import com.kingmang.lazurite.parser.ast.Expression; | ||
import com.kingmang.lazurite.log; | ||
import com.kingmang.lazurite.runtime.LZR.LZRNumber; | ||
import com.kingmang.lazurite.runtime.Value; | ||
import com.kingmang.lazurite.runtime.Variables; | ||
|
||
import java.util.Date; | ||
import java.util.List; | ||
|
||
public class Handler { | ||
public static void handle(String input, String pathToScript, boolean isExec) { | ||
try { | ||
try{ | ||
if(!isExec) { | ||
log.clear(); | ||
log.append(String.format("Run (%s)\n", new Date())); | ||
} | ||
} | ||
catch (Exception ignored){} | ||
final List<Token> tokens = new Lexer(input).tokenize(); | ||
final MStatement program = (MStatement) new Parser(tokens).parse(); | ||
program.execute(); | ||
if(!isExec){ | ||
Variables.clear(); | ||
} | ||
} catch (LZRExeption ex) { | ||
try{ | ||
log.append(String.format("%s: %s in %s (%s)\n", ex.getType(), ex.getText(), pathToScript, new Date())); | ||
} | ||
catch (Exception ex2){} | ||
System.out.println(String.format("%s: %s in %s", ex.getType(), ex.getText(), pathToScript)); | ||
if(!isExec) { | ||
Variables.clear(); | ||
} | ||
int count = CallStack.getCalls().size(); | ||
if (count == 0) return; | ||
System.out.println(String.format("\nCall stack was:")); | ||
for (CallStack.CallInfo info : CallStack.getCalls()) { | ||
System.out.println(" " + count + ". " + info); | ||
count--; | ||
} | ||
} | ||
} | ||
public static Value returnHandle(String input, String pathToScript) { | ||
try { | ||
final List<Token> tokens = new Lexer(input).tokenize(); | ||
final Expression program = new Parser(tokens).expression(); | ||
return program.eval(); | ||
} catch (LZRExeption ex) { | ||
System.out.println(String.format("%s: %s in %s", ex.getType(), ex.getText(), pathToScript)); | ||
return LZRNumber.ZERO; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 0 additions & 36 deletions
36
src/main/java/com/kingmang/lazurite/parser/linters/AssignValidator.java
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
src/main/java/com/kingmang/lazurite/parser/linters/DefaultFunctionsOverrideValidator.java
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
src/main/java/com/kingmang/lazurite/parser/linters/LintVisitor.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.