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

de.claas.parser.RuleVisitor Maven / Gradle / Ivy

Go to download

This is an open source library for parsing text-based inputs. PARSER makes use of context-free grammars to validate and parse sentences. Having specified such a grammar, the library takes care of parsing text-based inputs and returns a tree of nodes that represents the parsed sentence. Furthermore, it provides ways for interpreting and refining the returned tree of nodes. In essence, the library aims to remove the pain of parsing and instead allow focusing on processing and interpreting parsed results.

There is a newer version: 2.0.1
Show newest version
package de.claas.parser;

import de.claas.parser.exceptions.CyclicRuleException;
import de.claas.parser.rules.CharacterValue;
import de.claas.parser.rules.Conjunction;
import de.claas.parser.rules.Disjunction;
import de.claas.parser.rules.NonTerminal;
import de.claas.parser.rules.NumberValue;
import de.claas.parser.rules.Optional;
import de.claas.parser.rules.Repetition;

/**
 * 
 * Superclass of all rule-based visitors. This class is intended to model a
 * visitor for {@link Rule} instances and their children. Implementations of
 * this class will most likely extract details (e.g. terminal symbols or
 * non-terminal symbols) or otherwise process rule-hierarchies.
 * 

* This class resembles the visitor design pattern. It includes a * visit-method for all implementations of the {@link Rule} class. * * @author Claas Ahlrichs * */ public interface RuleVisitor { /** * Called by {@link Conjunction}-rules. * * @param rule * the rule * @throws CyclicRuleException * if the visited rule is part of a cyclic graph (i.e. the rule * references itself either directly or indirectly) and if this * cannot be handled by the visitor */ void visitConjunction(Conjunction rule); /** * Called by {@link Disjunction}-rules. * * @param rule * the rule * @throws CyclicRuleException * if the visited rule is part of a cyclic graph (i.e. the rule * references itself either directly or indirectly) and if this * cannot be handled by the visitor */ void visitDisjunction(Disjunction rule); /** * Called by {@link NonTerminal}-rules. * * @param rule * the rule * @throws CyclicRuleException * if the visited rule is part of a cyclic graph (i.e. the rule * references itself either directly or indirectly) and if this * cannot be handled by the visitor */ void visitNonTerminal(NonTerminal rule); /** * Called by {@link Optional}-rules. * * @param rule * the rule * @throws CyclicRuleException * if the visited rule is part of a cyclic graph (i.e. the rule * references itself either directly or indirectly) and if this * cannot be handled by the visitor */ void visitOptional(Optional rule); /** * Called by {@link Repetition}-rules. * * @param rule * the rule * @throws CyclicRuleException * if the visited rule is part of a cyclic graph (i.e. the rule * references itself either directly or indirectly) and if this * cannot be handled by the visitor */ void visitRepetition(Repetition rule); /** * Called by {@link CharacterValue}-rules. * * @param rule * the rule */ default void visitTerminal(CharacterValue rule) { return; } /** * Called by {@link NumberValue}-rules. * * @param rule * the rule */ default void visitTerminal(NumberValue rule) { return; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy