Commit a5a36fb0 authored by Custom2043's avatar Custom2043
Browse files

add doc and compilation error for size limited array

parent a8cb8d15
......@@ -79,7 +79,9 @@ An ArraySearch is a MultipleSearch and allows to search for an unknown number of
Identifier = {Search1}
This line means that an Identifier is composed of an unknown number of Identifier2.
This line means that an Identifier is composed of an unknown number of Search1.
#### Left and right searches
An ArraySearch can also be composed of a left and and right search.
......@@ -115,6 +117,15 @@ The left and right parts are equivalent, since
all describe the same ItemList.
#### Size limited arrays
An array can be limited in size by using
minimumSize-{ ... }-maximumSize
The sizes are to be integers between 1 and 2147483647. The range is inclusive, and the maximum size must be
greater or equal than the minimum size.
## Strings
A string is a TokenSearch, as seen before :
......
......@@ -7,7 +7,12 @@ import java.util.List;
import parser.ParserString;
import parser.Token;
import tokens.*;
import tokens.ArraySearchToken;
import tokens.Line;
import tokens.MultipleSearchToken;
import tokens.OrSearchToken;
import tokens.SearchToken;
import tokens.TokenSearchToken;
public class Compiler
{
......@@ -171,7 +176,7 @@ public class Compiler
if (!found)
report(new Info(InfoModel.tokenUndeclared, token));
else if (first && foundAfterThisLine)
if ((currentLine.header.trans != null) == tokenTransient)
if ((currentLine.header.trans != null) || !tokenTransient)
report(new Info(InfoModel.firstTokenUndeclared, token));
if (!tokenTransient && tokenSearch.trans != null)
......@@ -179,6 +184,24 @@ public class Compiler
}
}
if (token instanceof ArraySearchToken)
{
ArraySearchToken ats = (ArraySearchToken)token;
int min, max;
if (ats.minSize != null)
min = Integer.valueOf(Token.getStringFromTokens(ats.minSize));
else
min = 1;
if (ats.maxSize != null)
max = Integer.valueOf(Token.getStringFromTokens(ats.maxSize));
else
max = Integer.MAX_VALUE;
if (min <= 0 || min > max)
report(new Info(InfoModel.incorrectRange, token));
}
if (token instanceof MultipleSearchToken)
{
if (SearchToken.canBeOptionnal(((MultipleSearchToken)token).getTypes()))
......
......@@ -34,6 +34,7 @@ enum InfoModel
tokenUndeclared(Etat.ERROR, "This token doesn't exist"),
illegalIdentifier(Etat.ERROR, "This name is not allowed"),
invalidTransSearch(Etat.ERROR, "'#' can only be used with a transient token"),
incorrectRange(Etat.ERROR, "Min and max size must be positive integers (min <= max)")
;
public final Etat etat;
......
Supports Markdown
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