Search in sources :

Example 1 with M3M4StateListener

use of org.finos.legend.pure.m3.statelistener.M3M4StateListener in project legend-pure by finos.

the class Loader method parseM3.

public static void parseM3(String code, ModelRepository repository, ParserLibrary library, ValidationType validationType, M3M4StateListener stateListener, Context context) {
    try {
        ListMultimap<Parser, CoreInstance> newInstancesByParser = new TopParser().parse(code, "fromString.pure", repository, library, stateListener, context, null);
        ListIterable<CoreInstance> newInstances = newInstancesByParser.valuesView().toList();
        updateStateFullContextCache(newInstances, context);
        ProcessorSupport processorSupport = new M3ProcessorSupport(context, repository);
        PostProcessor.process(newInstances, repository, library, new InlineDSLLibrary(), null, context, processorSupport, null, null);
        processExcludes(repository, processorSupport, stateListener);
        if (validationType == ValidationType.DEEP) {
            repository.validate(stateListener);
        }
        // Validate M3
        stateListener.startValidation();
        Validator.validateM3(newInstances, validationType, library, new InlineDSLLibrary(), new PureCodeStorage(null), repository, context, processorSupport);
        stateListener.finishedValidation();
    } catch (PureException exception) {
        String space = "      ";
        throw new RuntimeException(exception + " in\n" + space + code.replace("\n", "\n" + space), exception);
    }
}
Also used : PureException(org.finos.legend.pure.m4.exception.PureException) ProcessorSupport(org.finos.legend.pure.m3.navigation.ProcessorSupport) M3ProcessorSupport(org.finos.legend.pure.m3.navigation.M3ProcessorSupport) TopParser(org.finos.legend.pure.m3.serialization.grammar.top.TopParser) M3ProcessorSupport(org.finos.legend.pure.m3.navigation.M3ProcessorSupport) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) InlineDSLLibrary(org.finos.legend.pure.m3.serialization.grammar.m3parser.inlinedsl.InlineDSLLibrary) PureCodeStorage(org.finos.legend.pure.m3.serialization.filesystem.PureCodeStorage) M3AntlrParser(org.finos.legend.pure.m3.serialization.grammar.m3parser.antlr.M3AntlrParser) Parser(org.finos.legend.pure.m3.serialization.grammar.Parser) TopParser(org.finos.legend.pure.m3.serialization.grammar.top.TopParser)

Example 2 with M3M4StateListener

use of org.finos.legend.pure.m3.statelistener.M3M4StateListener in project legend-pure by finos.

the class DiagramParser method parse.

@Override
public void parse(String code, String sourceName, boolean addLines, int offset, ModelRepository repository, MutableList<CoreInstance> coreInstancesResult, M3M4StateListener listener, Context context, int count, SourceState oldState) throws PureParserException {
    String result = this.parseDefinition(true, code, sourceName, addLines, offset, repository, listener, context, count);
    new M3AntlrParser(false).parse(result, sourceName, false, offset, repository, coreInstancesResult, listener, context, count, null);
}
Also used : M3AntlrParser(org.finos.legend.pure.m3.serialization.grammar.m3parser.antlr.M3AntlrParser)

Example 3 with M3M4StateListener

use of org.finos.legend.pure.m3.statelistener.M3M4StateListener in project legend-pure by finos.

the class TopParser method parseDefinition.

private MutableListMultimap<Parser, CoreInstance> parseDefinition(boolean useFastParser, String code, String sourceName, ModelRepository repository, ParserLibrary parserLibrary, M3M4StateListener listener, Context context, SourceState oldState) {
    TopAntlrParser parser = this.initAntlrParser(useFastParser, "\u005cn###Pure\u005cn" + code, sourceName);
    TopGraphBuilder visitor = new TopGraphBuilder(sourceName, repository, listener, context, parserLibrary, oldState);
    TopAntlrParser.DefinitionContext c = parser.definition();
    return visitor.visitDefinition(c);
}
Also used : TopAntlrParser(org.finos.legend.pure.m3.serialization.grammar.top.antlr.TopAntlrParser)

Example 4 with M3M4StateListener

use of org.finos.legend.pure.m3.statelistener.M3M4StateListener in project legend-pure by finos.

the class MappingParser method parse.

@Override
public void parse(String string, String sourceName, boolean addLines, int offset, ModelRepository repository, MutableList<CoreInstance> coreInstancesResult, M3M4StateListener listener, Context context, int count, SourceState oldState) throws PureParserException {
    String result = parseDefinition(true, string, sourceName, addLines, offset, repository, listener, context, count);
    new M3AntlrParser(false).parse(result, sourceName, false, offset, repository, coreInstancesResult, listener, context, count, null);
}
Also used : M3AntlrParser(org.finos.legend.pure.m3.serialization.grammar.m3parser.antlr.M3AntlrParser)

Example 5 with M3M4StateListener

use of org.finos.legend.pure.m3.statelistener.M3M4StateListener in project legend-pure by finos.

the class RelationalParser method parse.

public void parse(String code, String sourceName, boolean addLines, int offset, ModelRepository repository, MutableList<CoreInstance> coreInstancesResult, M3M4StateListener listener, Context context, int count, SourceState oldState) throws PureParserException {
    String importId = AntlrContextToM3CoreInstance.createImportGroupId(sourceName, count);
    String result = parseDefinition(true, code, sourceName, addLines, offset, repository, listener, context, count, importId);
    new M3AntlrParser(false).parse(result, sourceName, false, offset, repository, coreInstancesResult, listener, context, count, null);
}
Also used : M3AntlrParser(org.finos.legend.pure.m3.serialization.grammar.m3parser.antlr.M3AntlrParser)

Aggregations

M3AntlrParser (org.finos.legend.pure.m3.serialization.grammar.m3parser.antlr.M3AntlrParser)4 M3ProcessorSupport (org.finos.legend.pure.m3.navigation.M3ProcessorSupport)1 ProcessorSupport (org.finos.legend.pure.m3.navigation.ProcessorSupport)1 PureCodeStorage (org.finos.legend.pure.m3.serialization.filesystem.PureCodeStorage)1 Parser (org.finos.legend.pure.m3.serialization.grammar.Parser)1 InlineDSLLibrary (org.finos.legend.pure.m3.serialization.grammar.m3parser.inlinedsl.InlineDSLLibrary)1 TopParser (org.finos.legend.pure.m3.serialization.grammar.top.TopParser)1 TopAntlrParser (org.finos.legend.pure.m3.serialization.grammar.top.antlr.TopAntlrParser)1 CoreInstance (org.finos.legend.pure.m4.coreinstance.CoreInstance)1 PureException (org.finos.legend.pure.m4.exception.PureException)1