HS: ask/answer + prompt/confirm mock (+4 tests)
Wire up the `ask` and `answer` commands end-to-end:
- tokenizer.sx: register `ask` and `answer` as hs-keywords.
- parser.sx: cmd-kw? gains both; parse-cmd dispatches to new
parse-ask-cmd (emits `(ask MSG)`) and parse-answer-cmd, which
reads `answer MSG [with YES or NO]`. The with/or pair reads
yes/no via parse-atom — parse-expr would collapse
`"Yes" or "No"` into `(or "Yes" "No")` before match-kw "or"
could fire. The no-`with` form emits `(answer-alert MSG)`.
- compiler.sx: three new cond branches (ask, answer, answer-alert)
compile to a let that binds __hs-a, sets `the-result` and `it`,
and returns the value — so `then put it into ...` works.
- runtime.sx: hs-ask / hs-answer / hs-answer-alert call
window.prompt / confirm / alert via host-call + host-global.
- tests/hs-run-filtered.js: test-name-keyed globalThis.{alert,
confirm,prompt}; __currentHsTestName is updated before each
test. Host-set! for innerHTML/textContent now coerces JS
null → "null" (browser behaviour) so `prompt → null` →
`put it into #out` renders literal text "null", which the
fourth test depends on.
Suite hs-upstream-askAnswer: 1/5 -> 5/5.
Smoke 0-195: 166/195 -> 170/195.
This commit is contained in:
@@ -1757,6 +1757,39 @@
|
||||
(list (quote hs-settle) (quote me)))
|
||||
((= head (quote go))
|
||||
(list (quote hs-navigate!) (hs-to-sx (nth ast 1))))
|
||||
((= head (quote ask))
|
||||
(let
|
||||
((val (list (quote hs-ask) (hs-to-sx (nth ast 1)))))
|
||||
(list
|
||||
(quote let)
|
||||
(list (list (quote __hs-a) val))
|
||||
(list
|
||||
(quote begin)
|
||||
(list (quote set!) (quote the-result) (quote __hs-a))
|
||||
(list (quote set!) (quote it) (quote __hs-a))
|
||||
(quote __hs-a)))))
|
||||
((= head (quote answer))
|
||||
(let
|
||||
((val (list (quote hs-answer) (hs-to-sx (nth ast 1)) (hs-to-sx (nth ast 2)) (hs-to-sx (nth ast 3)))))
|
||||
(list
|
||||
(quote let)
|
||||
(list (list (quote __hs-a) val))
|
||||
(list
|
||||
(quote begin)
|
||||
(list (quote set!) (quote the-result) (quote __hs-a))
|
||||
(list (quote set!) (quote it) (quote __hs-a))
|
||||
(quote __hs-a)))))
|
||||
((= head (quote answer-alert))
|
||||
(let
|
||||
((val (list (quote hs-answer-alert) (hs-to-sx (nth ast 1)))))
|
||||
(list
|
||||
(quote let)
|
||||
(list (list (quote __hs-a) val))
|
||||
(list
|
||||
(quote begin)
|
||||
(list (quote set!) (quote the-result) (quote __hs-a))
|
||||
(list (quote set!) (quote it) (quote __hs-a))
|
||||
(quote __hs-a)))))
|
||||
((= head (quote __get-cmd))
|
||||
(let
|
||||
((val (hs-to-sx (nth ast 1))))
|
||||
|
||||
Reference in New Issue
Block a user