first usable version

This commit is contained in:
Peter
2023-11-09 09:46:07 +01:00
parent 70b3e9c722
commit 6b5ab857cb
22 changed files with 675 additions and 153 deletions

View File

@@ -7,48 +7,26 @@ imports
pp/IBAF-pp
imports
cbs-gen/IBAF-Expressions
cbs-gen/IBAF-Statements
// Language "IBAFlang"
rules
to-funcons:
|[ start[: (:AExp:) :] ]| ->
|[ initialise-binding finalise-failing eval-arith[: (:AExp:) :] ]|
// #1 Arithmetic expressions
to-funcons:
|[ eval-arith[: (:N:) :] ]| ->
|[ int-val[: (:N:) :] ]|
to-funcons:
|[ eval-arith[: (:I:) :] ]| ->
|[ assigned (bound (id[: (:I:) :])) ]|
to-funcons:
|[ eval-arith[: (:AExp1:)+(:AExp2:) :] ]| ->
|[ integer-add (eval-arith[: (:AExp1:) :],
eval-arith[: (:AExp2:) :]) ]|
to-funcons:
|[ eval-arith[: (:AExp1:)/(:AExp2:) :] ]| ->
|[ checked integer-divide (eval-arith[: (:AExp1:) :],
eval-arith[: (:AExp2:) :]) ]|
to-funcons:
|[ eval-arith[: ((:AExp:)) :] ]| ->
|[ eval-arith[: (:AExp:) :] ]|
to-funcons-lex:
FCTDoubleQuoted(L-decimal(LEX-decimal(str))) ->
FCTString(<double-quote> str)
to-funcons:
|[ int-val[: (:D:) :] ]| ->
|[ decimal-natural (\"(:D:)\") ]|
to-funcons:
|[ int-val[: -(:D:) :] ]| ->
|[ integer-negate (int-val[: (:D:) :]) ]|
to-funcons-lex:
FCTDoubleQuoted(L-id(LEX-id(str))) ->
FCTString(<double-quote> str)
to-funcons:
|[ id[: (:I:) :] ]| ->
|[ \"(:I:)\" ]|
|[ start[: (:Pgm:) :] ]| ->
|[ initialise-binding finalise-failing run[: (:Pgm:) :] ]|
to-funcons:
|[ run[: int(:IL:);(:Stmt:) :] ]| ->
|[ scope (collateral (declare-int-vars[: (:IL:) :]),
execute[: (:Stmt:) :]) ]|
to-funcons:
|[ declare-int-vars[: (:Id:) :] ]| ->
|[ bind (\"(:Id:)\",
allocate-initialised-variable (integers,
0)) ]|
to-funcons:
|[ declare-int-vars[: (:Id:),(:IL:) :] ]| ->
|[ declare-int-vars[: (:Id:) :],
declare-int-vars[: (:IL:) :] ]|