Commit a36581b2 authored by Milhomme Allan's avatar Milhomme Allan
Browse files

Add list search names

parent fd06002d
File added
T = "a" T = {"a" [#b:"b"]}
\ No newline at end of file
...@@ -249,7 +249,7 @@ public class ClassGenerator ...@@ -249,7 +249,7 @@ public class ClassGenerator
builder.append("\""); builder.append("\"");
builder.append(name.id.getName()); builder.append(name.id.getName());
builder.append("\", "); builder.append("\", ");
builder.append(name.list); builder.append(name.list != null);
builder.append(", "); builder.append(", ");
} }
} }
......
...@@ -150,6 +150,14 @@ public class Compiler ...@@ -150,6 +150,14 @@ public class Compiler
pathForThisName.add(level, new SearchPath(currentPath, token)); pathForThisName.add(level, new SearchPath(currentPath, token));
} }
if (type.searchName.list != null)
{
if (level == 0)
report(new Info(InfoModel.listIsntInArraySearch, type.searchName.id));
if (!(token instanceof TokenSearchToken))
report(new Info(InfoModel.listIsntATokenSearch, type.searchName.id));
}
} }
if (type.searchName != null && type.searchName != null) if (type.searchName != null && type.searchName != null)
...@@ -210,8 +218,10 @@ public class Compiler ...@@ -210,8 +218,10 @@ public class Compiler
report(new Info(InfoModel.emptyArray, token)); report(new Info(InfoModel.emptyArray, token));
boolean b = first; boolean b = first;
if (token instanceof ArraySearchToken) if (token instanceof ArraySearchToken)
level ++; level ++;
int i = 0; int i = 0;
for (SearchToken tt : ((MultipleSearchToken)token).getTypes()) for (SearchToken tt : ((MultipleSearchToken)token).getTypes())
{ {
......
...@@ -35,7 +35,9 @@ enum InfoModel ...@@ -35,7 +35,9 @@ enum InfoModel
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") nonExistentIgnore(Etat.ERROR, "Can't use ignore because it has not been defined"),
listIsntInArraySearch(Etat.ERROR, "A list cannot be used outside of an array search"),
listIsntATokenSearch(Etat.ERROR, "A list can only be used on a token search")
; ;
public final Etat etat; public final Etat etat;
......
...@@ -10,8 +10,12 @@ public class SearchName extends Token ...@@ -10,8 +10,12 @@ public class SearchName extends Token
public Result searchResults[]; public Result searchResults[];
public Identifier id; public Identifier id;
public ParserString list;
public ParserString notGenerated; public ParserString notGenerated;
public static final Search builderSearches[] = { public static final Search builderSearches[] = {
new OptionalSearch(
new TokenSearch("list", false, ParserString.transientToken)
),
new OptionalSearch( new OptionalSearch(
new TokenSearch("notGenerated", false, ParserString.nonGeneratedName) new TokenSearch("notGenerated", false, ParserString.nonGeneratedName)
), ),
...@@ -20,6 +24,4 @@ public class SearchName extends Token ...@@ -20,6 +24,4 @@ public class SearchName extends Token
}; };
/********** Do not modify or remove **********/ /********** Do not modify or remove **********/
public boolean list = false;
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment