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.java.Annotation.Annotable;
|
||||
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.state.BuilderStateTree;
|
||||
import be.jeffcheasey88.peeratcode.parser.state.InitialStateTree;
|
||||
|
@ -71,6 +70,24 @@ public class JavaParser extends Parser<JavaElement> {
|
|||
i = j-1;
|
||||
}else if(Character.isWhitespace(c)) continue;
|
||||
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) == '*')){
|
||||
longCommentary = true;
|
||||
|
@ -373,25 +390,7 @@ public class JavaParser extends Parser<JavaElement> {
|
|||
}
|
||||
return false;
|
||||
}).end();
|
||||
value.then((validator) -> {
|
||||
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) -> {
|
||||
value.then((validator) -> validator.validate((token) -> token.getType().equals(TokenType.STRING))).end((parent,bag) -> {
|
||||
bag.set(new Value(bag.<Token>get()));
|
||||
return null;
|
||||
});
|
||||
|
|
|
@ -265,6 +265,6 @@ public class ValueTests {
|
|||
|
||||
@Test
|
||||
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