String in tokenizer
This commit is contained in:
parent
dd2854f34b
commit
4cd54b738f
2 changed files with 20 additions and 21 deletions
|
@ -23,7 +23,6 @@ import be.jeffcheasey88.peeratcode.parser.TokenValidator;
|
||||||
import be.jeffcheasey88.peeratcode.parser.Tokenizer;
|
import be.jeffcheasey88.peeratcode.parser.Tokenizer;
|
||||||
import be.jeffcheasey88.peeratcode.parser.java.Annotation.Annotable;
|
import be.jeffcheasey88.peeratcode.parser.java.Annotation.Annotable;
|
||||||
import be.jeffcheasey88.peeratcode.parser.java.Function.FunctionContainer;
|
import be.jeffcheasey88.peeratcode.parser.java.Function.FunctionContainer;
|
||||||
import be.jeffcheasey88.peeratcode.parser.java.Value.BiValue;
|
|
||||||
import be.jeffcheasey88.peeratcode.parser.java.Variable.VariableContainer;
|
import be.jeffcheasey88.peeratcode.parser.java.Variable.VariableContainer;
|
||||||
import be.jeffcheasey88.peeratcode.parser.state.BuilderStateTree;
|
import be.jeffcheasey88.peeratcode.parser.state.BuilderStateTree;
|
||||||
import be.jeffcheasey88.peeratcode.parser.state.InitialStateTree;
|
import be.jeffcheasey88.peeratcode.parser.state.InitialStateTree;
|
||||||
|
@ -71,6 +70,24 @@ public class JavaParser extends Parser<JavaElement> {
|
||||||
i = j-1;
|
i = j-1;
|
||||||
}else if(Character.isWhitespace(c)) continue;
|
}else if(Character.isWhitespace(c)) continue;
|
||||||
else{
|
else{
|
||||||
|
if(c == '"'){
|
||||||
|
String value = "";
|
||||||
|
int j = i;
|
||||||
|
for(; j < line.length(); j++){
|
||||||
|
c = line.charAt(j);
|
||||||
|
if(c == '"'){
|
||||||
|
value+=c;
|
||||||
|
j++;
|
||||||
|
break;
|
||||||
|
}else if(c == '\\'){
|
||||||
|
value+=c+line.charAt(++j);
|
||||||
|
}else{
|
||||||
|
value+=c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
token = new Token(lineNumber, i+1, value, TokenType.STRING);
|
||||||
|
i = j-1;
|
||||||
|
}
|
||||||
if(c == '/' && (i < line.length()-1 && line.charAt(i+1) == '/')) break;
|
if(c == '/' && (i < line.length()-1 && line.charAt(i+1) == '/')) break;
|
||||||
if(c == '/' && (i < line.length()-1 && line.charAt(i+1) == '*')){
|
if(c == '/' && (i < line.length()-1 && line.charAt(i+1) == '*')){
|
||||||
longCommentary = true;
|
longCommentary = true;
|
||||||
|
@ -373,25 +390,7 @@ public class JavaParser extends Parser<JavaElement> {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}).end();
|
}).end();
|
||||||
value.then((validator) -> {
|
value.then((validator) -> validator.validate((token) -> token.getType().equals(TokenType.STRING))).end((parent,bag) -> {
|
||||||
if(validator.validate((token) -> token.getValue().equals("\""))){
|
|
||||||
while(validator.validate(
|
|
||||||
(token) -> !token.getValue().equals("\""),
|
|
||||||
(bag, token) -> {
|
|
||||||
Token current = bag.get();
|
|
||||||
if(current == null) current = token;
|
|
||||||
else current = current.concat(token);
|
|
||||||
bag.set(current);
|
|
||||||
}));
|
|
||||||
return validator.validate((token) -> token.getValue().equals("\""), (bag, token) -> {
|
|
||||||
Token current = bag.get();
|
|
||||||
if(current == null) current = token;
|
|
||||||
else current = current.concat(token);
|
|
||||||
bag.set(current);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}).end((parent,bag) -> {
|
|
||||||
bag.set(new Value(bag.<Token>get()));
|
bag.set(new Value(bag.<Token>get()));
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
|
@ -265,6 +265,6 @@ public class ValueTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void doubleInDouble() throws Exception{
|
void doubleInDouble() throws Exception{
|
||||||
JavaElement result = testCase("(jeffcheasey88 == goefra) || (yuzzu == yugs)");
|
JavaElement result = testCase("(jeffcheasey88 == goefra) || (yuzzu == yugs) || (test == \"Content-Disposition: form-data; name=\\\"?\\\"\")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue