use of org.hl7.fhir.r4b.utils.FHIRLexer.FHIRLexerException in project org.hl7.fhir.core by hapifhir.
the class FHIRPathEngine method parsePartial.
/**
* Parse a path for later use using execute
*
* @param path
* @return
* @throws PathEngineException
* @throws Exception
*/
public ExpressionNodeWithOffset parsePartial(String path, int i) throws FHIRLexerException {
FHIRLexer lexer = new FHIRLexer(path, i);
if (lexer.done()) {
throw lexer.error("Path cannot be empty");
}
ExpressionNode result = parseExpression(lexer, true);
result.check();
return new ExpressionNodeWithOffset(lexer.getCurrentStart(), result);
}
use of org.hl7.fhir.r4b.utils.FHIRLexer.FHIRLexerException in project org.hl7.fhir.core by hapifhir.
the class FHIRPathEngine method parse.
public ExpressionNode parse(String path, String name) throws FHIRLexerException {
FHIRLexer lexer = new FHIRLexer(path, name);
if (lexer.done()) {
throw lexer.error("Path cannot be empty");
}
ExpressionNode result = parseExpression(lexer, true);
if (!lexer.done()) {
throw lexer.error("Premature ExpressionNode termination at unexpected token \"" + lexer.getCurrent() + "\"");
}
result.check();
return result;
}
use of org.hl7.fhir.r4b.utils.FHIRLexer.FHIRLexerException in project org.hl7.fhir.core by hapifhir.
the class FHIRPathEngine method parse.
/**
* Parse a path that is part of some other syntax
*
* @return
* @throws PathEngineException
* @throws Exception
*/
public ExpressionNode parse(FHIRLexer lexer) throws FHIRLexerException {
ExpressionNode result = parseExpression(lexer, true);
result.check();
return result;
}
use of org.hl7.fhir.r4b.utils.FHIRLexer.FHIRLexerException in project org.hl7.fhir.core by hapifhir.
the class FHIRLexer method processConstant.
public String processConstant(String s) throws FHIRLexerException {
StringBuilder b = new StringBuilder();
int i = 1;
while (i < s.length() - 1) {
char ch = s.charAt(i);
if (ch == '\\') {
i++;
switch(s.charAt(i)) {
case 't':
b.append('\t');
break;
case 'r':
b.append('\r');
break;
case 'n':
b.append('\n');
break;
case 'f':
b.append('\f');
break;
case '\'':
b.append('\'');
break;
case '"':
b.append('"');
break;
case '`':
b.append('`');
break;
case '\\':
b.append('\\');
break;
case '/':
b.append('/');
break;
case 'u':
i++;
int uc = Integer.parseInt(s.substring(i, i + 4), 16);
b.append((char) uc);
i = i + 4;
break;
default:
throw new FHIRLexerException("Unknown character escape \\" + s.charAt(i));
}
} else {
b.append(ch);
i++;
}
}
return b.toString();
}
use of org.hl7.fhir.r4b.utils.FHIRLexer.FHIRLexerException in project org.hl7.fhir.core by hapifhir.
the class FHIRLexer method processFixedName.
public String processFixedName(String s) throws FHIRLexerException {
StringBuilder b = new StringBuilder();
int i = 1;
while (i < s.length() - 1) {
char ch = s.charAt(i);
if (ch == '\\') {
i++;
switch(s.charAt(i)) {
case 't':
b.append('\t');
break;
case 'r':
b.append('\r');
break;
case 'n':
b.append('\n');
break;
case 'f':
b.append('\f');
break;
case '\'':
b.append('\'');
break;
case '"':
b.append('"');
break;
case '\\':
b.append('\\');
break;
case '/':
b.append('/');
break;
case 'u':
i++;
int uc = Integer.parseInt(s.substring(i, i + 4), 16);
b.append((char) uc);
i = i + 4;
break;
default:
throw new FHIRLexerException("Unknown character escape \\" + s.charAt(i));
}
} else {
b.append(ch);
i++;
}
}
return b.toString();
}
Aggregations