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

org.modelcc.parser.fence.Fence Maven / Gradle / Ivy

Go to download

ModelCC is a model-based parser generator (a.k.a. compiler compiler) that decouples language specification from language processing, avoiding some of the problems caused by grammar-driven parser generators. ModelCC receives a conceptual model as input, along with constraints that annotate it. It is then able to create a parser for the desired textual language and the generated parser fully automates the instantiation of the language conceptual model. ModelCC also includes a built-in reference resolution mechanism that results in abstract syntax graphs, rather than mere abstract syntax trees.

The newest version!
/*
 * ModelCC, distributed under ModelCC Shared Software License, www.modelcc.org
 */

package org.modelcc.parser.fence;

import java.io.Serializable;
import java.util.Map;

import org.modelcc.language.syntax.ParserMetadata;
import org.modelcc.language.syntax.SyntaxSpecification;
import org.modelcc.lexer.LexicalGraph;

/**
 * Fence - SyntaxGraphParser with Lexical and Syntactic Ambiguity Support.
 * 
 * @author Luis Quesada ([email protected])
 */
public class Fence implements Serializable {

    /**
     * Perform syntactical analysis on a Lexical Graph.
     * @param fs the Fence specification.
     * @param lg the input lexical graph.
     * @return a syntax graph.
     */
    public SyntaxGraph parse(ParserMetadata metadata,SyntaxSpecification fs,LexicalGraph lg) 
    {
    	return parse(metadata,fs,lg,null);
    }
    
    /**
     * Perform syntactical analysis on a Lexical Graph.
     * @param fs the Fence specification.
     * @param lg the input lexical graph.
     * @param objectMetadata the object metadata warehouse
     * @return a syntax graph.
     */
    public SyntaxGraph parse(ParserMetadata metadata,SyntaxSpecification fs,LexicalGraph lg,Map> objectMetadata) 
    {
        FenceGrammarParser fgp = new FenceGrammarParser();
        ParsedGraph pg = fgp.parse(fs.getGrammar(),lg);
        FenceConstraintEnforcer fce = new FenceConstraintEnforcer(metadata,fs.getConstraints(),objectMetadata);
        SyntaxGraph sg = fce.enforce(pg);
        return sg;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy