all will be int

This commit is contained in:
Peter
2023-12-10 16:51:49 +01:00
parent 165be5cfdb
commit c4f9bbcbfa
7 changed files with 27 additions and 64 deletions

View File

@@ -35,10 +35,8 @@ context-free syntax // Language
"{" L-statement* "}"
L-statement.L-statement--R-print-LPAREN-L-exp-RPAREN-SEMI =
"print" "(" L-exp ")" ";"
L-statement.L-statement--L-type-L-id-SEMI =
L-type L-id ";"
L-statement.L-statement--L-type-L-id-EQUALS-L-exp-SEMI =
L-type L-id "=" L-exp ";"
L-statement.L-statement--L-id-SEMI =
L-id ";"
L-statement.L-statement--L-id-EQUALS-L-exp-SEMI =
L-id "=" L-exp ";"
L-statement.L-statement--R-return-L-exp-Q-SEMI =
@@ -46,13 +44,6 @@ context-free syntax // Language
L-statement.L-statement--R-fun-L-id-LPAREN-RPAREN-LBRACE-L-statement-S-RBRACE =
"fun" L-id "(" ")" "{" L-statement* "}"
L-type.L-type--R-int =
"int"
L-type.L-type--R-bool =
"bool"
L-type.L-type--L-id =
L-id
// # Handling variable declarations
@@ -93,10 +84,6 @@ variables // Meta-variables
L-statement+ = "(:Stmt" [1-9]? "+:)" {prefer}
L-statement* = "..." [1-9]? {prefer}
L-statement* = "..." [1-9]? {prefer}
L-type = "(:Typ" [1-9]? ":)" {prefer}
L-type? = "(:Typ" [1-9]? "?:)" {prefer}
L-type* = "(:Typ" [1-9]? "*:)" {prefer}
L-type+ = "(:Typ" [1-9]? "+:)" {prefer}
// # Handling variable declarations

File diff suppressed because one or more lines are too long

View File

@@ -24,12 +24,9 @@ to-funcons:
|[ execute[: print((:Exp:)); :] ]| ->
|[ print eval-exp[: (:Exp:) :] ]|
to-funcons:
|[ execute[: (:Typ:)(:Id:); :] ]| ->
|[ null ]|
to-funcons:
|[ execute[: (:Typ:)(:Id:)=(:Exp:); :] ]| ->
|[ execute[: (:Id:); :] ]| ->
|[ assign (bound id[: (:Id:) :],
eval-exp[: (:Exp:) :]) ]|
0) ]|
to-funcons:
|[ execute[: (:Id:)=(:Exp:); :] ]| ->
|[ assign (bound id[: (:Id:) :],
@@ -55,18 +52,16 @@ to-funcons:
to-funcons:
|[ collect-declared-vars[: (:Typ:)(:Id:)=(:Exp:); :] ]| ->
|[ bind (\"(:Id:)\",
allocate-initialised-variable (integers,
0)) ]|
|[ collect-declared-vars[: (:Id:)=(:Exp:); :] ]| ->
|[ bind (id[: (:Id:) :],
allocate-variable (integers)) ]|
to-funcons:
|[ collect-declared-vars[: (:Typ:)(:Id:); :] ]| ->
|[ bind (\"(:Id:)\",
allocate-initialised-variable (integers,
0)) ]|
|[ collect-declared-vars[: (:Id:); :] ]| ->
|[ bind (id[: (:Id:) :],
allocate-variable (integers)) ]|
to-funcons:
|[ collect-declared-vars[: fun(:Id:)(){(:Stmt*:)} :] ]| ->
|[ bind (\"(:Id:)\",
|[ bind (id[: (:Id:) :],
function abstraction (execute[: {(:Stmt*:)} :])) ]|
to-funcons:
|[ collect-declared-vars[: :] ]| ->