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

org.modelcc.parser.fence.FenceCompositionConstraints 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!
package org.modelcc.parser.fence;

import java.util.Set;

import org.modelcc.language.syntax.Rule;
import org.modelcc.language.syntax.Symbol;
import org.modelcc.language.syntax.SyntaxConstraints;

/**
 * Fence composition constraints
 * 
 * @author Luis Quesada ([email protected]), refactored by Fernando Berzal ([email protected])
 */

public class FenceCompositionConstraints 
{
	private SyntaxConstraints constraints;
	
	public FenceCompositionConstraints (SyntaxConstraints constraints)
	{
		this.constraints = constraints;
	}
	
	// Composition constraint
	
	public boolean inhibit (Rule r, Symbol s) 
	{
		boolean inhibited = false;

		Set compc = constraints.getCompositionPrecedences(r);
		
		if (compc != null) {
			for (int j = 0;j < s.size();j++) {
				if (s.getContent(j).getRelevantRule() != null) {
					if (compc.contains(s.getContent(j).getRelevantRule())) {
						inhibited = true;
					}
				}
			}
		}
		
		return inhibited;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy