Skip to content

Commit

Permalink
+ Mesh Editor.
Browse files Browse the repository at this point in the history
#2 ExportAs ok
Improving TreeNode. Addition vectors 1/1 (revert to my Android Calculator App)
Game works again.
TextDialog in feature processing
Include spaces in AlgebraicTree formulas.
New class analyze StringAnalyser.+

Signed-off-by: Manuel Daniel Dahmen <[email protected]>
  • Loading branch information
manuelddahmen committed Jan 28, 2024
1 parent 58755c0 commit fdf494f
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 20 deletions.
91 changes: 78 additions & 13 deletions src/main/java/one/empty3/library1/tree/StringAnalyser.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,42 @@

package one.empty3.library1.tree;

import org.apache.xerces.impl.xpath.XPath;
import one.empty3.library.StructureMatrix;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

public class StringAnalyser {
private HashMap<Integer, Token> definitions = new HashMap<>();
protected HashMap<Integer, Token> definitions = new HashMap<>();
private HashMap<String, Class> classes;
private int index = 0;

@NotNull
protected Construct getConstruct() {
return construct;
}

abstract class Token {
protected Action action;
protected Class aClass;
protected Method method;
protected Variable variable;
private boolean successful = false;
private StructureMatrix<Token> nextTokens = new StructureMatrix<>(1, Token.class);

public Token() {
index++;
this.action = action;
}

public Token addToken(Token token) {
index++;
definitions.put(index, token);
return token;
this.nextTokens.setElem(token, this.nextTokens.getData1d().size());
index++;
return this;
}

public void setAction(Action action) {
Expand All @@ -65,6 +74,7 @@ public int skipBlanks(String input, int position) {
}

public int parse(String input, int position) {
System.out.println(toString());
return position = skipBlanks(input, position);
}

Expand All @@ -80,9 +90,23 @@ public Action getAction() {
return action;
}

@Override
public String toString() {
return getClass().getName() + "{" +
"action=" + action +
", aClass=" + aClass +
", method=" + method +
", variable=" + variable +
", successful=" + successful +
'}';
}

public StructureMatrix<Token> getNextToken() {
return nextTokens;
}
}

class Action {
abstract class Action {
protected final Token token;

public Token getToken() {
Expand All @@ -91,12 +115,11 @@ public Token getToken() {

public Action(Token token) {
this.token = token;
token.action = this;

}

public boolean action() {
return false;
}
public abstract boolean action();
}

class TokenPrivacyModifier extends TokenChoiceExclusive {
Expand Down Expand Up @@ -201,6 +224,10 @@ public int parse(String input, int position) {

}


/***
* Tous les tokens choisis et aucun autre.
*/
class TokenChoiceExclusive extends Token {
protected final Token[] choices;

Expand All @@ -225,6 +252,10 @@ public int parse(String input, int position) {
}
}
setSuccessful(true);
for (int i = 0; i < choices.length; i++) {
getNextToken().getData1d().clear();
getNextToken().add(choices[i]);
}
return position;
}
}
Expand Down Expand Up @@ -352,6 +383,8 @@ public MultiTokenOptional(Token... options) {

@Override
public int parse(String input, int position) {
getNextToken().data1d.clear();
;
position = super.parse(input, position);
input = input.substring(position);
boolean allOk = true;
Expand All @@ -363,12 +396,13 @@ public int parse(String input, int position) {
position1 = token.parse(input, position1);
if (!token.isSuccessful()) {
allOk = false;
} else {
allNotOk = false;
} else {
// getNextToken().data1d.add(token);
}
}
}
setSuccessful(allOk);
setSuccessful(!allNotOk || allOk);
return position1;
}
}
Expand Down Expand Up @@ -436,9 +470,15 @@ public int parse(String input, int position) {
i++;
passed = true;
}
if (passed)
if (passed && i - position1 > 0) {
this.setName(input.substring(position1, i));
return super.parse(input, position);
setSuccessful(true);
return i;
} else {
setSuccessful(false);
return position1;
}

}

private void setName(String name) {
Expand Down Expand Up @@ -791,12 +831,37 @@ class Construct {
public void construct() {
Token token = definitions.get(0);
}

@Override
public String toString() {
return "Construct{" +
"currentField=" + currentField +
", currentMethod=" + currentMethod +
", packageName='" + packageName + '\'' +
", currentClass=" + currentClass +
", cited=" + cited +
", fieldMembers=" + fieldMembers +
", methodMembers=" + methodMembers +
'}';
}
}

private final Construct construct = new Construct();
private final ActualContext actualContext = new ActualContext();

public int parse(String input) {
return definitions.get(0).parse(input, 0);
Token token = definitions.get(0);
int position1 = token.parse(input, 0);
input = input.substring(position1);
while (token != null && token.isSuccessful()) {
position1 = token.parse(input, position1);
input = input.substring(position1);
if (token.getNextToken() != null)
for (int i = 0; i < token.getNextToken().data1d.size(); i++) {
token.getNextToken().getElem(i);
}

}
return position1;
}
}
24 changes: 17 additions & 7 deletions src/test/java/one/empty3/library1/tree/TestAlgebraicTreeVector.kt
Original file line number Diff line number Diff line change
Expand Up @@ -755,14 +755,24 @@ class TestAlgebraicTreeVector() {
val vars = HashMap<String, Double>()
vars["r"] = r
val stringAnalyser: StringAnalyser = StringAnalyser()
val parse: Int = stringAnalyser.parse(
"class Numb {\n" +
"double func1(Double a, Double b, Double c) {\n" +
"Double d = c+b/a\n" +
"return d\n" +
"}\n" +

val input =
"package one.empty3;\n\n" +
"class Numb {\n" +
"\tdouble func1(Double a, Double b, Double c) {\n" +
"\t\tDouble d = c+b/a;\n" +
"\t\treturn d\n" +
"\t}\n" +
"}\n"
)

val parse: Int = stringAnalyser.parse(input)
println(input)
println(stringAnalyser.construct)
stringAnalyser.definitions.keys.sorted().forEach {
if (it != null) {
println("[" + it + "]\t" + stringAnalyser.definitions.get(it))
}
}
println(parse)
}

Expand Down

0 comments on commit fdf494f

Please sign in to comment.