lemmascript 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -66,7 +66,7 @@ function tokenize(input) {
66
66
  if (matched)
67
67
  continue;
68
68
  const ch = input[i];
69
- if ("+-*/%><!".includes(ch)) {
69
+ if ("+-*/%><!?".includes(ch)) {
70
70
  tokens.push({ type: "op", value: ch });
71
71
  }
72
72
  else if ("()[],:.{}".includes(ch)) {
@@ -109,11 +109,21 @@ class Parser {
109
109
  return r;
110
110
  }
111
111
  parseImplies() {
112
- const left = this.parseOr();
112
+ const left = this.parseTernary();
113
113
  if (this.match("op", "==>"))
114
114
  return { kind: "binop", op: "==>", left, right: this.parseImplies() };
115
115
  return left;
116
116
  }
117
+ parseTernary() {
118
+ const cond = this.parseOr();
119
+ if (this.match("op", "?")) {
120
+ const then_ = this.parseImplies();
121
+ this.expect("punc", ":");
122
+ const else_ = this.parseImplies();
123
+ return { kind: "conditional", cond, then: then_, else: else_ };
124
+ }
125
+ return cond;
126
+ }
117
127
  parseOr() {
118
128
  let left = this.parseAnd();
119
129
  while (this.match("op", "||"))