Commit 03b00723 authored by Custom2043's avatar Custom2043
Browse files

Update

parent 00d620d1
No preview for this file type
...@@ -7,6 +7,7 @@ backslash = "\\" ...@@ -7,6 +7,7 @@ backslash = "\\"
CharacterToken = singleQuote [notToken:notToken] {|orToken character1:(NumberChar|SingleChar) ["-" character2:(NumberChar|SingleChar)]} singleQuote CharacterToken = singleQuote [notToken:notToken] {|orToken character1:(NumberChar|SingleChar) ["-" character2:(NumberChar|SingleChar)]} singleQuote
StringToken = (quote {charTokens:(CharacterToken | SingleChar)} quote) | singleChar:CharacterToken StringToken = (quote {charTokens:(CharacterToken | SingleChar)} quote) | singleChar:CharacterToken
#ignoreKeyword = "_ignore"
letter = 'a-z|A-Z' letter = 'a-z|A-Z'
digit = '0-9' digit = '0-9'
exprOpen = "(" exprOpen = "("
...@@ -29,7 +30,7 @@ ignore = {Space|Jump} ...@@ -29,7 +30,7 @@ ignore = {Space|Jump}
SearchName = [notGenerated:nonGeneratedName] id:Identifier ":" SearchName = [notGenerated:nonGeneratedName] id:Identifier ":"
LineHeader = [trans:transientToken] id:Identifier equals LineHeader = [trans:transientToken] id:Identifier equals
TokenSearchToken = ([trans:transientToken] id:Identifier)|string:StringToken TokenSearchToken = ([trans:transientToken [included:nonGeneratedName]] id:Identifier)|string:StringToken
ArraySearchToken = [{minSize:digit} "-"] arrayOpen [orToken left:SearchToken] {searches:SearchToken} [right:SearchToken orToken] arrayClose ["-" {maxSize:digit}] ArraySearchToken = [{minSize:digit} "-"] arrayOpen [orToken left:SearchToken] {searches:SearchToken} [right:SearchToken orToken] arrayClose ["-" {maxSize:digit}]
OptionalSearchToken = optionOpen {searches:SearchToken} optionClose OptionalSearchToken = optionOpen {searches:SearchToken} optionClose
BracketSearchToken = exprOpen {searches:SearchToken} exprClose BracketSearchToken = exprOpen {searches:SearchToken} exprClose
...@@ -37,6 +38,6 @@ OrSearchToken = 2-{searches:#SearchToken orToken|} ...@@ -37,6 +38,6 @@ OrSearchToken = 2-{searches:#SearchToken orToken|}
#SearchToken = ([searchName:SearchName] searchToken:(TokenSearchToken|ArraySearchToken|OptionalSearchToken|BracketSearchToken)) | searchToken:OrSearchToken #SearchToken = ([searchName:SearchName] searchToken:(TokenSearchToken|ArraySearchToken|OptionalSearchToken|BracketSearchToken)) | searchToken:OrSearchToken
Line = header:LineHeader {searchTokens:SearchToken} Line = header:LineHeader [firstIgnore:ignoreKeyword] {searchTokens:SearchToken} [lastIgnore:ignoreKeyword]
anyChar = '*' anyChar = '*'
...@@ -76,7 +76,15 @@ public class ClassGenerator ...@@ -76,7 +76,15 @@ public class ClassGenerator
classBuilder.append(lineIndex); classBuilder.append(lineIndex);
classBuilder.append(", "); classBuilder.append(", ");
classBuilder.append(l.header.id.getName()); classBuilder.append(l.header.id.getName());
classBuilder.append(".class);"); classBuilder.append(".class");
if (l.firstIgnore != null || l.lastIgnore != null)
{
classBuilder.append(", ");
classBuilder.append(l.firstIgnore != null);
classBuilder.append(", ");
classBuilder.append(l.lastIgnore != null);
}
classBuilder.append(");");
classBuilder.append(Generator.getLineJump()); classBuilder.append(Generator.getLineJump());
classBuilder.append(Generator.getLineJump()); classBuilder.append(Generator.getLineJump());
...@@ -155,11 +163,11 @@ public class ClassGenerator ...@@ -155,11 +163,11 @@ public class ClassGenerator
builder.append(", "); builder.append(", ");
} }
if (a.minSize != null || a.maxSize != null) if (a.minSize.length != 0 || a.maxSize.length != 0)
{ {
builder.append(a.minSize == null ? 1 : Integer.valueOf(Token.getStringFromTokens(a.minSize))); builder.append(a.minSize.length == 0 ? 1 : Integer.valueOf(Token.getStringFromTokens(a.minSize)));
builder.append(", "); builder.append(", ");
builder.append(a.maxSize == null ? "Integer.MAX_VALUE" : Integer.valueOf(Token.getStringFromTokens(a.maxSize))); builder.append(a.maxSize.length == 0 ? "Integer.MAX_VALUE" : Integer.valueOf(Token.getStringFromTokens(a.maxSize)));
builder.append(", "); builder.append(", ");
} }
} }
...@@ -181,7 +189,10 @@ public class ClassGenerator ...@@ -181,7 +189,10 @@ public class ClassGenerator
generateStringToken(tokenSearch.string, currentLine.isParserString() ? currentLine.header.id.getName() : null, lineIndex, builder); generateStringToken(tokenSearch.string, currentLine.isParserString() ? currentLine.header.id.getName() : null, lineIndex, builder);
if (tokenSearch.trans != null) if (tokenSearch.trans != null)
builder.append(", true"); {
builder.append(", ");
builder.append(tokenSearch.included != null);
}
builder.append(")"); builder.append(")");
} }
......
...@@ -11,6 +11,7 @@ import java.util.List; ...@@ -11,6 +11,7 @@ import java.util.List;
import javax.tools.SimpleJavaFileObject; import javax.tools.SimpleJavaFileObject;
import parser.Ignore;
import parser.ParserString; import parser.ParserString;
import parser.Token; import parser.Token;
import tokens.*; import tokens.*;
...@@ -68,11 +69,16 @@ public class Compiler ...@@ -68,11 +69,16 @@ public class Compiler
else if (t instanceof Line) else if (t instanceof Line)
{ {
for (Line l : lines) for (Line l : lines)
{
if (!l.header.id.getName().equals("ignore") && l.header.id.getName().equals(((Line)t).header.id.getName())) if (!l.header.id.getName().equals("ignore") && l.header.id.getName().equals(((Line)t).header.id.getName()))
{ {
report(new Info(InfoModel.idAlreadyDeclared, t)); report(new Info(InfoModel.idAlreadyDeclared, t));
break; break;
} }
if (l.firstIgnore != null || l.lastIgnore != null)
if (Ignore.getIgnoreAtLine(Line.builder.getLine()) == null)
report(new Info(InfoModel.nonExistentIgnore, t));
}
for (String s : javaKeywords) for (String s : javaKeywords)
if (s.equals(((Line)t).header.id.getName())) if (s.equals(((Line)t).header.id.getName()))
...@@ -184,12 +190,12 @@ public class Compiler ...@@ -184,12 +190,12 @@ public class Compiler
{ {
ArraySearchToken ats = (ArraySearchToken)token; ArraySearchToken ats = (ArraySearchToken)token;
int min, max; int min, max;
if (ats.minSize != null) if (ats.minSize.length != 0)
min = Integer.valueOf(Token.getStringFromTokens(ats.minSize)); min = Integer.valueOf(Token.getStringFromTokens(ats.minSize));
else else
min = 1; min = 1;
if (ats.maxSize != null) if (ats.maxSize.length != 0)
max = Integer.valueOf(Token.getStringFromTokens(ats.maxSize)); max = Integer.valueOf(Token.getStringFromTokens(ats.maxSize));
else else
max = Integer.MAX_VALUE; max = Integer.MAX_VALUE;
......
...@@ -34,7 +34,8 @@ enum InfoModel ...@@ -34,7 +34,8 @@ enum InfoModel
tokenUndeclared(Etat.ERROR, "This token doesn't exist"), tokenUndeclared(Etat.ERROR, "This token doesn't exist"),
illegalIdentifier(Etat.ERROR, "This name is not allowed"), illegalIdentifier(Etat.ERROR, "This name is not allowed"),
invalidTransSearch(Etat.ERROR, "'#' can only be used with a transient token"), invalidTransSearch(Etat.ERROR, "'#' can only be used with a transient token"),
incorrectRange(Etat.ERROR, "Min and max size must be positive integers (min <= max)") incorrectRange(Etat.ERROR, "Min and max size must be positive integers (min <= max)"),
nonExistentIgnore(Etat.ERROR, "Can't use ignore because it has not been defined")
; ;
public final Etat etat; public final Etat etat;
......
...@@ -12,7 +12,7 @@ public class Ignore extends Builder ...@@ -12,7 +12,7 @@ public class Ignore extends Builder
public static final Ignore[] ignoredSearches = public static final Ignore[] ignoredSearches =
{ {
new Ignore(23, new ArraySearch( new Ignore(24, new ArraySearch(
new OrSearch( new OrSearch(
new TokenSearch(Space.builder), new TokenSearch(Space.builder),
new TokenSearch(Jump.builder) new TokenSearch(Jump.builder)
......
...@@ -67,7 +67,6 @@ public class Parser ...@@ -67,7 +67,6 @@ public class Parser
{ {
//System.out.println("Searching for : "+tokenBuilder+" from index : "+index); //System.out.println("Searching for : "+tokenBuilder+" from index : "+index);
int oldIndex = index;
Token t; Token t;
ParserMemory memory = ParserMemory.setLastResult(index, line); ParserMemory memory = ParserMemory.setLastResult(index, line);
...@@ -88,11 +87,6 @@ public class Parser ...@@ -88,11 +87,6 @@ public class Parser
currentToken = t; currentToken = t;
ParserMemory.addResult(currentToken.getStart(), new ParserMemory(currentToken, lineBuilder.getLine())); ParserMemory.addResult(currentToken.getStart(), new ParserMemory(currentToken, lineBuilder.getLine()));
} }
else if (lineBuilder.getLine() == line && !excluded)
{
index = oldIndex;
//return null;
}
return currentToken; return currentToken;
} }
...@@ -133,6 +127,8 @@ public class Parser ...@@ -133,6 +127,8 @@ public class Parser
build.setDatas(start, index-start, getLine(start), Parser.getTokenStartColumn(start), Parser.readFrom(start, index-start), build.setDatas(start, index-start, getLine(start), Parser.getTokenStartColumn(start), Parser.readFrom(start, index-start),
total.toArray(new Token[total.size()]), sortedResults[1]); total.toArray(new Token[total.size()]), sortedResults[1]);
TokenCreator.fillContextInfos(tokenBuilder, results, null, null, -1, start);
build.getClass().getDeclaredField("searchResults").set(build, sortedResults[0]); build.getClass().getDeclaredField("searchResults").set(build, sortedResults[0]);
return build; return build;
......
...@@ -27,24 +27,28 @@ public class ParserCharacter ...@@ -27,24 +27,28 @@ public class ParserCharacter
new ParserCharacter(false, new char[]{'t'}), //10 new ParserCharacter(false, new char[]{'t'}), //10
new ParserCharacter(false, new char[]{'n'}), //11 new ParserCharacter(false, new char[]{'n'}), //11
new ParserCharacter(false, new char[]{'-'}), //12 new ParserCharacter(false, new char[]{'-'}), //12
new ParserCharacter(false, new char[]{'a', 'A'}, new char[]{'z', 'Z'}), //13 new ParserCharacter(false, new char[]{'_'}), //13
new ParserCharacter(false, new char[]{'0'}, new char[]{'9'}), //14 new ParserCharacter(false, new char[]{'i'}), //14
new ParserCharacter(false, new char[]{'('}), //15 new ParserCharacter(false, new char[]{'g'}), //15
new ParserCharacter(false, new char[]{')'}), //16 new ParserCharacter(false, new char[]{'o'}), //16
new ParserCharacter(false, new char[]{'['}), //17 new ParserCharacter(false, new char[]{'e'}), //17
new ParserCharacter(false, new char[]{']'}), //18 new ParserCharacter(false, new char[]{'a', 'A'}, new char[]{'z', 'Z'}), //18
new ParserCharacter(false, new char[]{'{'}), //19 new ParserCharacter(false, new char[]{'0'}, new char[]{'9'}), //19
new ParserCharacter(false, new char[]{'}'}), //20 new ParserCharacter(false, new char[]{'('}), //20
new ParserCharacter(false, new char[]{'!'}), //21 new ParserCharacter(false, new char[]{')'}), //21
new ParserCharacter(false, new char[]{'|'}), //22 new ParserCharacter(false, new char[]{'['}), //22
new ParserCharacter(false, new char[]{'#'}), //23 new ParserCharacter(false, new char[]{']'}), //23
new ParserCharacter(false, new char[]{'='}), //24 new ParserCharacter(false, new char[]{'{'}), //24
new ParserCharacter(false, new char[]{'_'}), //25 new ParserCharacter(false, new char[]{'}'}), //25
new ParserCharacter(false, new char[]{'\r'}), //26 new ParserCharacter(false, new char[]{'!'}), //26
new ParserCharacter(false, new char[]{'\n'}), //27 new ParserCharacter(false, new char[]{'|'}), //27
new ParserCharacter(false, new char[]{' '}), //28 new ParserCharacter(false, new char[]{'#'}), //28
new ParserCharacter(false, new char[]{'\t'}), //29 new ParserCharacter(false, new char[]{'='}), //29
new ParserCharacter(false, new char[]{':'}), //30 new ParserCharacter(false, new char[]{'\r'}), //30
new ParserCharacter(false, new char[]{'\n'}), //31
new ParserCharacter(false, new char[]{' '}), //32
new ParserCharacter(false, new char[]{'\t'}), //33
new ParserCharacter(false, new char[]{':'}), //34
}; };
/********** Do not modify or remove **********/ /********** Do not modify or remove **********/
......
...@@ -18,28 +18,29 @@ public class ParserString extends Token ...@@ -18,28 +18,29 @@ public class ParserString extends Token
trans8 = new ParserStringBuilder(true, 4, 10), trans8 = new ParserStringBuilder(true, 4, 10),
trans9 = new ParserStringBuilder(true, 4, 11), trans9 = new ParserStringBuilder(true, 4, 11),
trans10 = new ParserStringBuilder(true, 5, 12), trans10 = new ParserStringBuilder(true, 5, 12),
letter = new ParserStringBuilder(false, 7, 13), ignoreKeyword = new ParserStringBuilder(false, 7, 13),
digit = new ParserStringBuilder(false, 8, 14), letter = new ParserStringBuilder(false, 8, 14),
exprOpen = new ParserStringBuilder(false, 9, 15), digit = new ParserStringBuilder(false, 9, 15),
exprClose = new ParserStringBuilder(false, 10, 16), exprOpen = new ParserStringBuilder(false, 10, 16),
optionOpen = new ParserStringBuilder(false, 11, 17), exprClose = new ParserStringBuilder(false, 11, 17),
optionClose = new ParserStringBuilder(false, 12, 18), optionOpen = new ParserStringBuilder(false, 12, 18),
arrayOpen = new ParserStringBuilder(false, 13, 19), optionClose = new ParserStringBuilder(false, 13, 19),
arrayClose = new ParserStringBuilder(false, 14, 20), arrayOpen = new ParserStringBuilder(false, 14, 20),
notToken = new ParserStringBuilder(false, 15, 21), arrayClose = new ParserStringBuilder(false, 15, 21),
orToken = new ParserStringBuilder(false, 16, 22), notToken = new ParserStringBuilder(false, 16, 22),
transientToken = new ParserStringBuilder(false, 17, 23), orToken = new ParserStringBuilder(false, 17, 23),
equals = new ParserStringBuilder(false, 18, 24), transientToken = new ParserStringBuilder(false, 18, 24),
nonGeneratedName = new ParserStringBuilder(false, 19, 25), equals = new ParserStringBuilder(false, 19, 25),
trans11 = new ParserStringBuilder(true, 20, 26), nonGeneratedName = new ParserStringBuilder(false, 20, 26),
trans12 = new ParserStringBuilder(true, 20, 27), trans11 = new ParserStringBuilder(true, 21, 27),
trans13 = new ParserStringBuilder(true, 20, 28), trans12 = new ParserStringBuilder(true, 21, 28),
trans14 = new ParserStringBuilder(true, 21, 29), trans13 = new ParserStringBuilder(true, 21, 29),
trans15 = new ParserStringBuilder(true, 21, 30), trans14 = new ParserStringBuilder(true, 22, 30),
trans16 = new ParserStringBuilder(true, 24, 31), trans15 = new ParserStringBuilder(true, 22, 31),
trans17 = new ParserStringBuilder(true, 27, 12), trans16 = new ParserStringBuilder(true, 25, 32),
trans18 = new ParserStringBuilder(true, 27, 12), trans17 = new ParserStringBuilder(true, 28, 12),
anyChar = new ParserStringBuilder(false, 33, 32) trans18 = new ParserStringBuilder(true, 28, 12),
anyChar = new ParserStringBuilder(false, 34, 33)
; ;
private static final ParserCharacter[][] characters = private static final ParserCharacter[][] characters =
...@@ -57,26 +58,27 @@ public class ParserString extends Token ...@@ -57,26 +58,27 @@ public class ParserString extends Token
new ParserCharacter[]{ParserCharacter.chars[10]}, //10 new ParserCharacter[]{ParserCharacter.chars[10]}, //10
new ParserCharacter[]{ParserCharacter.chars[11]}, //11 new ParserCharacter[]{ParserCharacter.chars[11]}, //11
new ParserCharacter[]{ParserCharacter.chars[12]}, //12 new ParserCharacter[]{ParserCharacter.chars[12]}, //12
new ParserCharacter[]{ParserCharacter.chars[13]}, //13 new ParserCharacter[]{ParserCharacter.chars[13],ParserCharacter.chars[14],ParserCharacter.chars[15],ParserCharacter.chars[11],ParserCharacter.chars[16],ParserCharacter.chars[9],ParserCharacter.chars[17]}, //13
new ParserCharacter[]{ParserCharacter.chars[14]}, //14 new ParserCharacter[]{ParserCharacter.chars[18]}, //14
new ParserCharacter[]{ParserCharacter.chars[15]}, //15 new ParserCharacter[]{ParserCharacter.chars[19]}, //15
new ParserCharacter[]{ParserCharacter.chars[16]}, //16 new ParserCharacter[]{ParserCharacter.chars[20]}, //16
new ParserCharacter[]{ParserCharacter.chars[17]}, //17 new ParserCharacter[]{ParserCharacter.chars[21]}, //17
new ParserCharacter[]{ParserCharacter.chars[18]}, //18 new ParserCharacter[]{ParserCharacter.chars[22]}, //18
new ParserCharacter[]{ParserCharacter.chars[19]}, //19 new ParserCharacter[]{ParserCharacter.chars[23]}, //19
new ParserCharacter[]{ParserCharacter.chars[20]}, //20 new ParserCharacter[]{ParserCharacter.chars[24]}, //20
new ParserCharacter[]{ParserCharacter.chars[21]}, //21 new ParserCharacter[]{ParserCharacter.chars[25]}, //21
new ParserCharacter[]{ParserCharacter.chars[22]}, //22 new ParserCharacter[]{ParserCharacter.chars[26]}, //22
new ParserCharacter[]{ParserCharacter.chars[23]}, //23 new ParserCharacter[]{ParserCharacter.chars[27]}, //23
new ParserCharacter[]{ParserCharacter.chars[24]}, //24 new ParserCharacter[]{ParserCharacter.chars[28]}, //24
new ParserCharacter[]{ParserCharacter.chars[25]}, //25 new ParserCharacter[]{ParserCharacter.chars[29]}, //25
new ParserCharacter[]{ParserCharacter.chars[26],ParserCharacter.chars[27]}, //26 new ParserCharacter[]{ParserCharacter.chars[13]}, //26
new ParserCharacter[]{ParserCharacter.chars[26]}, //27 new ParserCharacter[]{ParserCharacter.chars[30],ParserCharacter.chars[31]}, //27
new ParserCharacter[]{ParserCharacter.chars[27]}, //28 new ParserCharacter[]{ParserCharacter.chars[30]}, //28
new ParserCharacter[]{ParserCharacter.chars[28]}, //29 new ParserCharacter[]{ParserCharacter.chars[31]}, //29
new ParserCharacter[]{ParserCharacter.chars[29]}, //30 new ParserCharacter[]{ParserCharacter.chars[32]}, //30
new ParserCharacter[]{ParserCharacter.chars[30]}, //31 new ParserCharacter[]{ParserCharacter.chars[33]}, //31
new ParserCharacter[]{ParserCharacter.any}, //32 new ParserCharacter[]{ParserCharacter.chars[34]}, //32
new ParserCharacter[]{ParserCharacter.any}, //33
}; };
/********** Do not modify or remove **********/ /********** Do not modify or remove **********/
......
...@@ -47,7 +47,12 @@ public abstract class Token ...@@ -47,7 +47,12 @@ public abstract class Token
/********** Do not modify or remove **********/ /********** Do not modify or remove **********/
private int start, length, line, column; private int start, length, line, column, index, containerPosition;
/**
* Only make sens in an array
*/
private Result previousIgnore;
private Result nextIgnore;
private String total; private String total;
private Token[] totalTokens; private Token[] totalTokens;
private Result[] ignored; private Result[] ignored;
...@@ -64,8 +69,38 @@ public abstract class Token ...@@ -64,8 +69,38 @@ public abstract class Token
this.init(); this.init();
} }
final void setContextInfos(int in, Result p, Result n, int containerPosition)
{
this.index = in;
this.previousIgnore = p;
this.nextIgnore = n;
this.containerPosition = containerPosition;
this.initContext();
}
public void init() {} public void init() {}
public void initContext() {}
public int getIndexInArray()
{
return this.index;
}
public Result getPreviousIgnore()
{
return this.previousIgnore;
}
public Result getNextIgnore()
{
return this.nextIgnore;
}
public int getInnerStart()
{
return this.start - this.containerPosition;
}
public int getInnerEnd()
{
return this.getEnd() - this.containerPosition;
}
public int getStart() public int getStart()
{ {
return this.start; return this.start;
...@@ -74,6 +109,10 @@ public abstract class Token ...@@ -74,6 +109,10 @@ public abstract class Token
{ {
return this.length; return this.length;
} }
public int getEnd()
{
return this.start + this.length;
}
public int getLine() public int getLine()
{ {
return this.line; return this.line;
......
...@@ -8,10 +8,17 @@ public class TokenBuilder extends Builder ...@@ -8,10 +8,17 @@ public class TokenBuilder extends Builder
private Search[] searches, searchesWithIgnore; private Search[] searches, searchesWithIgnore;
private final Class<? extends Token> tokenClass; private final Class<? extends Token> tokenClass;
private Ignore ignore; private Ignore ignore;
private final boolean firstIgnore, lastIgnore;
public TokenBuilder(boolean isTransient, int line, Class<? extends Token> c) public TokenBuilder(boolean isTransient, int line, Class<? extends Token> c)
{
this(isTransient, line, c, false, false);
}
public TokenBuilder(boolean isTransient, int line, Class<? extends Token> c, boolean firstIgnore, boolean lastIgnore)
{ {
super(isTransient, line); super(isTransient, line);
this.tokenClass = c; this.tokenClass = c;
this.firstIgnore = firstIgnore;
this.lastIgnore = lastIgnore;
} }
public Search[] setSearches() public Search[] setSearches()
...@@ -35,14 +42,18 @@ public class TokenBuilder extends Builder ...@@ -35,14 +42,18 @@ public class TokenBuilder extends Builder
this.searchesWithIgnore = this.searches; this.searchesWithIgnore = this.searches;
else else
{ {
List<Search> s = addIgnores(this.ignore, this.searches); LinkedList<Search> s = addIgnores(this.ignore, this.searches);
if (this.firstIgnore)
s.addFirst(this.ignore.getRealSearch());
if (this.lastIgnore)
s.addLast(this.ignore.getRealSearch());
this.searchesWithIgnore = s.toArray(new Search[s.size()]); this.searchesWithIgnore = s.toArray(new Search[s.size()]);
} }
} }
public static List<Search> addIgnores(Ignore ignore, Search[] searches) public static LinkedList<Search> addIgnores(Ignore ignore, Search[] searches)
{ {
List<Search> searchesWithIgnore = new LinkedList<>(); LinkedList<Search> searchesWithIgnore = new LinkedList<>();
for (Search s : searches) for (Search s : searches)
{ {
if (s instanceof TokenSearch) if (s instanceof TokenSearch)
......
...@@ -20,6 +20,17 @@ public class TokenCreator ...@@ -20,6 +20,17 @@ public class TokenCreator
{ {
if (ss[i].getSearchName() != null) if (ss[i].getSearchName() != null)
write(build, ss[i].getSearchName(), pos, max, null); write(build, ss[i].getSearchName(), pos, max, null);
if (ss[i] instanceof ArraySearch)
{
pos.add(i);
max.add(0);
for (Search sss : ((ArraySearch)ss[i]).getSearches())
if (sss.getSearchName() != null)
write(build, sss.getSearchName(), pos, max, null);
max.removeLast();
pos.removeLast();
}
} }
} }
...@@ -60,6 +71,7 @@ public class TokenCreator ...@@ -60,6 +71,7 @@ public class TokenCreator
if (pos.isEmpty()) if (pos.isEmpty())
{ {
Field f = build.getClass().getDeclaredField(to); Field f = build.getClass().getDeclaredField(to);
f.setAccessible(true);
boolean assignable = Token.class.isAssignableFrom(f.getType()); boolean assignable = Token.class.isAssignableFrom(f.getType());
if (assignable && toWrite != null && toWrite.isToken()) if (assignable && toWrite != null && toWrite.isToken())
f.set(build, toWrite.getToken()); f.set(build, toWrite.getToken());
...@@ -72,11 +84,13 @@ public class TokenCreator ...@@ -72,11 +84,13 @@ public class TokenCreator
{ {
Object[] current, total; Object[] current, total;
Class<?> currentType = build.getClass().getDeclaredField(to).getType().getComponentType(); Class<?> currentType = build.getClass().getDeclaredField(to).getType().getComponentType();
current = total = (Object[])build.getClass().getDeclaredField(to).get(build); Field f = build.getClass().getDeclaredField(to);
f.setAccessible(true);
current = total = (Object[])f.get(build);
Iterator<Integer> maxs = max.iterator(), poss = pos.iterator(); Iterator<Integer> maxs = max.iterator(), poss = pos.iterator();
int m = maxs.next(); int m = maxs.next(), p;
if (current == null) if (current == null)
{ {
current = total = (Object[])Array.newInstance(currentType, m); current = total = (Object[])Array.newInstance(currentType, m);
...@@ -87,7 +101,7 @@ public class TokenCreator ...@@ -87,7 +101,7 @@ public class TokenCreator
for (;maxs.hasNext();) for (;maxs.hasNext();)
{ {
m = maxs.next(); m = maxs.next();
int p = poss.next(); p = poss.next();
if (current[p] == null) if (current[p] == null)
current = (Object[])(current[p] = Array.newInstance(currentType, m));