Commit 706f0906 authored by Custom2043's avatar Custom2043
Browse files

merge

parents 38110618 009b57fe
No preview for this file type
...@@ -29,7 +29,7 @@ ignore = {Space|Jump} ...@@ -29,7 +29,7 @@ ignore = {Space|Jump}
SearchName = id:Identifier ":" SearchName = id:Identifier ":"
LineHeader = [trans:transientToken] id:Identifier equals LineHeader = [trans:transientToken] id:Identifier equals
TokenSearchToken = [not:notToken] ([trans:transientToken] id:Identifier)|string:StringToken|allToken TokenSearchToken = ([trans:transientToken] id:Identifier)|string:StringToken|any:"*"
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
......
...@@ -63,24 +63,19 @@ public class Parser ...@@ -63,24 +63,19 @@ public class Parser
* @param tokenBuilder the builder to reach or null to read all lines</br> * @param tokenBuilder the builder to reach or null to read all lines</br>
* @return the token built or null if the fonction has failed * @return the token built or null if the fonction has failed
*/ */
static Token readUntil(int line, boolean excluded)//TokenBuilder tokenBuilder) static Token readUntil(int line, boolean excluded)
{ {
//System.out.println("Searching for : "+tokenBuilder+" from index : "+index); //System.out.println("Searching for : "+tokenBuilder+" from index : "+index);
/*int line = tokenBuilder == null ? -1 : tokenBuilder.getLine();
boolean excluded = tokenBuilder == null ? false : tokenBuilder.isTransient();*/
//if (trans)
//line --;
int oldIndex = index; int oldIndex = index;
Token t; Token t;
ParserMemory memory = ParserMemory.setLastResult(index, line); ParserMemory memory = ParserMemory.setLastResult(index, line);
mark.currentToken = memory.getToken(); Token currentToken = memory.getToken();
if (memory.getToken() != null) if (memory.getToken() != null)
{ {
//System.out.println("Found : "+mark.token+" at : "+index+" while building "+builder); //System.out.println("Found : "+mark.token+" at : "+index+" while building "+builder);
index = mark.currentToken.getStart() + mark.currentToken.getLength(); index = currentToken.getStart() + currentToken.getLength();
mark(); mark();
} }
...@@ -88,18 +83,18 @@ public class Parser ...@@ -88,18 +83,18 @@ public class Parser
if (lineBuilder.getLine() > memory.getLine()) if (lineBuilder.getLine() > memory.getLine())
if (line == -1 || (lineBuilder.getLine() < line) if (line == -1 || (lineBuilder.getLine() < line)
|| !excluded && lineBuilder.getLine() == line) || !excluded && lineBuilder.getLine() == line)
if ((t = buildToken(lineBuilder, mark.currentToken)) != null) if ((t = buildToken(lineBuilder, currentToken)) != null)
{ {
mark.currentToken = t; currentToken = t;
ParserMemory.addResult(mark.currentToken.getStart(), new ParserMemory(mark.currentToken, lineBuilder.getLine())); ParserMemory.addResult(currentToken.getStart(), new ParserMemory(currentToken, lineBuilder.getLine()));
} }
else if (lineBuilder.getLine() == line && !excluded) else if (lineBuilder.getLine() == line && !excluded)
{ {
index = oldIndex; index = oldIndex;
return null; //return null;
} }
return mark.currentToken; return currentToken;
} }
/** /**
...@@ -252,7 +247,6 @@ public class Parser ...@@ -252,7 +247,6 @@ public class Parser
private static class Mark private static class Mark
{ {
private int markIndex = index; private int markIndex = index;
private Token currentToken = null;
private LinkedList<Integer> submarks = new LinkedList<>(); private LinkedList<Integer> submarks = new LinkedList<>();
} }
......
...@@ -28,6 +28,9 @@ public class TokenSearch extends Search ...@@ -28,6 +28,9 @@ public class TokenSearch extends Search
*/ */
public Result isTokenCorrect(Token token) public Result isTokenCorrect(Token token)
{ {
if (this.builder == null)
return new Result(this, token);
if (this.builder instanceof ParserStringBuilder) if (this.builder instanceof ParserStringBuilder)
{ {
if (token == null) if (token == null)
...@@ -52,7 +55,7 @@ public class TokenSearch extends Search ...@@ -52,7 +55,7 @@ public class TokenSearch extends Search
Result temp; Result temp;
if (!hasCurrent) if (!hasCurrent)
{ {
if (this.fromThisLine) if (this.fromThisLine || this.builder == null)
current = Parser.readUntil(this.getDeclarationBuilder().getLine(), true); current = Parser.readUntil(this.getDeclarationBuilder().getLine(), true);
else else
current = Parser.readUntil(this.builder.getLine(), this.builder.isTransient()); current = Parser.readUntil(this.builder.getLine(), this.builder.isTransient());
......
...@@ -28,7 +28,7 @@ ignore = {Space|Jump} ...@@ -28,7 +28,7 @@ ignore = {Space|Jump}
SearchName = id:Identifier ":" SearchName = id:Identifier ":"
LineHeader = [trans:transientToken] id:Identifier equals LineHeader = [trans:transientToken] id:Identifier equals
TokenSearchToken = ([trans:transientToken] id:Identifier)|string:StringToken TokenSearchToken = ([trans:transientToken] id:Identifier)|string:StringToken|any:"*"
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
...@@ -38,4 +38,4 @@ OrSearchToken = 2-{searches:#SearchToken orToken|} ...@@ -38,4 +38,4 @@ OrSearchToken = 2-{searches:#SearchToken orToken|}
Line = header:LineHeader {searchTokens:SearchToken} Line = header:LineHeader {searchTokens:SearchToken}
anyChar = '*' anyChar = '*'
\ No newline at end of file
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