Mercurial > hg > Members > kono > compiler-examples
view s-code-print.c @ 27:c4e2ca100ab9 default tip
llvm worked
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 25 Oct 2024 17:10:11 +0900 |
parents | 6bf66c125dbc |
children |
line wrap: on
line source
/* Very Simple Code Generator for Reverse Polish Notation $Id$ */ #include "s-compile.h" char *comments = "#####"; void emit_push() { } void emit_compare() { printf("> "); } void emit_store(assign) int assign; { printf("->%c ",assign+'a'); } char *opcode[] = { "", "-", "+", "*", "/", "", "", "", "", "-(r)", "/(r)", }; void emit_calc(enum opcode op) { printf("%s ",opcode[op]); } void emit_value(d) int d; { printf("%d ",d); } void emit_load(d) int d; { printf("%c\n",d+'a'); } void emit_comment() { } void emit_print() { printf("print\n"); } void emit_intro() { } void emit_ending() { } /* end */