All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.api.processor.LanguageDefinition.kt Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (C) 2018 Dr. David H. Akehurst (http://dr.david.h.akehurst.net)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.akehurst.language.api.processor

import net.akehurst.language.agl.grammar.grammar.GrammarContext
import net.akehurst.language.agl.processor.AglLanguages
import net.akehurst.language.api.analyser.ScopeModel
import net.akehurst.language.api.analyser.SemanticAnalyser
import net.akehurst.language.api.analyser.SyntaxAnalyser
import net.akehurst.language.api.formatter.AglFormatterModel
import net.akehurst.language.api.grammar.Grammar
import net.akehurst.language.api.grammar.Namespace
import net.akehurst.language.api.style.AglStyleModel

interface GrammarRegistry {
    fun registerGrammar(grammar: Grammar)
    fun findGrammarOrNull(localNamespace: Namespace, nameOrQName: String): Grammar?
}

interface LanguageRegistry : GrammarRegistry {

    val agl: AglLanguages

    /**
     * create and register a LanguageDefinition as specified
     */
    fun  register(
        identity: String,
        grammarStr: String?,
        aglOptions: ProcessOptions, GrammarContext>?,
        buildForDefaultGoal: Boolean,
        configuration: LanguageProcessorConfiguration
    ): LanguageDefinition

    fun unregister(identity: String)

    fun  findOrNull(identity: String): LanguageDefinition?

    fun  findOrPlaceholder(
        identity: String,
        aglOptions: ProcessOptions, GrammarContext>?,
        configuration: LanguageProcessorConfiguration?
    ): LanguageDefinition
}

interface LanguageDefinition {

    val identity: String
    val isModifiable: Boolean

    var grammarStr: String?
    var grammar: Grammar?
    var targetGrammarName: String?
    var defaultGoalRule: String?

    var scopeModelStr: String?
    var scopeModel: ScopeModel?

    var configuration: LanguageProcessorConfiguration

    val syntaxAnalyser: SyntaxAnalyser?
    val semanticAnalyser: SemanticAnalyser?

    //var formatStr: String?
    //val formatterModel:AglFormatterModel?
    val formatter: Formatter?

    /** the options for parsing/processing the grammarStr for this language */
    //var aglOptions: ProcessOptions, GrammarContext>?
    val processor: LanguageProcessor?

    var styleStr: String?
    var style: AglStyleModel?

    val issues: IssueCollection

    val processorObservers: MutableList<(LanguageProcessor?, LanguageProcessor?) -> Unit>
    val grammarStrObservers: MutableList<(String?, String?) -> Unit>
    val grammarObservers: MutableList<(Grammar?, Grammar?) -> Unit>
    val scopeStrObservers: MutableList<(String?, String?) -> Unit>
    val scopeModelObservers: MutableList<(ScopeModel?, ScopeModel?) -> Unit>
    val formatterStrObservers: MutableList<(String?, String?) -> Unit>
    val formatterObservers: MutableList<(AglFormatterModel?, AglFormatterModel?) -> Unit>
    val styleStrObservers: MutableList<(String?, String?) -> Unit>
    val styleObservers: MutableList<(AglStyleModel?, AglStyleModel?) -> Unit>

    fun update(grammarStr: String?, scopeModelStr: String?, styleStr: String?)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy