Texomy syntax at a glance.
A Texomy specification describes what your text means — types and their fields — and how those types appear on the surface. The compiler turns it into a deterministic parser.
The mental model
A specification is a tree of types. Each type either has$fields (a structured type), or children (an enum-like alternation), or a single $patterns value (a leaf pattern). Types compose freely: any type may reference any other by name.
Types
Types are top-level YAML keys. They can be leaves or containers.
# Leaf type: one or more regex patterns.
Integer: '\d+'
# Enum-like: children are named alternatives.
LogLevel:
Info: 'INFO'
Warn: 'WARN'
Error: 'ERROR'
# Structural: fields with a surface pattern.
Money:
$fields:
amount: '\d+(\.\d+)?'
currency: '[A-Z]{3}'
$patterns: '#{amount} #{currency}'Fields
$fields declares the named parts of a structural type. Each field has a type — either a reference by name, or an inline pattern.
Payment:
$fields:
id: TransactionId # reference to a declared type
money: Money # another type
when: { $patterns: '\d{4}-\d{2}-\d{2}' } # inline anonymous type
$patterns: 'PAY #{id} #{money} on #{when}'Patterns
$patterns is where surface form meets structure. Use #{field} to splice a field back into the regex; use ${Type} to embed a declared type's pattern.
TransactionId: 'TX-${Integer}' # composes IntegerA type may declare multiple patterns as alternatives. Any of them will match.
Country:
$fields:
code: CountryCode
name: CountryName
$patterns:
- '#{code}'
- '#{name}'Cross-references and paths
Types can be nested. Use :: to walk into a child.
Number:
Decimal: '\d+\.\d+'
Integer: '\d+'
Latency:
$fields:
ms: Number::Integer # specifically the Integer child
$patterns: '#{ms}ms'Use ${!Type} in a pattern to match anything exceptthat type — useful for "everything until the next keyword".
Flags
$flags controls how patterns match at scope. They are inherited from the file scope down into each type; a type may opt out of an inherited flag by prefixing it with -.
$flags: ['FLEXIBLE_WHITESPACE', 'WORD_BOUNDARY']
Number:
$flags: '-WORD_BOUNDARY' # opt out for this type; digits are composed elsewhere
Decimal: '\d+\.\d+'
Integer: '\d+'Common flags:
WORD_BOUNDARY— anchor matches to word boundaries. Ideal for keyword-like enums.FLEXIBLE_WHITESPACE— treat any whitespace in a pattern as "one or more".CASE_INSENSITIVE— self-explanatory.
Put a flag at the widest scope it correctly applies to. Do not repeat it on every child.
Composition rules of thumb
- Model the domain, not the sample. A closed vocabulary gets the whole typical set even if input contains only one value.
- No literal identifiers in
$patterns. If a service name or code appears literally, promote it to a typed enum and reference it. - No bare regex for a value with a vocabulary. Declare an enum type with named children instead.
- Compose declared types. Write
'K-${Integer}', not'K-\d+', whenIntegerexists.
Try it
The fastest way to learn the syntax is to open an example in Studio and change it.