src/main/java/org/semgus/java/problem/ProblemGenerator.java
public SemgusProblem end() {
        if (synthFun == null) {
            throw new IllegalStateException("No synthesis function has been set!");
        }

        // construct all non-terminals beforehand so child term non-terminals can be resolved
        Map<String, SemgusNonTerminal> nonTerminals = new HashMap<>();
        for (SynthFunEvent.NonTerminal nonTerminal : synthFun.grammar().values()) {
            nonTerminals.put(nonTerminal.termType(), new SemgusNonTerminal(nonTerminal.termType(), new HashMap<>()));
        }

        // add productions to non-terminals
        for (SynthFunEvent.NonTerminal nonTerminal : synthFun.grammar().values()) {
            TermType termType = termTypes.get(nonTerminal.termType());
            Map<String, SemgusProduction> productions = nonTerminals.get(nonTerminal.termType()).productions();
            for (SynthFunEvent.Production production : nonTerminal.productions().values()) {
                TermConstructor termCtor = termType.constructors.get(production.operator());
                productions.put(production.operator(), new SemgusProduction(
                        production.operator(),
                        termCtor.childTermTypes.stream().map(nonTerminals::get).collect(Collectors.toList()),
                        termCtor.semanticRules.stream()
                                .map(r -> new SemanticRule(r.childTermVars(), r.head(), r.bodyRelations(), r.constraint()))
                                .collect(Collectors.toList())));
            }
        }

        return new SemgusProblem(
                synthFun.name(),
                nonTerminals.get(synthFun.termType()),
                nonTerminals,
                new ArrayList<>(constraints),
                new HashMap<>(metadata));
    }
/**
     * Finishes parsing, wrapping all collected data into a {@link SemgusProblem} data structure.
     *
     * @return The parsed SemGuS problem.
     */
Finishes parsing, wrapping all collected data into a  SemgusProblem data structure.
@return The parsed SemGuS problem.
Finishes parsing wrapping all collected data into a SemgusProblem data structure . @return The parsed SemGuS problem .
public SemgusProblem end() {
        if (synthFun == null) {
            throw new IllegalStateException("No synthesis function has been set!");
        }
        Map<String, SemgusNonTerminal> nonTerminals = new HashMap<>();
        for (SynthFunEvent.NonTerminal nonTerminal : synthFun.grammar().values()) {
            nonTerminals.put(nonTerminal.termType(), new SemgusNonTerminal(nonTerminal.termType(), new HashMap<>()));
        }
        for (SynthFunEvent.NonTerminal nonTerminal : synthFun.grammar().values()) {
            TermType termType = termTypes.get(nonTerminal.termType());
            Map<String, SemgusProduction> productions = nonTerminals.get(nonTerminal.termType()).productions();
            for (SynthFunEvent.Production production : nonTerminal.productions().values()) {
                TermConstructor termCtor = termType.constructors.get(production.operator());
                productions.put(production.operator(), new SemgusProduction(
                        production.operator(),
                        termCtor.childTermTypes.stream().map(nonTerminals::get).collect(Collectors.toList()),
                        termCtor.semanticRules.stream()
                                .map(r -> new SemanticRule(r.childTermVars(), r.head(), r.bodyRelations(), r.constraint()))
                                .collect(Collectors.toList())));
            }
        }
        return new SemgusProblem(
                synthFun.name(),
                nonTerminals.get(synthFun.termType()),
                nonTerminals,
                new ArrayList<>(constraints),
                new HashMap<>(metadata));
    }
public SemgusProblem end ( ) { if ( synthFun == null ) { throw new IllegalStateException ( "No synthesis function has been set!" ) ; } Map < String , SemgusNonTerminal > nonTerminals = new HashMap < > ( ) ; for ( SynthFunEvent . NonTerminal nonTerminal : synthFun . grammar ( ) . values ( ) ) { nonTerminals . put ( nonTerminal . termType ( ) , new SemgusNonTerminal ( nonTerminal . termType ( ) , new HashMap < > ( ) ) ) ; } for ( SynthFunEvent . NonTerminal nonTerminal : synthFun . grammar ( ) . values ( ) ) { TermType termType = termTypes . get ( nonTerminal . termType ( ) ) ; Map < String , SemgusProduction > productions = nonTerminals . get ( nonTerminal . termType ( ) ) . productions ( ) ; for ( SynthFunEvent . Production production : nonTerminal . productions ( ) . values ( ) ) { TermConstructor termCtor = termType . constructors . get ( production . operator ( ) ) ; productions . put ( production . operator ( ) , new SemgusProduction ( production . operator ( ) , termCtor . childTermTypes . stream ( ) . map ( nonTerminals :: get ) . collect ( Collectors . toList ( ) ) , termCtor . semanticRules . stream ( ) . map ( r -> new SemanticRule ( r . childTermVars ( ) , r . head ( ) , r . bodyRelations ( ) , r . constraint ( ) ) ) . collect ( Collectors . toList ( ) ) ) ) ; } } return new SemgusProblem ( synthFun . name ( ) , nonTerminals . get ( synthFun . termType ( ) ) , nonTerminals , new ArrayList < > ( constraints ) , new HashMap < > ( metadata ) ) ; }
Finishes parsing, wrapping all collected data into a {@link SemgusProblem} data structure.
Finishes parsing wrapping all collected data into a { @link SemgusProblem } data structure .
// construct all non-terminals beforehand so child term non-terminals can be resolved // add productions to non-terminals