Commit e136473e authored by Custom2043's avatar Custom2043
Browse files

Ignore are now only inner

parent afd136e9
No preview for this file type
......@@ -55,6 +55,9 @@ public class Compiler
for (Token t : tokens)
{
if (t instanceof Space || t instanceof Jump)
continue;
if (t instanceof ParserString && ((ParserString)t).index == ParserString.anyChar.getIndex())
report(new Info(InfoModel.invalidChar, t));
else if (t instanceof Line)
......@@ -76,7 +79,7 @@ public class Compiler
lines.add((Line)t);
}
else if (!(t instanceof Space || t instanceof Jump))
else
report(new Info(InfoModel.syntaxError, t));
enabled = t instanceof Line;
......
package parser;
import java.util.LinkedList;
import java.util.List;
/**
* An array search is composed of a left search, a core and a right search
......@@ -181,11 +182,30 @@ public class ArraySearch extends MultipleSearch
@Override
MultipleSearch addIgnore(Ignore ignore)
{
return new ArraySearch(this.getSearchName(), this.minSize, this.maxSize,
/*return new ArraySearch(this.getSearchName(), this.minSize, this.maxSize,
TokenBuilder.addIgnoresToArray(ignore, this.leftSearches),
TokenBuilder.addIgnoresToArray(ignore, this.getSearches()),
TokenBuilder.addIgnoresToArray(ignore, this.rightSearches)
);
);*/
List<Search> leftWithIgnored = TokenBuilder.addIgnores(ignore, this.leftSearches),
coreWithIgnored = TokenBuilder.addIgnores(ignore, this.getSearches()),
rightWithIgnored = TokenBuilder.addIgnores(ignore, this.rightSearches);
if (leftWithIgnored.size() > 0)
leftWithIgnored.add(0, ignore.getRealSearch());
leftWithIgnored.add(ignore.getRealSearch());
if (rightWithIgnored.size() > 0)
rightWithIgnored.add(0, ignore.getRealSearch());
return new ArraySearch(this.getSearchName(), this.minSize, this.maxSize,
leftWithIgnored.toArray(new Search[leftWithIgnored.size()]),
coreWithIgnored.toArray(new Search[coreWithIgnored.size()]),
rightWithIgnored.toArray(new Search[rightWithIgnored.size()])
);
//coreWithIgnored, coreWithIgnored.length == 0 ? new Search[0] : ignore.getRealSearch());
}
@Override
......@@ -198,5 +218,30 @@ public class ArraySearch extends MultipleSearch
for(Search s : this.getRightSearches())
s.setDeclarationBuilder(builder);
}
@Override
public final String toString(int tabs)
{
String tab = "", s;
for (int i=0;i<tabs;i++)
tab+= "\t";
s = tab + this.getClass().getSimpleName();
s += " "+this.getSearchName()+" : ";
s += "\n"+tab+"LeftSearches :";
for (Search ss : this.leftSearches)
s += "\n"+ss.toString(tabs+1);
s += "\n"+tab+"CoreSearches :";
for (Search ss : this.getSearches())
s += "\n"+ss.toString(tabs+1);
s += "\n"+tab+"RightSearches :";
for (Search ss : this.rightSearches)
s += "\n"+ss.toString(tabs+1);
return s;
}
}
......@@ -17,7 +17,7 @@ public abstract class MultipleSearch extends Search
abstract MultipleSearch addIgnore(Ignore ignore);
@Override
public final String toString(int tabs)
public String toString(int tabs)
{
String s = "";
for (int i=0;i<tabs;i++)
......
......@@ -44,14 +44,16 @@ public class TokenBuilder extends Builder
{
List<Search> searchesWithIgnore = new LinkedList<>();
for (Search s : searches)
{
if (s instanceof TokenSearch || s instanceof OrSearch)
{
searchesWithIgnore.add(s);
if (s != searches[searches.length - 1])
searchesWithIgnore.add(ignore.getRealSearch());
}
else if (s instanceof MultipleSearch)
searchesWithIgnore.add(((MultipleSearch)s).addIgnore(ignore));
if (s != searches[searches.length - 1])
searchesWithIgnore.add(ignore.getRealSearch());
}
return searchesWithIgnore;
}
......
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