private void parseRuleReference(StructureMapGroupRuleComponent rule, FHIRLexer lexer) throws FHIRLexerException { StructureMapGroupRuleDependentComponent ref = rule.addDependent(); ref.setName(lexer.take()); lexer.token("("); boolean done = false; while (!done) { ref.addVariable(lexer.take()); done = !lexer.hasToken(","); if (!done) lexer.next(); } lexer.token(")"); }
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; }
StructureMapGroupComponent group = result.addGroup(); boolean newFmt = false; if (lexer.hasToken("for")) { lexer.token("for"); if ("type".equals(lexer.getCurrent())) { group.setTypeMode(StructureMapGroupTypeMode.NONE); group.setName(lexer.take()); if (lexer.hasToken("(")) { newFmt = true; lexer.take(); while (!lexer.hasToken(")")) { parseInput(group, lexer, true); if (lexer.hasToken(",")) lexer.token(","); if (lexer.hasToken("extends")) { lexer.next(); group.setExtends(lexer.take()); if (lexer.hasToken("<")) { lexer.token("<"); lexer.token("<"); if (lexer.hasToken("types")) { group.setTypeMode(StructureMapGroupTypeMode.TYPES); lexer.token("types"); while (!lexer.hasToken("}")) { if (lexer.done())
private void parseSource(StructureMapGroupRuleComponent rule, FHIRLexer lexer) throws FHIRException { StructureMapGroupRuleSourceComponent source = rule.addSource(); source.setContext(lexer.take()); if (source.getContext().equals("search") && lexer.hasToken("(")) { source.setContext("@search"); lexer.take(); source.setElement(node.toString()); lexer.token(")"); } else if (lexer.hasToken(".")) { lexer.token("."); source.setElement(lexer.take()); if (lexer.hasToken(":")) { if (!lexer.hasToken("as", "first", "last", "not_first", "not_last", "only_one", "default")) { source.setMin(lexer.takeInt()); lexer.token(".."); if (lexer.hasToken("default")) { lexer.token("default"); source.setDefaultValue(new StringType(lexer.readConstant("default value"))); if (lexer.hasToken("as")) { lexer.take(); source.setVariable(lexer.take()); if (lexer.hasToken("where")) { lexer.take(); ExpressionNode node = fpe.parse(lexer);
while (!done) { parseSource(rule, lexer); done = !lexer.hasToken(","); if (!done) lexer.next(); if ((newFmt && lexer.hasToken("->")) || (!newFmt && lexer.hasToken("make"))) { lexer.token(newFmt ? "->" : "make"); done = false; while (!done) { parseTarget(rule, lexer); done = !lexer.hasToken(","); if (!done) lexer.next(); if (lexer.hasToken("then")) { lexer.token("then"); if (lexer.hasToken("{")) { lexer.token("{"); if (lexer.hasComment()) { while (!lexer.hasToken("}")) { if (lexer.done()) throw lexer.error("premature termination expecting '}' in nested group"); while (!done) { parseRuleReference(rule, lexer); done = !lexer.hasToken(","); if (!done)
private void parseUses(StructureMap result, FHIRLexer lexer) throws FHIRException { lexer.token("uses"); StructureMapStructureComponent st = result.addStructure(); st.setUrl(lexer.readConstant("url")); if (lexer.hasToken("alias")) { lexer.token("alias"); st.setAlias(lexer.take()); } lexer.token("as"); st.setMode(StructureMapModelMode.fromCode(lexer.take())); lexer.skipToken(";"); if (lexer.hasComment()) { st.setDocumentation(lexer.take().substring(2).trim()); } lexer.skipComments(); }
while (lexer.hasToken("prefix")) { lexer.token("prefix"); String n = lexer.take(); prefixes.put(n, v); while (lexer.hasToken("unmapped")) { lexer.token("unmapped"); lexer.token("for"); throw lexer.error("Only unmapped mode PROVIDED is supported at this time"); while (!lexer.hasToken("}")) { String srcs = readPrefix(prefixes, lexer); lexer.token(":");
private void parseInput(StructureMapGroupComponent group, FHIRLexer lexer, boolean newFmt) throws FHIRException { StructureMapGroupInputComponent input = group.addInput(); if (newFmt) { input.setMode(StructureMapInputMode.fromCode(lexer.take())); } else lexer.token("input"); input.setName(lexer.take()); if (lexer.hasToken(":")) { lexer.token(":"); input.setType(lexer.take()); } if (!newFmt) { lexer.token("as"); input.setMode(StructureMapInputMode.fromCode(lexer.take())); if (lexer.hasComment()) { input.setDocumentation(lexer.take().substring(2).trim()); } lexer.skipToken(";"); lexer.skipComments(); } }
private void parseTarget(StructureMapGroupRuleComponent rule, FHIRLexer lexer) throws FHIRException { StructureMapGroupRuleTargetComponent target = rule.addTarget(); String start = lexer.take(); if (lexer.hasToken(".")) { target.setContext(start); target.setContextType(StructureMapContextType.VARIABLE); if (lexer.hasToken("=")) { if (start != null) target.setContext(start); target.addParameter().setValue(new StringType(node.toString())); lexer.token(")"); } else if (lexer.hasToken("(")) { target.setTransform(StructureMapTransform.fromCode(name)); lexer.token("("); target.addParameter().setValue(new StringType(node.toString())); } else { while (!lexer.hasToken(")")) { parseParameter(target, lexer); if (!lexer.hasToken(")")) lexer.token(","); if (!isConstant) { String id = name; while (lexer.hasToken(".")) { id = id + lexer.take() + lexer.take(); if (lexer.hasToken("as")) {
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"))) { if (lexer.hasToken("year", "years", "month", "months", "week", "weeks", "day", "days", "hour", "hours", "minute", "minutes", "second", "seconds", "millisecond", "milliseconds")) { String s = lexer.take(); if (s.equals("year") || s.equals("years"))
StructureMapGroupComponent group = result.addGroup(); boolean newFmt = false; if (lexer.hasToken("for")) { lexer.token("for"); if ("type".equals(lexer.getCurrent())) { group.setTypeMode(StructureMapGroupTypeMode.NONE); group.setName(lexer.take()); if (lexer.hasToken("(")) { newFmt = true; lexer.take(); while (!lexer.hasToken(")")) { parseInput(group, lexer, true); if (lexer.hasToken(",")) lexer.token(","); if (lexer.hasToken("extends")) { lexer.next(); group.setExtends(lexer.take()); if (lexer.hasToken("<")) { lexer.token("<"); lexer.token("<"); if (lexer.hasToken("types")) { group.setTypeMode(StructureMapGroupTypeMode.TYPES); lexer.token("types"); while (!lexer.hasToken("}")) { if (lexer.done())
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; }
private void parseRuleReference(StructureMapGroupRuleComponent rule, FHIRLexer lexer) throws FHIRLexerException { StructureMapGroupRuleDependentComponent ref = rule.addDependent(); ref.setName(lexer.take()); lexer.token("("); boolean done = false; while (!done) { ref.addVariable(lexer.take()); done = !lexer.hasToken(","); if (!done) lexer.next(); } lexer.token(")"); }
private void parseUses(StructureMap result, FHIRLexer lexer) throws FHIRException { lexer.token("uses"); StructureMapStructureComponent st = result.addStructure(); st.setUrl(lexer.readConstant("url")); if (lexer.hasToken("alias")) { lexer.token("alias"); st.setAlias(lexer.take()); } lexer.token("as"); st.setMode(StructureMapModelMode.fromCode(lexer.take())); lexer.skipToken(";"); if (lexer.hasComment()) { st.setDocumentation(lexer.take().substring(2).trim()); } lexer.skipComments(); }
private void parseSource(StructureMapGroupRuleComponent rule, FHIRLexer lexer) throws FHIRException { StructureMapGroupRuleSourceComponent source = rule.addSource(); source.setContext(lexer.take()); if (source.getContext().equals("search") && lexer.hasToken("(")) { source.setContext("@search"); lexer.take(); source.setElement(node.toString()); lexer.token(")"); } else if (lexer.hasToken(".")) { lexer.token("."); source.setElement(lexer.take()); if (lexer.hasToken(":")) { if (!lexer.hasToken("as", "first", "last", "not_first", "not_last", "only_one", "default")) { source.setMin(lexer.takeInt()); lexer.token(".."); if (lexer.hasToken("default")) { lexer.token("default"); source.setDefaultValue(new StringType(lexer.readConstant("default value"))); if (lexer.hasToken("as")) { lexer.take(); source.setVariable(lexer.take()); if (lexer.hasToken("where")) { lexer.take(); ExpressionNode node = fpe.parse(lexer);
while (!done) { parseSource(rule, lexer); done = !lexer.hasToken(","); if (!done) lexer.next(); if ((newFmt && lexer.hasToken("->")) || (!newFmt && lexer.hasToken("make"))) { lexer.token(newFmt ? "->" : "make"); done = false; while (!done) { parseTarget(rule, lexer); done = !lexer.hasToken(","); if (!done) lexer.next(); if (lexer.hasToken("then")) { lexer.token("then"); if (lexer.hasToken("{")) { lexer.token("{"); if (lexer.hasComment()) { while (!lexer.hasToken("}")) { if (lexer.done()) throw lexer.error("premature termination expecting '}' in nested group"); while (!done) { parseRuleReference(rule, lexer); done = !lexer.hasToken(","); if (!done)
private void parseInput(StructureMapGroupComponent group, FHIRLexer lexer, boolean newFmt) throws FHIRException { StructureMapGroupInputComponent input = group.addInput(); if (newFmt) { input.setMode(StructureMapInputMode.fromCode(lexer.take())); } else lexer.token("input"); input.setName(lexer.take()); if (lexer.hasToken(":")) { lexer.token(":"); input.setType(lexer.take()); } if (!newFmt) { lexer.token("as"); input.setMode(StructureMapInputMode.fromCode(lexer.take())); if (lexer.hasComment()) { input.setDocumentation(lexer.take().substring(2).trim()); } lexer.skipToken(";"); lexer.skipComments(); } }
while (lexer.hasToken("prefix")) { lexer.token("prefix"); String n = lexer.take(); prefixes.put(n, v); while (lexer.hasToken("unmapped")) { lexer.token("unmapped"); lexer.token("for"); throw lexer.error("Only unmapped mode PROVIDED is supported at this time"); while (!lexer.hasToken("}")) { String srcs = readPrefix(prefixes, lexer); lexer.token(":");
private void parseTarget(StructureMapGroupRuleComponent rule, FHIRLexer lexer) throws FHIRException { StructureMapGroupRuleTargetComponent target = rule.addTarget(); String start = lexer.take(); if (lexer.hasToken(".")) { target.setContext(start); target.setContextType(StructureMapContextType.VARIABLE); if (lexer.hasToken("=")) { if (start != null) target.setContext(start); target.addParameter().setValue(new StringType(node.toString())); lexer.token(")"); } else if (lexer.hasToken("(")) { target.setTransform(StructureMapTransform.fromCode(name)); lexer.token("("); target.addParameter().setValue(new StringType(node.toString())); } else { while (!lexer.hasToken(")")) { parseParameter(target, lexer); if (!lexer.hasToken(")")) lexer.token(","); if (!isConstant) { String id = name; while (lexer.hasToken(".")) { id = id + lexer.take() + lexer.take(); if (lexer.hasToken("as")) {
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"))) { if (lexer.hasToken("year", "years", "month", "months", "week", "weeks", "day", "days", "hour", "hours", "minute", "minutes", "second", "seconds", "millisecond", "milliseconds")) { String s = lexer.take(); if (s.equals("year") || s.equals("years"))