diff options
author | Yuqian Yang <crupest@crupest.life> | 2025-02-28 23:13:39 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-02-28 23:13:39 +0800 |
commit | 99e2e923d0c77b02f3fb4ff648ea916954868606 (patch) | |
tree | ec8e03f6f2cd1ce43990fb4fe6cd631967d0237e /works/life/compile-principle-experiment/4/syn.y | |
parent | 1cee979f5d36b311a03cc7397a036ba11caf3d42 (diff) | |
download | crupest-99e2e923d0c77b02f3fb4ff648ea916954868606.tar.gz crupest-99e2e923d0c77b02f3fb4ff648ea916954868606.tar.bz2 crupest-99e2e923d0c77b02f3fb4ff648ea916954868606.zip |
chore(store): move everything to store.
Diffstat (limited to 'works/life/compile-principle-experiment/4/syn.y')
-rw-r--r-- | works/life/compile-principle-experiment/4/syn.y | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/works/life/compile-principle-experiment/4/syn.y b/works/life/compile-principle-experiment/4/syn.y deleted file mode 100644 index ebe113f..0000000 --- a/works/life/compile-principle-experiment/4/syn.y +++ /dev/null @@ -1,39 +0,0 @@ -%{ -#include "main.h" -#include <stdio.h> -#define code2(c1,c2) code(c1); code(c2) -#define code3(c1,c2,c3) code(c1); code(c2); code(c3) -%} -%union { - Symbol *sym; /* symbol table pointer */ - double val; - Inst *inst; /* machine instruction */ -} -%token <sym> NUMBER VAR BLTIN UNDEF -%right '=' -%left '+' '-' -%left '*' '/' -%left UNARYMINUS -%right '^' /* exponentiation */ -%% -list: /* nothing */ - | list '\n' - | list asgn '\n' { code2(mypop, STOP); return 1; } - | list expr '\n' { code2(print, STOP); return 1; } - | list error '\n' { yyerrok; } - ; -asgn: VAR '=' expr { code3(varpush,(Inst)$1,assign); } - ; -expr: NUMBER { code2(constpush, (Inst)$1); } - | VAR { code3(varpush, (Inst)$1, eval); } - | asgn - | BLTIN '(' expr ')' { code2(bltin, (Inst)$1->value.ptr); } - | '(' expr ')' - | expr '+' expr { code(add); } - | expr '-' expr { code(sub); } - | expr '*' expr { code(mul); } - | expr '/' expr { code(mydiv); } - | expr '^' expr { code(power); } - | '-' expr %prec UNARYMINUS { code(negate); } - ; -%% |