mirror of
https://github.com/Ed94/metadesk.git
synced 2026-08-05 07:08:45 +00:00
[examples] filled out the expression intro example and added commentary
This commit is contained in:
@@ -8,7 +8,32 @@ a: 1;
|
||||
b: 2;
|
||||
c: 3;
|
||||
|
||||
w: 100;
|
||||
// @notes See expr_c_like.mdesk for an explanation of why these have to be
|
||||
// wrapped in parentheses in some cases.
|
||||
l: 5*5 + 1;
|
||||
m: (5*(5 + 1));
|
||||
n: ((5 + 1)*(5 + 1));
|
||||
|
||||
w: 0x100;
|
||||
x: a;
|
||||
y: b + w*a;
|
||||
z: c + w*b + w*w*a;
|
||||
|
||||
// @notes The Metadesk expression parser will automatically accept any set with
|
||||
// delimiters as a leaf. In this example we are doing an extra custom check to
|
||||
// disallow these cases.
|
||||
range: ([0,64));
|
||||
origin: ({50,100});
|
||||
p: (origin + {0, -20});
|
||||
|
||||
// @notes We can also generate errors that point at operators just as easily:
|
||||
`no_&`: 5000 & 0xFF;
|
||||
|
||||
// @notes The expression parser will produce an error if the series of nodes
|
||||
// that form the expression cannot form a complete expression.
|
||||
bad_1: a b c;
|
||||
bad_2: z % b;
|
||||
|
||||
// @notes Surprising things might count as expressions! Anything can be a leaf
|
||||
// so long as it is not recognized as an operator.
|
||||
`good?`: ! + ? * ==;
|
||||
|
||||
Reference in New Issue
Block a user