git @ Cat's Eye Technologies Tamsin / ee242d6
Hey, I fixed while/asteration! Cool Cat's Eye Technologies 11 years ago
1 changed file(s) with 14 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
182182 + 0 2
183183 = 2
184184
185 Alternatives can select code to be executed, basically.
186
187 | main = set L = nil & (aorb & set L = el(L) | cord & set L = le(L)) &
188 | return L.
189 | aorb = "a" | "b".
190 | cord = "c" | eorf.
191 | eorf = "e" | "f".
192 + e
193 = le(nil)
194
185195 When a production is called, the result that it evaluates to may be stored
186196 in a variable. Variables are local to the production.
187197
438448
439449 For now, let's evaluate some backwards S-expressions.
440450
441 DEFINITELY SOME PROBLEMS WITH `{while}`; we're not restoring context
442 properly when we try/except.
451 Whew, finally got `{}` (while) working correctly. Although, this result isn't
452 quite what I had in mind, but it does parse...
443453
444454 | main = sexp.
445455 | sexp = symbol | list.
449459 | ")" &
450460 | return L.
451461 | symbol = "cons" | "head" | "tail" | "nil" | "a" | "b" | "c".
452 + (cons (a cons(b nil))
453 = cons(a, cons(b, nil))
454
455
456 | main = set L = nil & (aorb & set L = el(L) | cord & set L = le(L)) &
457 | return L.
458 | aorb = "a" | "b".
459 | cord = "c" | eorf.
460 | eorf = "e" | "f".
461 + e
462 = le(nil)
462 + (cons (a (cons b nil)))
463 = cons(cons(cons(nil, cons(b, cons(cons, nil))), cons(a, nil)), cons(cons, nil))
463464
464465 So let's write it in the less intuitive, recursive way:
465466