Compiler/AST interpreter: Difference between revisions
Content added Content deleted
m (J: include an implementation of 'error' (so that an error would display the error message before erroring out)) |
(J: Putc becomes Prtc (see syntax analyzer talk page)) |
||
Line 1,701: | Line 1,701: | ||
Implementation: |
Implementation: |
||
<lang J> |
<lang J>outbuf=: '' |
||
outbuf=: '' |
|||
emit=:{{ |
emit=:{{ |
||
outbuf=: outbuf,y |
outbuf=: outbuf,y |
||
Line 1,758: | Line 1,757: | ||
case.'If'do.if.interp V do.interp left W else.interp right W end.'' |
case.'If'do.if.interp V do.interp left W else.interp right W end.'' |
||
case.'While'do.while.interp V do.interp W end.'' |
case.'While'do.while.interp V do.interp W end.'' |
||
case.' |
case.'Prtc'do.emit u:interp V |
||
case.'Prti'do.emit rplc&'_-'":interp V |
case.'Prti'do.emit rplc&'_-'":interp V |
||
case.'Prts'do.emit interp V |
case.'Prts'do.emit interp V |
||
Line 1,766: | Line 1,765: | ||
'' |
'' |
||
case.do.error'unknown node type ',typ y |
case.do.error'unknown node type ',typ y |
||
end. |
|||
}} |
|||
ast_interp=: {{ |
|||
outbuf=:'' |
|||
interp load_ast y |
|||
if.#outbuf do. |
|||
echo outbuf |
|||
outbuf=:'' |
|||
end. |
end. |
||
}} |
}} |