Grammar.h header
#include <ew/core/Grammar.h>
Namespace ew::core
Grammar struct
struct ew::core::Grammar
The structured grammar of a constructed language: the typology, constituent order, and modifier placement; the word's internal slot template (positionClasses); the inflection paradigms; the pronouns; and the numberSystem. This supplements – it does not replace – the language's free-form grammar notes (which stay prose); it is the machine-readable part the translator and the reference-grammar export read.
Members
std::optional<MorphologicalTypology> ew::core::conlang::Grammar::typology
The morphological typology; unset when the writer has not said.
Unset is not the same as a default. These three carried one, so a language that had never been asked about adjectives still exported "Adjective position: before" as though it were a stated fact – in a document whose whole purpose is to be shared as the description of the language. A reference grammar may not assert what nobody decided, so the fields say when nobody has and the export omits the line.
std::optional<WordOrder> ew::core::conlang::Grammar::wordOrder
The basic constituent order; unset when the writer has not said.
std::optional<ModifierPosition> ew::core::conlang::Grammar::adjectivePosition
Where an adjective sits relative to its noun; unset when the writer has not said (including a language with no adjective class at all).
QString ew::core::conlang::Grammar::notes
Supplementary structured-grammar notes (kept apart from the Language's prose grammar notes).
std::vector<MorphemePositionClass> ew::core::conlang::Grammar::positionClasses
The word's internal slot template, in position order (see MorphemePositionClass). Empty for a language whose words are not built slot by slot.
std::vector<Paradigm> ew::core::conlang::Grammar::paradigms
The inflection paradigms (declensions/conjugations).
std::vector<PronounEntry> ew::core::conlang::Grammar::pronouns
The personal pronoun set.
NumberSystem ew::core::conlang::Grammar::numberSystem
The number system.
bool ew::core::conlang::Grammar::isEmpty() const
Whether the grammar carries no structured content (only defaults), so a language can omit it.
const Paradigm * ew::core::conlang::Grammar::paradigmFor(const QString &appliesTo) const
The paradigm that applies to appliesTo (part of speech / inflection class), or nullptr.
bool ew::core::conlang::Grammar::operator==(const Grammar &other) const =default
Value equality over all fields.
InflectionRule struct
struct ew::core::InflectionRule
One cell of an inflection paradigm: the affixation that realizes a grammatical feature combination on a stem. feature names the combination (e.g. "plural", "genitive.singular"); type and affix say how to build the inflected form from a stem.
Members
QString ew::core::conlang::InflectionRule::feature
The grammatical feature combination this rule realizes (e.g. "past", "accusative.plural").
AffixType ew::core::conlang::InflectionRule::type =
How the affix attaches.
QString ew::core::conlang::InflectionRule::affix
The affix text (a "before|after" pair for a circumfix; the whole word for a replacement).
QString ew::core::conlang::InflectionRule::rootWord
For AffixType::Root, the headword of the root that carries the feature.
Some languages mark a feature with a whole root in a slot rather than an affix – tense, for instance, can be a root whose POSITION and polarity together carry it. None of the affix types can say that, so such a rule had nowhere to live but prose; and because the root looks like any other, a glosser saw a tensed word only as an unknown string.
int ew::core::conlang::InflectionRule::positionClass = -1
For AffixType::Root, which MorphemePositionClass slot the root occupies (its position). -1 when the position does not matter.
bool ew::core::conlang::InflectionRule::usesOppositePolarity = false
For AffixType::Root, whether the feature is carried by the root's opposite pole (LexiconEntry::oppositeGloss) rather than its primary sense.
bool ew::core::conlang::InflectionRule::operator==(const InflectionRule &other) const =default
Value equality over all fields.
MorphemePositionClass struct
struct ew::core::MorphemePositionClass
One slot in a word's internal template: which position it occupies and what may fill it.
Constituent word order (SVO, SOV, ...) is a SENTENCE-level property and says nothing about the order of morphemes inside a word. A polysynthetic language – where a whole clause can be one word – has its real grammar in that intra-word order, and a paradigm cannot express it either: a paradigm attaches a known fixed affix, while a position class is an open slot any root of the right role may fill. Without this the grammar of such a language has nowhere to live but prose.
Members
int ew::core::conlang::MorphemePositionClass::position = 0
The slot's index in the word, 0 first. Slots are applied in ascending order.
QString ew::core::conlang::MorphemePositionClass::role
What the slot holds (e.g. "agent", "instrument", "root", "aspect"), naming a role rather than a fixed string.
QString ew::core::conlang::MorphemePositionClass::fills
Which roots may fill it: a semantic field, an inflection class, or a part of speech, matched against the lexicon. Empty means any root.
bool ew::core::conlang::MorphemePositionClass::required = false
Whether the slot must be filled for the word to be well formed.
bool ew::core::conlang::MorphemePositionClass::operator==(const MorphemePositionClass &other) const =default
Value equality over all fields.
NumberSystem struct
struct ew::core::NumberSystem
A constructed language's number system: its counting base and the words to build numbers from. The base is the radix (10 = decimal, 20 = vigesimal, 12 = duodecimal); digits gives the words for small values and base powers; formationNote records in prose how compounds are formed.
Members
int ew::core::conlang::NumberSystem::base = 10
The counting base / radix (at least 2). 10 is decimal, 20 vigesimal, 12 duodecimal.
QString ew::core::conlang::NumberSystem::formationNote
Free-form note on how multi-digit numbers are composed (e.g. "tens-word then ones-word").
std::vector<NumeralDigit> ew::core::conlang::NumberSystem::digits
The numeral words, by value (digits 0..base-1 and powers of the base).
QString ew::core::conlang::NumberSystem::wordFor(int value) const
The word for value, or an empty string if the system has none.
bool ew::core::conlang::NumberSystem::operator==(const NumberSystem &other) const =default
Value equality over all fields.
NumeralDigit struct
struct ew::core::NumeralDigit
One numeral word: a value and the word the language uses for it. A number system lists the words for the digits (0..base-1) and for the powers of the base, from which larger numbers are composed.
Members
int ew::core::conlang::NumeralDigit::value = 0
The numeric value this word names (e.g. 0, 1, ... , or a power of the base like 10, 100).
QString ew::core::conlang::NumeralDigit::word
The word for that value in the language.
bool ew::core::conlang::NumeralDigit::operator==(const NumeralDigit &other) const =default
Value equality over all fields.
Paradigm struct
struct ew::core::Paradigm
A named inflection paradigm: the set of forms a class of words takes across a grammatical dimension (declension for nouns, conjugation for verbs). appliesTo names the part of speech or inflection class the paradigm inflects, so the right paradigm can be found for a word.
Members
QString ew::core::conlang::Paradigm::name
The paradigm's display name (e.g. "Regular noun", "Strong verb").
QString ew::core::conlang::Paradigm::appliesTo
The part of speech or inflection class this paradigm applies to (e.g. "noun", "a-stem").
std::vector<InflectionRule> ew::core::conlang::Paradigm::rules
The paradigm's cells, one per feature combination.
const InflectionRule * ew::core::conlang::Paradigm::rule(const QString &feature) const
The rule realizing feature, or nullptr if the paradigm has no cell for it.
bool ew::core::conlang::Paradigm::operator==(const Paradigm &other) const =default
Value equality over all fields.
PronounEntry struct
struct ew::core::PronounEntry
One personal pronoun: its form in the language and the person/number/role it stands for. Pronouns are a small closed set worth modelling explicitly rather than as ordinary lexicon entries, so the grammar can lay them out in a paradigm table (person x number, inclusive/exclusive, formality).
Members
QString ew::core::conlang::PronounEntry::label
A short feature label (e.g. "1sg", "2pl.formal", "1pl.incl").
QString ew::core::conlang::PronounEntry::form
The pronoun as written in the language.
QString ew::core::conlang::PronounEntry::gloss
Its meaning/role in the writer's language (e.g. "I", "you (plural, formal)").
bool ew::core::conlang::PronounEntry::operator==(const PronounEntry &other) const =default
Value equality over all fields.
Enumerations
enum class AffixType { None, Prefix, Suffix, Circumfix, Replacement, Root }
How an inflectional affix attaches to a stem.
enum class ModifierPosition { BeforeNoun, AfterNoun }
Whether a modifier (adjective, article) precedes or follows the noun it modifies.
enum class MorphologicalTypology { Isolating, Agglutinative, Fusional, Polysynthetic }
The broad morphological typology of a constructed language – how much meaning it packs into a single word, from isolating (one morpheme per word) to polysynthetic (whole clauses in a word). Serialized as a stable lowercase token.
enum class WordOrder { SubjectVerbObject, SubjectObjectVerb, VerbSubjectObject, VerbObjectSubject, ObjectVerbSubject, ObjectSubjectVerb, Free }
The basic order of subject, verb, and object in a clause (the language's constituent order). Serialized as a stable uppercase token (e.g. "SOV").
Functions
std::optional< AffixType > ew::core::conlang::affixTypeFromToken(QStringView token)
Parses an affix type from its token; std::nullopt if unrecognized.
std::optional< ModifierPosition > ew::core::conlang::modifierPositionFromToken(QStringView token)
Parses a modifier position from its token; std::nullopt if unrecognized.
std::optional< MorphologicalTypology > ew::core::conlang::morphologicalTypologyFromToken(QStringView token)
Parses a morphological typology from its token; std::nullopt if unrecognized.
QString ew::core::conlang::toToken(MorphologicalTypology typology)
The stable serialization token for typology (e.g. "agglutinative").
QString ew::core::conlang::toToken(WordOrder order)
The stable serialization token for order (e.g. "SOV").
QString ew::core::conlang::toToken(ModifierPosition position)
The stable serialization token for position (e.g. "before").
QString ew::core::conlang::toToken(AffixType type)
The stable serialization token for type (e.g. "suffix").
std::optional< WordOrder > ew::core::conlang::wordOrderFromToken(QStringView token)
Parses a word order from its token; std::nullopt if unrecognized.