Skip to content

Clause renames - #624

Merged
teunbrand merged 8 commits into
mainfrom
clause-renames
Dec 3, 2026
Merged

teunbrand merged 8 commits into
mainfrom
clause-renames

Conversation

@teunbrand

Copy link
Copy Markdown
Collaborator

This PR aims to fix an issue discussed off-github.

Essentially LABEL title => 'foo', subtitle => 'bar' becomes TITLE main => 'foo', sub => 'bar'.
Then, SCALE RENAMING and FORMAT RENAMING become SCALE LABEL c.q. FORMAT LABEL.
In terms of grammar, it becomes more ambiguous to do SCALE label: is the label the label-clause or the label-aesthetic?
However, we hardcode null/identity scales in the vegalite path and any actual use of a label scale will likely include other subclauses to distinguish these by position.

Frees 'title' from colliding with the upcoming TITLE clause keyword:
'TITLE title => ...' would lex the second word as the keyword. 'main'
and 'sub' read naturally beside 'caption'.
The LABEL clause sets (sub)titles, captions and axis/legend titles, so
TITLE is the more natural name — freeing LABEL for a future clause
that actually sets break labels.

Grammar nodes rename accordingly (title_clause, title_assignment,
title_type), the shared Labels struct becomes Titles (src/titles.rs,
Plot.titles, Table.titles), and the doc pages move to
syntax/clause/title.qmd and title-tabulate.qmd.
The SCALE/FORMAT subclause that maps values to display labels is now
LABEL, made available by the titles clause taking the TITLE name. The
Format AST field follows Scale::label_spec as Format::label_spec.
The TITLE main line is one column shorter than the LABEL title line it
replaced, shifting every token after it; the assertion carets moved with
it.
@teunbrand
teunbrand marked this pull request as ready for review November 30, 2026 12:14
@teunbrand
teunbrand requested a review from thomasp85 November 30, 2026 12:14

@thomasp85 thomasp85 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mostly ready to ship. Once the following is addressed, merge at your discretion:

  • No changelog (this is a large breaking change)
  • We perhaps need to provide slightly better error messages for the old syntax rather than a generic syntax error
  • syntax/clause/label → title breaks external doc links — consider a Quarto aliases: redirect
  • From Kimi: Highlighters: ggsql.tmLanguage.json:356 colors the aesthetic in SCALE label as a keyword (rule order); line 388 FACET highlights a LABEL keyword that FACET doesn't have; doc/ggsql.xml:540 has the mirror-image problem (LABEL colored as aesthetic), and the label_properties list (line 250) now holds main/sub under the old name.

The old forms fail to parse and used to get the generic fallback:

- LABEL as a clause and RENAMING as a SCALE/FORMAT subclause head an
  ERROR node with the old keyword; check_dead_clauses() in
  SourceTree::validate() recognises them and names the replacement
  (TITLE, LABEL).
- TITLE title => ... lexes title as a second TITLE keyword, leaving
  the assignment name missing; the same check points at main.
- TITLE subtitle => ... parses cleanly, so check_dead_keywords() in
  build_titles rejects the key and points at sub. Quoting the name
  opts out, for a column genuinely named title or subtitle.

A specific SourceTree message now wins over validate()'s generic
VISUALISE-side recovery guess. The shims are marked for removal
before the post-beta release in src/AGENTS.md.
@teunbrand

Copy link
Copy Markdown
Collaborator Author

Addressed most of the comments, with the exception:

ggsql.tmLanguage.json:356 colors the aesthetic in SCALE label as a keyword (rule order)

This is the grammatical ambiguity I noted previously. The ambiguity gets resolved by position as soon as other subclauses is involved, which would be any non trivial label scale.

@teunbrand
teunbrand merged commit 33d975e into main Dec 3, 2026
24 of 25 checks passed
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.

2 participants