Search in sources :

Example 66 with FHIRLexer

use of org.hl7.fhir.r4b.utils.FHIRLexer in project org.hl7.fhir.core by hapifhir.

the class StructureMapUtilities method parseRule.

private void parseRule(List<StructureMapGroupRuleComponent> list, FHIRLexer lexer) throws FHIRException {
    StructureMapGroupRuleComponent rule = new StructureMapGroupRuleComponent();
    list.add(rule);
    rule.setName(lexer.takeDottedToken());
    lexer.token(":");
    lexer.token("for");
    boolean done = false;
    while (!done) {
        parseSource(rule, lexer);
        done = !lexer.hasToken(",");
        if (!done)
            lexer.next();
    }
    if (lexer.hasToken("make")) {
        lexer.token("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()) {
                rule.setDocumentation(lexer.take().substring(2).trim());
            }
            lexer.skipComments();
            while (!lexer.hasToken("}")) {
                if (lexer.done())
                    throw lexer.error("premature termination expecting '}' in nested group");
                parseRule(rule.getRule(), lexer);
            }
            lexer.token("}");
        } else {
            done = false;
            while (!done) {
                parseRuleReference(rule, lexer);
                done = !lexer.hasToken(",");
                if (!done)
                    lexer.next();
            }
        }
    } else if (lexer.hasComment()) {
        rule.setDocumentation(lexer.take().substring(2).trim());
    }
    lexer.skipComments();
}
Also used : StructureMapGroupRuleComponent(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleComponent)

Aggregations

ExpressionNode (org.hl7.fhir.r4.model.ExpressionNode)8 ExpressionNode (org.hl7.fhir.dstu2016may.model.ExpressionNode)7 ExpressionNode (org.hl7.fhir.dstu3.model.ExpressionNode)7 ExpressionNode (org.hl7.fhir.r4b.model.ExpressionNode)6 ExpressionNode (org.hl7.fhir.r5.model.ExpressionNode)6 ExpressionNode (org.hl7.fhir.dstu2.model.ExpressionNode)5 BigDecimal (java.math.BigDecimal)3 HashMap (java.util.HashMap)3 SourceLocation (org.hl7.fhir.utilities.SourceLocation)3 StringType (org.hl7.fhir.dstu3.model.StringType)2 StringType (org.hl7.fhir.r4.model.StringType)2 Function (org.hl7.fhir.dstu2.model.ExpressionNode.Function)1 SourceLocation (org.hl7.fhir.dstu2.model.ExpressionNode.SourceLocation)1 FunctionDetails (org.hl7.fhir.dstu2.utils.FHIRPathEngine.IEvaluationContext.FunctionDetails)1 ConceptMap (org.hl7.fhir.dstu2016may.model.ConceptMap)1 SourceElementComponent (org.hl7.fhir.dstu2016may.model.ConceptMap.SourceElementComponent)1 TargetElementComponent (org.hl7.fhir.dstu2016may.model.ConceptMap.TargetElementComponent)1 Function (org.hl7.fhir.dstu2016may.model.ExpressionNode.Function)1 SourceLocation (org.hl7.fhir.dstu2016may.model.ExpressionNode.SourceLocation)1 IdType (org.hl7.fhir.dstu2016may.model.IdType)1