Skip to main content

equals

Description

The equals operator (used with a given field name) lets you filter a grammar so that an entry can only be generated if the form in the given field is equal to a particular string or matches a particular regex.

equals applies to the content immediately to its left, but can be chained.

Usage examples

Say, for example, that the A symbol defines the fields text and group, and group can be either "ER", "IR", or "OTHER". The following code creates a symbol B that only contains entries where the group equals "OTHER".

A = textgroup
mangerER
allerOTHER
choisirIR
vendreOTHER
pouvoirOTHER
B = embedequals group
AOTHER

Below an equals operator, content is interpreted as a regex. For example, we could filter A only to entries where the text starts with "p", "t", or "k":

B = embedequals text
A(p|t|k).*

(There is also a special convenience operator for this, starts, which you can read about on the starts page, that auto-generates a regex and would suffice for this particular use-case. However, if you have a more complex regex you wish to filter on, we recommend using equals and being explicit about which regex you want to match.)

Below is an example of how you could define a single-field symbol (like VOWEL shown below) and use it in place of a long or complicated regex:

VOWEL = text
a
e
i
o
u

Suppose we want to define a new symbol V that contains any entry from Nouns below if it the form in text ends with a vowel:

Nouns = text
casa
gato
sabor
animal
V = embedequals text
Nouns.*{VOWEL}

To use a symbol like this, it can only have one field.