Automatic parentheses

From Fōrmulæ dictionary
Jump to: navigation, search

In Fōrmulæ, parentheses are automatically drawn where they are necessary.

Parentheses are never drawn by an expression visualizer around itself. These are always drawn by an expression visualizer around its children expressions. It is, the parent draws parentheses around the children.

Parentheses categories

A parent visualizer determinates if an specific child needs parentheses according to certain generic characteristics of that child called Parentheses categories. An specific visualization can belong to zero, one or more Parentheses categories.

Currently there are the following categories:

Category Definition Examples
Parentheses as operator This visualization should be shown between parentheses if it participates as an operand of a infix operation An Math.Arithmetic.Addition infix visualization belongs to this category. When participates as a factor of a Math.Arithmetic.Multiplication infix visualization, the parent (multiplication) shows the child (the addition) between parentheses, such like
An Math.Arithmetic.Addition visualization belongs to this category. When participates as the argument of a Math.Arithmetic.Negative visualization, the parent -nagative- show show the child (the addition) between parentheses, such like
Parentheses as super/subscripted This visualization should be shown between parentheses if it is subscripted or superscripted An Math.Arithmetic.Addition infix visualization belongs to this category. When participates as the base of a Math.Arithmetic.Exponentiation visualization, the parent (exponentiation) shows the child (the addition) between parentheses, such like
An Math.Arithmetic.Negative visualization belongs to this category. When participates as the base of a Math.Arithmetic.Exponentiation visualization, the parent (exponentiation) shows show the child (the negative expression) between parentheses, such like
An Math.Arithmetic.Division visualization belongs to this category. When participates as the base of a Math.Arithmetic.Exponentiation visualization, the parent (exponentiation) show the child (the division) between parentheses, such like

A visualizer expression has the option of ignoring the parentheses category of one or several of its children, basically because this method of visualization does not introduce ambiguity when showing its children that can be solved by the use of parentheses.

As an example, the following Math.Arithmetic.SquareRoot visualization does not show its unique child between parentheses, even when it is a Math.Arithmetic.Addition visualization that belongs to several Parentheses categories:

Parentheses awareness

If a visualizar expression take in account the parentheses category of one or several of its children, it is said that it awares of that or those categories.