AngouriMath

Navigation

← Back to list of members

RationalLiteral​(AngouriMath.​Entity)

 Method (no overloads)

Summary

The Rational that a quotient of two integer literals denotes, or
the node unchanged where it denotes none.

Remarks

A Rational prints as 7/2 and there is no rational literal
in the grammar, so re-parsing gave a Divf and the round trip was not an
identity — the value survived and the node did not. That is
https://github.com/asc-community/AngouriMath/issues/946's neighbour,
https://github.com/asc-community/AngouriMath/issues/873, answered there with "if you
have two integers on both sides of the division, it is reasonable to try to parse it
as a rational".
A quotient that reduces to an integer is left alone, deliberately. Parsing is
not simplification: turning 4/2 into 2 would discard what the caller
wrote, and 4/2 already round-trips, being a Divf before and after.
Only the non-integer case is what a Rational can print as, so only
it is what the round trip needs.
This agrees with the normalisation rather than anticipating it:
Divf(1, 2).InnerSimplified was already a Rational, so the
parser was the one step that disagreed.
The codomain is not read here and not carried. Every caller either has no codomain to
carry — the sweep over a finished tree, where an annotation cannot have reached a
quotient — or is domain(...) itself, which applies its own afterwards.

























Angouri © 2019-2023 · Project's repo · Site's repo · Octicons · Transparency · 4378 pages online