Skip to content

Commit

Permalink
v3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
NGSpace committed Apr 30, 2024
1 parent d23c94e commit 0b2452c
Show file tree
Hide file tree
Showing 60 changed files with 1,368 additions and 566 deletions.
1 change: 1 addition & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
eclipse.preferences.version=1
encoding//src/main/java/io/github/ngspace/hudder/meta/methods/ItemStackMethods.java=UTF-8
encoding/<project>=windows-1252
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ yarn_mappings=1.20.4+build.3
loader_version=0.15.7

# Mod Properties
mod_version=2.0.0
mod_version=3.0.0
maven_group=io.github.ngspace.hudder
archives_base_name=hudder

Expand Down
File renamed without changes.
41 changes: 0 additions & 41 deletions src/main/java/io/github/ngspace/hudder/CachedTextReader.java

This file was deleted.

213 changes: 136 additions & 77 deletions src/main/java/io/github/ngspace/hudder/Hudder.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
public abstract class ATextCompiler {

public static Map<String, String> compilers = new HashMap<String, String>();
private static final Map<String, ATextCompiler> loadedcomps = new HashMap<String,ATextCompiler>();

public static final String EMPTYCOM = "io.github.ngspace.hudder.compilers.EmptyCompiler";
public static final String DEFAULT_COMPILER = "io.github.ngspace.hudder.compilers.DefaultCompiler";
Expand All @@ -33,8 +34,18 @@ public abstract class ATextCompiler {
registerCompiler("null", EMPTYCOM);
registerCompiler( null , EMPTYCOM);
}

public static ATextCompiler getCompilerFromName(String name) throws ReflectiveOperationException,
IllegalArgumentException, SecurityException {

String comp = name.toLowerCase();
if (ATextCompiler.compilers.get(comp)==null) return getCompilerFromName("default");
if (!loadedcomps.containsKey(comp)) loadedcomps.put(comp,(ATextCompiler) Class.forName
(ATextCompiler.compilers.get(comp)).getDeclaredConstructor().newInstance());
return loadedcomps.get(comp);
}

protected Map<String, Object> variables = new HashMap<String, Object>();
protected static Map<String, Object> variables = new HashMap<String, Object>();

public abstract CompileResult compile(ConfigInfo info, String text) throws CompileException;
public abstract Object getVariable(String key) throws CompileException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
import static io.github.ngspace.hudder.data_management.StringData.getString;
import static io.github.ngspace.hudder.util.MathUtils.eval;

import io.github.ngspace.hudder.config.ConfigInfo;
import io.github.ngspace.hudder.config.ConfigManager;

public abstract class AVarTextCompiler extends ATextCompiler {
public static ConfigInfo info = ConfigManager.getConfig();

@Override public Object getVariable(String variable) throws CompileException {
String advkey = variable.trim().replace(" ", "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public class CompileException extends Exception {
public final int line;
public final int col;
public final boolean fatal;

public CompileException(String string) {this(string,0,0);}
public CompileException(String string, boolean fatal) {this(string,0,0,fatal);}
public CompileException(String string, int line, int col) {this(string,line,col,false);}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.ngspace.hudder.compilers;

import io.github.ngspace.hudder.meta.Element;
import io.github.ngspace.hudder.meta.elements.Element;

public class CompileResult {
public String TopLeftText;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ public class DefaultCompiler extends TextCompiler {
compileState = TEXT_STATE;
CompileResult res = solveCondition(info,
AddToStringArray(condArgs,condArgBuilder.toString().trim()));
// for (Element e : res.elements) currentMeta.elements.add(e);
// resultBuilder.append(res.TopLeftText);
currentMeta.combineWithResult(res, true);
break;
case '"':
Expand Down Expand Up @@ -166,41 +164,41 @@ else if(c==' '&&condBuilder.toString().equals("while")) {
} else if(c==' '&&condBuilder.toString().equals("if")) condBuilder.setLength(0);
else condBuilder.append(c);
}
StringBuilder strb = new StringBuilder();
boolean condition = conditionCheck(condBuilder.toString());
String cond = condBuilder.toString();
StringBuilder instructions = new StringBuilder();
boolean condition = conditionCheck(cond);
ind++;
if (ind<text.length()&&text.charAt(ind)=='\t') {
ind++;
for (;ind<text.length();ind++) {
c = text.charAt(ind);
if ((c=='\n')&&ind+1<text.length()) {
if (text.charAt(ind+1)=='\t') {ind++;}
else {strb.append('\n');break;}
else {instructions.append('\n');break;}

}
if (condition) strb.append(c);
if (condition) instructions.append(c);
}
} else ind--;
if (!condition) break;
if (isWhile) {
while(conditionCheck(condBuilder.toString()))
currentMeta.combineWithResult(compile(info, strb.toString()), false);
String cmds = instructions.toString();
while(conditionCheck(cond)) currentMeta.combineWithResult(compile(info, cmds), false);
break;
}
if (condition) {
CompileResult result = compile(info, strb.toString());
currentMeta.combineWithResult(result, false);
String resStr = (result.TopLeftText);
resultBuilder.append(resStr);
if (resStr.length()>0&&resStr.charAt(resStr.length()-1)!='\n')resultBuilder.append('\n');
}
CompileResult result = compile(info, instructions.toString());
currentMeta.combineWithResult(result, false);
String resStr = (result.TopLeftText);
resultBuilder.append(resStr);
if (resStr.length()>0&&resStr.charAt(resStr.length()-1)!='\n')resultBuilder.append('\n');
break;
}
default: throw new CompileException("Compiler reached an unknown state: "+compileState,line,col);
}
}
} catch (CompileException e) {
throw new CompileException(e.getMessage(),line+e.line,-1);
} catch (Exception e) {throw new CompileException(e.getMessage());}
}
currentMeta.addString(resultBuilder.toString(), true);

if (compileState!=0) throw new CompileException(getErrorMessage(compileState),line,col);
Expand Down Expand Up @@ -231,5 +229,4 @@ public static String[] AddToStringArray(String[] arr, String string) {
newarr[arr.length] = string;
return newarr;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.github.ngspace.hudder.config.ConfigInfo;

public class EmptyCompiler extends TextCompiler {
public class EmptyCompiler extends AVarTextCompiler {
@Override
public CompileResult compile(ConfigInfo info, String text) throws CompileException {return CompileResult.of(text);}
}
Loading

0 comments on commit 0b2452c

Please sign in to comment.