Canonical Expansion · Patent Pending
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= >FORMAT
INTENT
Mandatory. Single uppercase letter. Defines the action to perform. G = Generate, Q = Query, E = Explain, S = Summarise, D = Data, C = Command, R = Revise
DOMAIN
Optional. Dot-separated after intent. Narrows the action type. G.email, G.report, Q.med, C.workflow
SUBJECT
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, @customers
angle=
Optional. Purpose or framing of the output. Position: second modifier. angle=compliance, angle=risks, angle=benefits
tone=
Optional. Tone of the output. Position: third modifier. tone=formal, tone=plain, tone=urgent
+/- modifiers
Optional. Add (+) or reduce (-) scope. Position: fourth. +detail, -length, +comparison
context=
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, >tbl
Canonical 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.

TokenCanonical English expansionPosition
Intent tokens
GWriteIntent (mandatory)
G.emailWrite an emailIntent.Domain
G.reportWrite a reportIntent.Domain
G.letterWrite a letterIntent.Domain
G.summaryWrite a summaryIntent.Domain
G.workflowExecute the workflow forIntent.Domain
G.planCreate a plan forIntent.Domain
QProvide information aboutIntent (mandatory)
Q.medProvide medical information aboutIntent.Domain
Q.finProvide financial information aboutIntent.Domain
Q.legProvide legal information aboutIntent.Domain
Q.techProvide technical information aboutIntent.Domain
EExplainIntent (mandatory)
SSummariseIntent (mandatory)
DRecord structured data forIntent (mandatory)
D.medRecord structured clinical data forIntent.Domain
CExecuteIntent (mandatory)
C.travelCreate a travel itinerary forIntent.Domain
RReviseIntent (mandatory)
Recipient tokens (@)
@financeto the finance departmentFirst modifier
@gpto the general practitionerFirst modifier
@surgeonto the surgeonFirst modifier
@cardiologistto the cardiologistFirst modifier
@customersto all customersFirst modifier
@managementto the management teamFirst modifier
@clientto the clientFirst modifier
@teamto the teamFirst modifier
Angle tokens (angle=)
angle=compliancefocused on complianceSecond modifier
angle=risksfocused on risksSecond modifier
angle=benefitsfocused on benefitsSecond modifier
angle=comparisonas a comparative analysisSecond modifier
angle=summaryas a high-level overviewSecond modifier
angle=outcomesfocused on outcomesSecond modifier
Tone tokens (tone=)
tone=formalin a formal toneThird modifier
tone=plainin plain languageThird modifier
tone=urgentwith urgencyThird modifier
tone=professionalin a professional toneThird modifier
tone=empatheticin an empathetic toneThird modifier
Scope tokens (+/-)
+detailwith full detailFourth modifier
-lengthbriefFourth modifier
+comparisonincluding a comparisonFourth modifier
+crmand create a reminder in the CRMFourth modifier
+notify.financeand notify the finance teamFourth modifier
+top3highlighting the top three itemsFourth modifier
+management.summarywith a management summaryFourth modifier
+nextplanned for the next stepFourth modifier
+pastpreviously completedFourth modifier
Context tokens (context=)
country=UKin the United KingdomFifth modifier
country=USin the United StatesFifth modifier
lang=enin EnglishFifth modifier
system=crmwithin the CRM systemFifth modifier
budget=lowon a budgetFifth modifier
duration=3dover three daysFifth modifier
Format tokens (>)
>txtas plain textLast (mandatory position)
>listas a listLast
>briefas a brief summaryLast
>fullin full detailLast
>stepas step-by-step instructionsLast
>jsonas structured JSON dataLast
>tblas a tableLast
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