Repository navigation
Write down what the grammar accepts, and correct three statements that were not true (#746 items 8, 74) - #1041
Merged
Conversation
…t say (#746 items 8, 74) Syntax.md is the only statement of the language other than the grammar itself, so what it leaves out is undiscoverable and what it gets wrong is worse than nothing. Derived rather than taken from a list: every function-open literal in AngouriMath.g -- 102 of them -- checked against the page, plus the non-function productions of `atom`, the lexer rules, and the token insertion in Core/Parser.cs. Twenty function names and fifteen features were missing. Added: sum and product, the operators that declare a name over a range, with what the declared name shadows: `sum(i, i, 1, 10)` is 55 while `sum(sqrt(-1) * i, i, 1, 10)` is 55i, and `product(pi, pi, 1, 4)` is 24 exp, log10, log2, and log with one argument, which is base 10 the a- spellings of every inverse hyperbolic and the five refusals beyond arcsinh (|x|), the absolute-value brackets True and False, which is what Stringize prints // and /* */ comments, and newlines, which are skipped .5, 1., and the imaginary suffix in 3i and 1.5e3i MathS.Settings.ExplicitParsingOnly Cyrillic letters in names, where only Greek was named Corrected, each with the probe that settles it: The variable-name rule said "a letter or `_` followed by letters, digits or `_`". The grammar is `letter+ ('_' (letter|digit)+)?`, which disagrees four ways: `_x` and `x_` are lexer errors, `x_1_2` is one too, `x1` is `x ^ 1` rather than a name, and Cyrillic is a letter as much as Greek. "`sinx` is `s * i * n * x`" is false -- `sinx` is one variable named `sinx`, because the lexer takes the longest match. Nothing here produced a product of one-letter names. "Juxtaposition is multiplication" is half of it. A number, a name or `)` followed by a number inserts `^` and not `*`, so `x2` is `x ^ 2` while `x(2)` is `x * 2`, and `x i` is `x ^ i` because `i` is a number token. The associativity statement item 74 also names -- everything but `^` groups to the left -- was already corrected by #1009 and is left as it stands. Two things the page now records rather than fixes: Stringize drops a codomain (#1022), and a // comment that ends the input is a parse error because the lexer rule requires the newline (#1039, filed from this work). #1028 gained the note that `[]` reaches its IndexOutOfRangeException through the parser and not only through MathS.Vector. Sources/Tests/UnitTests/Convenience/SyntaxDocumentedTest.cs runs every example on the page: the precedence table row by row, the four shapes that are not names, both juxtaposition rules and ExplicitParsingOnly, the number and boolean spellings, comments, the inverse hyperbolic table, and sum and product including what their declared name shadows. It compares entities, never printed forms. Suite: 7930 passed, 0 failed, 14 skipped, against 7825 / 0 / 14 on this branch before the change -- the 105 are this file, and nothing else moved. The new file carries the default 2019-2022 header; Sources/.editorconfig, which pins it, belongs to other pull requests this cycle and no 2026 scope was added there. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Bjumi5K7fg8yx6UK1mZTQd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Docs/Usage/Syntax.mdis the only statement of this language other than the grammar itself, so what it omits is undiscoverable and what it gets wrong is worse than nothing. #746 item 8 asks for the omissions and item 74 for the wrong statements.How the list was derived
Not taken from the roadmap's count. Every function-open literal in
Sources/AngouriMath/Core/Antlr/AngouriMath.g— 102 of them — checked by name against the page, plus the non-function productions ofatom, the lexer rules (NUMBER,BOOLEAN,VARIABLE,COMMENT,NEWLINE) and the token insertion inCore/Parser.cs. That left 20 function names and 15 features undocumented.Added
sum,productexp,log10,log2logwith one argument, which is base 10a-spellings of all six, and the five refusals beyondarcsinh(|x|)True,FalseStringizeprints//,/* */, newlines.5,1.,3i,1.5e3iExplicitParsingOnlysumandproductget their own section, since getting the argument order wrong is the difference between 55 and something else, and since the declared name shadows what it would otherwise mean:sum(i, i, 1, 10)is 55,sum(sqrt(-1) * i, i, 1, 10)is 55i,product(pi, pi, 1, 4)is 24, and a name that outlives its operator comes back aspi_1.Corrected
The variable-name rule, which said "a letter or
_followed by letters, digits or_". The grammar isletter+ ('_' (letter|digit)+)?and disagrees four ways:sinxiss * i * n * x— a third wrong statement, not in the roadmap's count. It is false: the lexer takes the longest match, sosinxis one variable namedsinx. Nothing in this language produces a product of one-letter names."Juxtaposition is multiplication" is half of it, and the missing half is the surprising one. A number, name or
)followed by a number inserts^:Already fixed, so left alone: item 74's other statement — everything but
^groups to the left — was corrected by #1009 when the printer was fixed. The roadmap entry predates that merge.Recorded rather than fixed
Stringizedrops a codomain, sodomain(x, ZZ)prints asx(Stringize drops a node's Codomain, so domain(x, ZZ) prints as x and does not round trip #1022).//comment that ends the input is a parse error, becauseCOMMENTrequires the newline. Filed as A // comment that ends the input is a parse error, because the lexer rule requires the newline #1039 from this work — a grammar change means regenerating the ANTLR parser and is its own change.[]reachesMathS.Vector'sIndexOutOfRangeExceptionthrough the parser and not only through the API; noted on SumAll, MultiplyAll and ToVector throw an internal bug exception on an empty sequence, where ToSet and ToPiecewise answer #1028 rather than filed again.Measured
Sources/Tests/UnitTests/Convenience/SyntaxDocumentedTest.csruns every example the page prints — the precedence table row by row against explicitly bracketed forms, the four shapes that are not names, both juxtaposition rules,ExplicitParsingOnly, the number and boolean spellings, comments, the inverse hyperbolic table, andsum/productincluding what the declared name shadows. It compares entities, never printed forms.No library code is touched, so no answer changes and
BREAKING-CHANGES.mdis owed nothing. The new test file carries the default 2019-2022 header —Sources/.editorconfigpins it and belongs to other pull requests this cycle, so no 2026 scope was added there.🤖 Generated with Claude Code
https://claude.ai/code/session_01Bjumi5K7fg8yx6UK1mZTQd