⚠️ DRAFT
ULM is a language for describing both the semantics and presentation of mathematical expressions.
Here is a simple expression written in ULMScript:
Example № 1+(2, 2)
That’s just 2 + 2
.
Here is a more complicated expression:
Example № 2=(
-(
245.5,
÷(11, 2, { division-style: "fraction" })
),
*(
+(100, 20),
2,
{ color: "blue" }
)
)
Which could be displayed like this:
- | + |
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | _ |
[
and ]
) are not currently used in the language, but have been reserved to represent lists in the future." | \ | / | b | f | n | r | t |
Example № 3// This is a comment! 😃
A positive integer ({ 1, 2, 3, … }
).
An natural number literal must always have an n
suffix:
Example № 41n
Example № 534n
Underscores may be used to make large numbers easier to read:
Example № 66_935n
Zero is not a natural number:
Counter Example № 70n
Natural number literals cannot have leading underscores:
Counter Example № 8_42n
An integer number literal must always have an i
suffix:
Example № 90i
Example № 1052i
Example № 11500i
Counter Example № 12-2
Underscores may be used to make large numbers easier to read:
Example № 135_000i
Integer number literal can be prefixed with either a positive or negative sign:
Example № 14-0i
Example № 15-52i
Example № 16-500i
Example № 17-5_000i
Example № 18+0i
Example № 19+52i
Example № 20+500i
Example № 21+5_000i
Integer number literals cannot have leading zeros or underscores:
Counter Example № 22042i
Counter Example № 23-042i
Counter Example № 24_42i
Example № 250
Example № 2612
Example № 270.4
Example № 280.50
Example № 2940.145
Example № 305_542.1_11
Example № 310/1
Example № 320/1_000
Example № 331/1
Example № 341_243/1000
Example № 35-0
Example № 36-12
Example № 37-0.4
Example № 38-0.50
Example № 39-40.145
Example № 40-5_542.1_11
Example № 41-0/1
Example № 42-0/1_000
Example № 43-1/1
Example № 44-1_243/1000
Example № 45+0
Example № 46+12
Example № 47+0.4
Example № 48+0.50
Example № 49+40.145
Example № 50+5_542.1_11
Example № 51+0/1
Example № 52+0/1_000
Example № 53+1/1
Example № 54+1_243/1000
Example № 55"This is a string"
TRUE
and FALSE
identifiers are not currently used in the language, but have been reserved to represent boolean literals in the future.Example № 56+
Example № 57^
Example № 58**
Example № 59atan2
Example № 60PascalCase
Example № 61snake_case
Example № 62-kebab-case-
Example № 63__this_is_valid!__
This is not a comment because there is no separator between foo
and //
:
Example № 64foo//bar
Comment:
Example № 65// Hello, this is a comment.
Separator:
Example № 66,
;
Example № 675n
Example № 68-48i
Example № 69-48/7
Example № 700.53
Example № 71"Hello"
Example № 72foo:5n
Example № 73foo : 5n
Example № 745n
Example № 75foo()
Example № 76{ color: "red" }
Example № 77{ color: "red"; number-format: "fraction"; }
Example № 78foo()
Example № 79foo(bar())
Example № 80foo(bar() abc:"xyz")
Example № 81foo(bar() abc:"xyz" {color:"red"})
Example № 82foo ( bar() abc:"xyz" {color:"red"} )
Example № 83foo(bar(), abc: "xyz", { color: "red" })
Example № 84// Foo
foo()
// Bar
bar()
A group has no semantic meaning, but can be used to apply presentation rules to expressions or values.
Example № 85Group(25, +(1, 16))
Example № 86g(25, +(1, 16), { color: "red" })
Example № 87AmbiguousSymbol("x")
Example № 88$("x")
Example № 89=($("x"), 25) // x = 25
Example № 90AmbiguousPlaceholder()
Example № 91?({ color: "red" })
Example № 92AmbiguousAdditionOperation(11, 31)
Example № 93+(5, 5, { color: "red" })
color
("red"
or "#ff00ff"
)division-format
("fraction"
or "obelus"
or "ratio"
)number-format
("decimal"
or "fraction"
)number-decimal-places
(3
)number-decimal-rounding
("nearest"
or "down"
or "up"
)