Skip to content

spec: pin message-literal source grammar (RFC-001 §5.1) - #108

Merged
trendvidia merged 2 commits into
mainfrom
spec/message-literal-grammar
Jul 16, 2026
Merged

spec: pin message-literal source grammar (RFC-001 §5.1)#108
trendvidia merged 2 commits into
mainfrom
spec/message-literal-grammar

Conversation

@trendvidia

Copy link
Copy Markdown
Owner

Pins the source-level spelling of message and list literals (#102) — the follow-up from #64/PR #99, which settled the carrier but left the literal production unexpanded.

Grammar

literal        ::= scalarLit | listLiteral | messageLiteral
literalValue   ::= literal | qualifiedIdent          (* enum-value reference *)
listLiteral    ::= "[" (literalValue ("," literalValue)*)? "]"
messageLiteral ::= qualifiedIdent? "{" (fieldInit ("," fieldInit)*)? "}"
fieldInit      ::= Ident ":" literalValue

Canonical spelling: @example(myco.commons.Money{currency: "USD", units: 5}).

Decisions

  • Type name follows the §8.1 typing rule: REQUIRED when the param (or, recursively, the initialized field) is any/google.protobuf.Any; OPTIONAL and compiler-verified against the declared type otherwise; never inferred from the value's shape.
  • Colon field-inits, tight subset: mandatory : and commas, no trailing comma, each field at most once, unknown field = error. Textformat liberties (colon-less blocks, semicolons, repeated-by-repetition, [type.url]) excluded. Repeated fields take list literals; map fields deferred (compile error in v1.2).
  • Enum-typed fields/elements = qualifiedIdent, linker-resolved (EnumLiteral); lists homogeneous, nestable, []/{} legal; no expressions inside literals.

Acceptance criteria (#102)

  • literal production expanded (message + list) in RFC-001 §5.1 and docs/grammar.ebnf (new clearly-scoped schema-extension section with PXF-divergence notes)
  • IETF draft -01 grammar section updated (ABNF additions + new Literal Values section; resolved "Literal value shape" open-issue bullet removed)
  • Fixture: 10_literal_args.proto gains the Money{...} use site — golden 11_literal_carrier_golden.textproto's previously-orphaned middle entry now has its source counterpart; locations synced (49/54/58)

Plus a resolution record under docs/RFC-001-issues.md §#15 (second commit).

Closes #102

Expands the `literal` production left open in RFC-001 §5.1 and IETF
draft -01 (follow-up from #64 / PR #99, which pinned the carrier):

- messageLiteral: optional type name + braced colon-separated field
  inits — name REQUIRED when the param/field is `any`, OPTIONAL and
  verified otherwise; never inferred from shape
- listLiteral EBNF (used by fixture 10 but previously unpublished)
- tight subset, not full textformat: mandatory colon + commas, no
  trailing comma, fields at most once, repeated via list literals,
  maps deferred
- draft -01: ABNF additions, new Literal Values section, resolved
  open-issue bullet dropped
- grammar.ebnf: schema-extension section (with PXF-divergence notes)
- fixture 10 gains the Money message-literal use site; golden 11
  locations synced

Closes #102
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pin message-literal source syntax (IETF draft -01)

1 participant