public boolean hasToken(String... names) { if (done()) return false; for (String s : names) if (s.equals(current)) return true; return false; }
public boolean hasToken(String kw) { return !done() && kw.equals(current); } public boolean hasToken(String... names) {
public boolean hasComment() { return !done() && current.startsWith("//"); } public boolean hasToken(String kw) {
public String takeDottedToken() throws FHIRLexerException { StringBuilder b = new StringBuilder(); b.append(take()); while (!done() && getCurrent().equals(".")) { b.append(take()); b.append(take()); } return b.toString(); }
void skipComments() throws FHIRLexerException { while (!done() && hasComment()) next(); } public int getCurrentStart() {
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; }
/** * 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); }
public StructureMap parse(String text, String srcName) throws FHIRException { FHIRLexer lexer = new FHIRLexer(text, srcName); if (lexer.done()) throw lexer.error("Map Input cannot be empty"); lexer.skipComments(); lexer.token("map"); StructureMap result = new StructureMap(); result.setUrl(lexer.readConstant("url")); lexer.token("="); result.setName(lexer.readConstant("name")); lexer.skipComments(); while (lexer.hasToken("conceptmap")) parseConceptMap(result, lexer); while (lexer.hasToken("uses")) parseUses(result, lexer); while (lexer.hasToken("imports")) parseImports(result, lexer); while (!lexer.done()) { parseGroup(result, lexer); } return result; }
public boolean hasToken(String... names) { if (done()) return false; for (String s : names) if (s.equals(current)) return true; return false; }
public boolean hasComment() { return !done() && current.startsWith("//"); } public boolean hasToken(String kw) {
public boolean hasToken(String kw) { return !done() && kw.equals(current); } public boolean hasToken(String... names) {
result.setConstant(processConstant(lexer)); result.setKind(Kind.Constant); if (!isString && !lexer.done() && (result.getConstant() instanceof IntegerType || result.getConstant() instanceof DecimalType) && (lexer.isStringConstant() || lexer.hasToken("year", "years", "month", "months", "week", "weeks", "day", "days", "hour", "hours", "minute", "minutes", "second", "seconds", "millisecond", "milliseconds"))) {
public String takeDottedToken() throws FHIRLexerException { StringBuilder b = new StringBuilder(); b.append(take()); while (!done() && getCurrent().equals(".")) { b.append(take()); b.append(take()); } return b.toString(); }
if (lexer.done()) throw lexer.error("premature termination expecting '}' in nested group"); parseRule(map, rule.getRule(), lexer, newFmt);
void skipComments() throws FHIRLexerException { while (!done() && hasComment()) next(); } public int getCurrentStart() {
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; }
if (newFmt) { while (!lexer.hasToken("}")) { if (lexer.done()) throw lexer.error("premature termination expecting 'endgroup'"); parseRule(result, group.getRule(), lexer, true); parseInput(group, lexer, false); while (!lexer.hasToken("endgroup")) { if (lexer.done()) throw lexer.error("premature termination expecting 'endgroup'"); parseRule(result, group.getRule(), lexer, false);
/** * 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); }
public StructureMap parse(String text, String srcName) throws FHIRException { FHIRLexer lexer = new FHIRLexer(text, srcName); if (lexer.done()) throw lexer.error("Map Input cannot be empty"); lexer.skipComments(); lexer.token("map"); StructureMap result = new StructureMap(); result.setUrl(lexer.readConstant("url")); lexer.token("="); result.setName(lexer.readConstant("name")); lexer.skipComments(); while (lexer.hasToken("conceptmap")) parseConceptMap(result, lexer); while (lexer.hasToken("uses")) parseUses(result, lexer); while (lexer.hasToken("imports")) parseImports(result, lexer); while (!lexer.done()) { parseGroup(result, lexer); } return result; }
if (newFmt) { while (!lexer.hasToken("}")) { if (lexer.done()) throw lexer.error("premature termination expecting 'endgroup'"); parseRule(result, group.getRule(), lexer, true); parseInput(group, lexer, false); while (!lexer.hasToken("endgroup")) { if (lexer.done()) throw lexer.error("premature termination expecting 'endgroup'"); parseRule(result, group.getRule(), lexer, false);