Revised GALEN Grammar
Fixed positional grammar specification
Every valid GALEN statement follows exactly one positional grammar. Position carries meaning. Deviation is a syntax error.
Full form
INTENT.DOMAIN: SUBJECT @RECIPIENT angle= tone= +/- context= >FORMATINTENT
Mandatory. Single uppercase letter. Defines the action to perform.
G = Generate, Q = Query, E = Explain, S = Summarise, D = Data, C = Command, R = ReviseDOMAIN
Optional. Dot-separated after intent. Narrows the action type.
G.email, G.report, Q.med, C.workflowSUBJECT
Mandatory. Core topic or object. Compound subjects joined with dots.
bariatric.surgery, overdue.invoices, customer.complaints@RECIPIENT
Optional. Target recipient or system. Always prefixed with @. Position: first modifier.
@finance, @gp, @customersangle=
Optional. Purpose or framing of the output. Position: second modifier.
angle=compliance, angle=risks, angle=benefitstone=
Optional. Tone of the output. Position: third modifier.
tone=formal, tone=plain, tone=urgent+/- modifiers
Optional. Add (+) or reduce (-) scope. Position: fourth.
+detail, -length, +comparisoncontext=
Optional. Jurisdiction, geography, system context. Position: fifth.
country=UK, lang=en, system=crm>FORMAT
Optional. Output format. Always last.
>txt, >list, >brief, >full, >step, >json, >tblCanonical Token Dictionary
One token. One meaning. Always.
Every token maps to exactly one canonical English phrase. This is the complete dictionary. No token may appear outside this list without registering a new canonical definition.
| Token | Canonical English expansion | Position |
|---|---|---|
| Intent tokens | ||
| G | Write | Intent (mandatory) |
| G.email | Write an email | Intent.Domain |
| G.report | Write a report | Intent.Domain |
| G.letter | Write a letter | Intent.Domain |
| G.summary | Write a summary | Intent.Domain |
| G.workflow | Execute the workflow for | Intent.Domain |
| G.plan | Create a plan for | Intent.Domain |
| Q | Provide information about | Intent (mandatory) |
| Q.med | Provide medical information about | Intent.Domain |
| Q.fin | Provide financial information about | Intent.Domain |
| Q.leg | Provide legal information about | Intent.Domain |
| Q.tech | Provide technical information about | Intent.Domain |
| E | Explain | Intent (mandatory) |
| S | Summarise | Intent (mandatory) |
| D | Record structured data for | Intent (mandatory) |
| D.med | Record structured clinical data for | Intent.Domain |
| C | Execute | Intent (mandatory) |
| C.travel | Create a travel itinerary for | Intent.Domain |
| R | Revise | Intent (mandatory) |
| Recipient tokens (@) | ||
| @finance | to the finance department | First modifier |
| @gp | to the general practitioner | First modifier |
| @surgeon | to the surgeon | First modifier |
| @cardiologist | to the cardiologist | First modifier |
| @customers | to all customers | First modifier |
| @management | to the management team | First modifier |
| @client | to the client | First modifier |
| @team | to the team | First modifier |
| Angle tokens (angle=) | ||
| angle=compliance | focused on compliance | Second modifier |
| angle=risks | focused on risks | Second modifier |
| angle=benefits | focused on benefits | Second modifier |
| angle=comparison | as a comparative analysis | Second modifier |
| angle=summary | as a high-level overview | Second modifier |
| angle=outcomes | focused on outcomes | Second modifier |
| Tone tokens (tone=) | ||
| tone=formal | in a formal tone | Third modifier |
| tone=plain | in plain language | Third modifier |
| tone=urgent | with urgency | Third modifier |
| tone=professional | in a professional tone | Third modifier |
| tone=empathetic | in an empathetic tone | Third modifier |
| Scope tokens (+/-) | ||
| +detail | with full detail | Fourth modifier |
| -length | brief | Fourth modifier |
| +comparison | including a comparison | Fourth modifier |
| +crm | and create a reminder in the CRM | Fourth modifier |
| +notify.finance | and notify the finance team | Fourth modifier |
| +top3 | highlighting the top three items | Fourth modifier |
| +management.summary | with a management summary | Fourth modifier |
| +next | planned for the next step | Fourth modifier |
| +past | previously completed | Fourth modifier |
| Context tokens (context=) | ||
| country=UK | in the United Kingdom | Fifth modifier |
| country=US | in the United States | Fifth modifier |
| lang=en | in English | Fifth modifier |
| system=crm | within the CRM system | Fifth modifier |
| budget=low | on a budget | Fifth modifier |
| duration=3d | over three days | Fifth modifier |
| Format tokens (>) | ||
| >txt | as plain text | Last (mandatory position) |
| >list | as a list | Last |
| >brief | as a brief summary | Last |
| >full | in full detail | Last |
| >step | as step-by-step instructions | Last |
| >json | as structured JSON data | Last |
| >tbl | as a table | Last |
Reverse Compilation Rules
GALEN → Canonical English
The reverse compiler follows a strict assembly order. Each position in the GALEN statement maps to a fixed position in the canonical English sentence.
Rule 1
Begin with the INTENT expansion. If -length is present, prepend "Write a brief" instead of "Write a". Apply -length before all other modifiers.
Rule 2
Expand SUBJECT by replacing dots with spaces.
overdue.invoice.followup → "overdue invoice follow-up"Rule 3
Append @RECIPIENT expansion immediately after subject.
@finance → "to the finance department"Rule 4
Append angle= expansion.
angle=compliance → "focused on compliance"Rule 5
Append tone= expansion.
tone=formal → "in a formal tone"Rule 6
Append all + modifiers in order of appearance. Join with commas if multiple.
Rule 7
Append context= expansions.
country=UK → "in the United Kingdom"Rule 8
Append >FORMAT expansion last, preceded by a comma.
>txt → ", as plain text"Rule 9
Capitalise the first character of the canonical output. End with a full stop.
Rule 10
Unknown tokens: expand by replacing dots with spaces and inserting into the sentence at the correct positional slot. Never discard a token silently.
Example 1
G.email: finance @finance angle=compliance tone=formal -length >txt
↓ canonical expansion
Write a brief formal email to the finance department focused on compliance, as plain text.
Example 2
Q.med: bariatric.surgery vs GLP1 +comparison country=UK >list
↓ canonical expansion
Provide medical information about bariatric surgery versus GLP1 including a comparison in the United Kingdom, as a list.
Example 3
G.workflow: overdue.invoice.followup @customers +crm +notify.finance angle=compliance >step
↓ canonical expansion
Execute the workflow for overdue invoice follow-up to all customers and create a reminder in the CRM and notify the finance team focused on compliance, as step-by-step instructions.
Example 4
C.travel: itinerary Tokyo budget=low duration=3d >list
↓ canonical expansion
Create a travel itinerary for itinerary Tokyo on a budget over three days, as a list.
Implementation
Pseudocode: GALEN → English compiler
// GALEN Reverse Compiler — Pseudocode // Input: GALEN string · Output: canonical English sentence function expandGALEN(galenString): // Step 1 — Tokenise parts = parse(galenString) // parts = { intent, domain, subject, tokens[] } // Step 2 — Detect -length early (modifies intent phrase) isBreif = parts.tokens.includes("-length") // Step 3 — Expand INTENT intentKey = parts.domain ? parts.intent + "." + parts.domain : parts.intent intentPhrase = DICTIONARY[intentKey] ?? "Perform action" if isBrief: intentPhrase = intentPhrase.replace("Write", "Write a brief") // Step 4 — Expand SUBJECT subjectPhrase = parts.subject .replace(/\./g, " ") .replace(" vs ", " versus ") // Step 5 — Assemble in canonical order sentence = [intentPhrase, subjectPhrase] // @recipient — first recipient = parts.tokens.find(t => t.startsWith("@")) if recipient: sentence.push(DICTIONARY[recipient]) // angle= — second angle = parts.tokens.find(t => t.startsWith("angle=")) if angle: sentence.push(DICTIONARY[angle]) // tone= — third tone = parts.tokens.find(t => t.startsWith("tone=")) if tone: sentence.push(DICTIONARY[tone]) // + modifiers — fourth (in order, skip -length) plusTokens = parts.tokens.filter(t => t.startsWith("+")) plusTokens.forEach(t => sentence.push(DICTIONARY[t] ?? t.replace("+",""))) // context= — fifth contextTokens = parts.tokens.filter(t => t.includes("=") && !t.startsWith("angle") && !t.startsWith("tone")) contextTokens.forEach(t => sentence.push(DICTIONARY[t] ?? t)) // >format — last format = parts.tokens.find(t => t.startsWith(">")) if format: sentence.push(",", DICTIONARY[format]) // Step 6 — Join and capitalise result = sentence.join(" ").trim() result = result[0].toUpperCase() + result.slice(1) + "." return result
Live Tool
Try the reverse compiler
Type any valid GALEN statement. It expands to canonical English in real time.
GALEN → English · Live Compiler
● Deterministic
Canonical English expansion will appear here...
Quick examples
G.email compliance
Q.med comparison
G.workflow invoice
C.travel Tokyo
S: complaints