Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1777: FML Parser in StructureMapUtilities and id transform #1778

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,29 @@ public Element parse(List<ValidationMessage> errors, String text) throws FHIRExc
String fid = lexer.takeDottedToken();
Element e = result.makeElement(fid).markLocation(lexer.getCurrentLocation());
lexer.token("=");
e.setValue(lexer.readConstant("meta value"));
String multiline = lexer.getCurrent();
if (fid.equals("description")) {
String descr = lexer.readConstant("description");
if ("\"\"".equals(multiline)) {
descr = lexer.readConstant("description multiline");
if (descr.startsWith("\r")) {
descr = descr.substring(1);
}
if (descr.startsWith("\n")) {
descr = descr.substring(1);
}
if (descr.endsWith("\n")) {
descr = descr.substring(0, descr.length()-1);
}
if (descr.endsWith("\r")) {
descr = descr.substring(0, descr.length()-1);
}
lexer.skipToken("\"\"");
}
e.setValue(descr);
} else {
e.setValue(lexer.readConstant("meta value"));
}
}
lexer.setMetadataFormat(false);
if (!result.hasChild("status")) {
Expand Down Expand Up @@ -434,6 +456,16 @@ private void parseRuleReference(Element rule, FHIRLexer lexer) throws FHIRLexerE
}
lexer.token(")");
}

private String removeQuotedOrBacktick(String token) {
if (token.startsWith("`") && token.endsWith("`")) {
return token.substring(1,token.length()-1);
}
if (token.startsWith("\"") && token.endsWith("\"")) {
return token.substring(1,token.length()-1);
}
return token;
}

private void parseSource(Element rule, FHIRLexer lexer) throws FHIRException {
Element source = rule.addElement("source").markLocation(lexer.getCurrentLocation());
Expand All @@ -448,7 +480,7 @@ private void parseSource(Element rule, FHIRLexer lexer) throws FHIRException {
lexer.token(")");
} else if (lexer.hasToken(".")) {
lexer.token(".");
source.makeElement("element").markLocation(lexer.getCurrentLocation()).setValue(lexer.take());
source.makeElement("element").markLocation(lexer.getCurrentLocation()).setValue(removeQuotedOrBacktick(lexer.take()));
}
if (lexer.hasToken(":")) {
// type and cardinality
Expand Down Expand Up @@ -490,8 +522,8 @@ private void parseSource(Element rule, FHIRLexer lexer) throws FHIRException {
lexer.take();
SourceLocation loc = lexer.getCurrentLocation();
ExpressionNode node = fpe.parse(lexer);
source.setUserData(StructureMapUtilities.MAP_WHERE_CHECK, node);
source.makeElement("logMessage").markLocation(loc).setValue(lexer.take());
source.setUserData(StructureMapUtilities.MAP_WHERE_LOG, node);
source.makeElement("logMessage").markLocation(loc).setValue(node.toString());
}
}

Expand All @@ -503,7 +535,7 @@ private void parseTarget(Element rule, FHIRLexer lexer) throws FHIRException {
target.makeElement("context").markLocation(loc).setValue(start);
start = null;
lexer.token(".");
target.makeElement("element").markLocation(lexer.getCurrentLocation()).setValue(lexer.take());
target.makeElement("element").markLocation(lexer.getCurrentLocation()).setValue(removeQuotedOrBacktick(lexer.take()));
}
String name;
boolean isConstant = false;
Expand Down
Loading
Loading