Look up words in the dictionary.
If they are not built-in, which means you can't "shadow" built-ins with "inscribe", which may or may not turn out to be what we want?
This commit is contained in:
parent
4acdec71ed
commit
edfd7c526f
|
|
@ -1,7 +1,7 @@
|
||||||
module Joy exposing (doit, JoyDict)
|
module Joy exposing (doit, JoyDict)
|
||||||
|
|
||||||
import Bitwise
|
import Bitwise
|
||||||
import Dict exposing (Dict)
|
import Dict exposing (Dict, get)
|
||||||
import Result exposing (andThen)
|
import Result exposing (andThen)
|
||||||
import String exposing (replace, words)
|
import String exposing (replace, words)
|
||||||
|
|
||||||
|
|
@ -42,7 +42,11 @@ joy_eval symbol stack expression dict =
|
||||||
Err msg ->
|
Err msg ->
|
||||||
if "Unknown word." == msg then
|
if "Unknown word." == msg then
|
||||||
-- Look up word in dictionary.
|
-- Look up word in dictionary.
|
||||||
Err ("Unknown word: " ++ symbol)
|
case get symbol dict of
|
||||||
|
Just definition ->
|
||||||
|
Ok (stack, definition ++ expression, dict)
|
||||||
|
Nothing ->
|
||||||
|
Err ("Unknown word: " ++ symbol)
|
||||||
else
|
else
|
||||||
Err msg
|
Err msg
|
||||||
Ok (stack0, expression0) -> Ok (stack0, expression0, dict)
|
Ok (stack0, expression0) -> Ok (stack0, expression0, dict)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue