Select Git revision
RagConnect.parser

René Schöne authored
- mappings bug fixed: boxed types handled correctly now - mappings bug fixed: type of last transformation correctly used now - add junit report to ci
RagConnect.parser 3.18 KiB
RagConnect ragconnect
= endpoint_definition.d ragconnect.r {: r.getEndpointDefinitionList().insertChild(d, 0); return r; :}
| dependency_definition.d ragconnect.r {: r.getDependencyDefinitionList().insertChild(d, 0); return r; :}
| mapping_definition.d ragconnect.r {: r.getMappingDefinitionList().insertChild(d, 0); return r; :}
| comment ragconnect.r {: return r; :}
| {: return new RagConnect(); :}
;
%embed {:
private Iterable<String> makeMappingDefs(ArrayList<?> raw_mapping_defs) {
return () -> raw_mapping_defs.stream().map(raw -> ((Symbol) raw).value.toString()).iterator();
}
private TokenEndpointDefinition enableAlwaysApply(TokenEndpointDefinition def) {
def.setAlwaysApply(true);
return def;
}
:} ;
EndpointDefinition endpoint_definition
= endpoint_definition_type.endpointDef SCOL
{:
return endpointDef;
:}
| endpoint_definition_type.endpointDef USING string_list.mapping_defs SCOL
{:
for (String mapping_def : makeMappingDefs(mapping_defs)) {
endpointDef.addMapping(MappingDefinition.createRef(mapping_def));
}
return endpointDef;
:}
;
EndpointDefinition endpoint_definition_type
= RECEIVE token_ref {: return new ReceiveTokenEndpointDefinition().setToken(token_ref); :}
| SEND token_ref {: return new SendTokenEndpointDefinition().setToken(token_ref); :}
| RECEIVE TREE type_ref {: return new ReceiveTypeEndpointDefinition().setType(type_ref); :}
| SEND TREE type_ref {: return new SendTypeEndpointDefinition().setType(type_ref); :}
;
TokenComponent token_ref
= ID.type_name DOT ID.token_name {: return TokenComponent.createRef(type_name + "." + token_name); :}
;
TypeComponent type_ref
= ID.parent_type_name DOT ID.child_type_name {: return TypeComponent.createRef(parent_type_name + "." + child_type_name); :}
;
ArrayList string_list
= ID
| string_list COMMA ID
;
DependencyDefinition dependency_definition
= ID.target_type DOT ID.target_token CAN_DEPEND_ON ID.source_type DOT ID.source_token AS ID.id SCOL
{:
DependencyDefinition result = new DependencyDefinition();
result.setSource(TokenComponent.createRef(source_type + "." + source_token));
result.setTarget(TokenComponent.createRef(target_type + "." + target_token));
result.setID(id);
return result;
:}
;
MappingDefinition mapping_definition
= ID.id MAPS mapping_type.from_type ID.from_name TO mapping_type.to_type MAPPING_CONTENT.content
{:
MappingDefinition result = new MappingDefinition();
result.setID(id);
result.setFromType(from_type);
result.setFromVariableName(from_name);
result.setToType(to_type);
result.setContent(content.substring(2, content.length() - 2));
return result;
:}
;
MappingDefinitionType mapping_type
= java_type_use.type
{:
JavaMappingDefinitionType result = new JavaMappingDefinitionType();
result.setType(type);
return result;
:}
| java_type_use.type LBRACKET RBRACKET
{:
JavaArrayMappingDefinitionType result = new JavaArrayMappingDefinitionType();
result.setType(type);
return result;
:}
;