pub enum Primary {
}Expand description
Represents a primary expression in CalcScript.
Primary expressions extend the concept of Atom by allowing for more complex and ambiguous
expressions that are still self-contained. These extensions include function calls and list
indexing expressions, which can be ambiguous when encountered in isolation.
For example, when trying to parse a Primary, a literal value like abc cannot
automatically be declared a Primary::Literal. Instead, we must parse forward a little more
to see if this is actually calling a function named abc, or indexing into a list named abc,
or neither.
Variants§
Literal(Literal)
A literal value.
Paren(Paren)
A parenthesized expression, such as (1 + 2).
Block(Block)
A blocked expression, such as {1 + 2}.
Sum(Sum)
A sum expression, such as sum n in 1..10 of n.
Product(Product)
A product expression, such as product n in 1..10 of n.
If(If)
An if expression, such as if x > 0 then x else -x.
Loop(Loop)
A loop expression, as in loop { ... }.
While(While)
A while loop expression, as in while x > 0 then { ... }.
For(For)
A for loop expression, as in for i in 0..10 then print(i).
Then(Then)
A then expression, as in then x += 1.
Of(Of)
An of expression, as in of x.
Break(Break)
A break expression, used to exit a loop, optionally with a value.
Continue(Continue)
A continue expression, used to skip the rest of a loop iteration.
Return(Return)
A return expression, as in return x, used to return a value from a function.
Call(Call)
A function call, such as abs(-1).
Index(Index)
List indexing, such as list[0].