1 // ecas -- By Joey Adams
7 text = "Simple Parser";
8 background = activeBorder;
14 anchor = { horz = -3, vert = -4 };
22 bool OnKeyHit(Key key, unichar ch)
30 void DoParse(bool simplify) {
32 CASDictionary dict {};
36 s = {editBox=outputTree};
37 if (expr.FromString(inputString.contents, dict)) {
38 statusLabel.SetText("Parse successful");
43 statusLabel.SetText("Invalid expression");
44 expr.DebugPrint(s, dict, 0, null);
45 s.Printf("\nCopy:\n");
46 exprCopy = expr.Copy(null);
48 exprCopy.DebugPrint(s, dict, 0, null);
56 this, text = "Parse", size = { 75, 30 }, position = { 10, 40 };
58 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
66 this, text = "Simplify", size = { 75, 30 }, position = { 90, 40 };
68 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
75 bool TypeButton(Button button, int x, int y, Modifiers mods) {
76 inputString.Activate();
77 inputString.Deselect();
78 inputString.AddS(button.text);
79 inputString.Update(null);
81 Label statusLabel { this, size = { 274, 21 }, position = { 250, 45 } };
82 Button ebutton { this, text = constant_string[e], NotifyClicked = TypeButton, size = { 20, 20 }, position = { 170, 45 } };
83 Button ibutton { this, text = constant_string[i], NotifyClicked = TypeButton, size = { 20, 20 }, position = { 195, 45 } };
84 Button pibutton { this, text = constant_string[pi], NotifyClicked = TypeButton, size = { 20, 20 }, position = { 220, 45 } };
85 EditBox outputTree { this, font = { "Courier New", 10 }, size = { 286, 219 }, position = { 10, 80 }, hasHorzScroll = true, true, readOnly = true, true };
86 EditBox inputString { this, text = "inputString", size = { 350, 19 }, position = { 10, 10 } };
88 void OnResize(int width, int height)
90 inputString.size.w = clientSize.w-20;
91 //parseButton.position.x = (clientSize.w-parseButton.size.w)/2;
92 statusLabel.size.w = clientSize.w-statusLabel.position.x-10;
93 outputTree.size.w = clientSize.w-20;
94 outputTree.size.h = clientSize.h-outputTree.position.y-10;