Class Grammar
java.lang.Object
org.episteme.social.linguistics.Grammar
- All Implemented Interfaces:
Serializable
Represents the grammar rules for parsing a language.
A grammar defines the syntactic structure of a language through a set of production rules. * @see Grammar (Wikipedia)
- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a rule to the grammar.voidClears all rules.Returns the description.Returns the language.getName()Returns the grammar name.intReturns the number of rules.getRules()Returns an unmodifiable set of rules.booleanremoveRule(Rule rule) Removes a rule from the grammar.voidsetDescription(String description) Sets the description.voidSets the grammar name.toString()
-
Constructor Details
-
Grammar
Creates a grammar for a language.- Parameters:
language- the language- Throws:
NullPointerException- if language is null
-
Grammar
-
-
Method Details
-
getLanguage
-
getName
-
setName
-
getDescription
-
setDescription
Sets the description.- Parameters:
description- the description
-
getRules
-
addRule
-
removeRule
Removes a rule from the grammar.- Parameters:
rule- the rule to remove- Returns:
- true if removed
-
getRuleCount
public int getRuleCount()Returns the number of rules.- Returns:
- rule count
-
clearRules
public void clearRules()Clears all rules. -
toString
-