Skip to content

Commit

Permalink
FEAT: allows Parse callbacks to be defined in objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
dockimbel committed Jan 14, 2020
1 parent 8f3b283 commit e4d17f8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion runtime/parse.reds
Original file line number Diff line number Diff line change
Expand Up @@ -674,11 +674,18 @@ parser: context [
len [integer!]
saved [red-value!]
res [red-value!]
int [red-integer!]
more [series!]
ctx [node!]
][
PARSE_SAVE_SERIES
saved: stack/top
stack/top: stack/top + 1 ;-- keep last value from paren expression

more: as series! fun/more/value
int: as red-integer! more/offset + 4
ctx: either TYPE_OF(int) = TYPE_INTEGER [as node! int/value][global-ctx]

stack/mark-func words/_body fun/ctx ;@@ find something more adequate
stack/push as red-value! event
logic/push match?
Expand All @@ -687,7 +694,7 @@ parser: context [
stack/push as red-value! rules
if positive? locals [_function/init-locals 1 + locals] ;-- +1 for /local refinement

catch RED_THROWN_ERROR [_function/call fun global-ctx] ;FIXME: hardcoded origin context
catch RED_THROWN_ERROR [_function/call fun ctx]

PARSE_RESTORE_SERIES ;-- restore localy saved series/head first
if system/thrown <> 0 [reset saved? re-throw]
Expand Down

0 comments on commit e4d17f8

Please sign in to comment.