Skip to content

Let a subscript have a subscript - #2070

Merged
Rafael-SOWNet merged 3 commits into
masterfrom
a-subscript-can-have-a-subscript
Oct 22, 2026
Merged

Rafael-SOWNet merged 3 commits into
masterfrom
a-subscript-can-have-a-subscript

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Fixes #524.

  • The gap. A name took at most one _, so X_a_beta was a lexer error, where technical papers write it for X with the subscript a_beta. On 2.6.0, even MathS.Var("X_a_beta") throws.
  • The change. A subscript may have one of its own.
    • X_a_beta is one variable, and its LaTeX is X_{a_{\beta}}. Each level is set as a name is, so Greek letters and constants are included: x_1_2_e is x_{1_{2_{\mathrm{e}}}}.
    • _ still neither begins nor ends a name, and two do not stand together, so x__1 is still an error.
  • Docs. The syntax page's list of things that look like names no longer includes x_1_2, and says what nesting gives.

Tests: SyntaxDocumentedTest reads x_1_2 and X_a_beta as names and x__1 as an error. LatexTest covers two levels, three levels, and a parsed sum.

Results:

  • Unit suite: passes (16,740).
  • MCP tests: pass (325).
  • Parser: the lexer is regenerated, with its classes internal.

#2068 also regenerates the parser, so whichever of the two merges second is regenerated from the merged grammar.

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

Rafael-SOWNet and others added 2 commits October 22, 2026 16:42
A name took at most one underscore, so X_a_beta, which technical papers
write for X with the subscript a_beta, was a lexer error. A subscript may
now have one of its own: X_a_beta is one variable, and its LaTeX is
X_{a_{\beta}}, each level set as a name is, Greek letters and constants
included. An underscore still neither begins nor ends a name, and two do
not stand together: x__1 is still an error.

Fixes #524.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
…e-a-subscript

# Conflicts:
#	Sources/AngouriMath/Core/Antlr/AngouriMathLexer.cs
#	Sources/AngouriMath/Core/Antlr/AngouriMathLexer.interp
@Rafael-SOWNet
Rafael-SOWNet merged commit 0c95f4f into master Oct 22, 2026
35 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in AngouriMath Oct 22, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the a-subscript-can-have-a-subscript branch October 29, 2026 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Multilevel Subscripts in Equations

1 participant