Collect all declared variables at start of program execution

This commit is contained in:
Peter
2024-04-16 08:12:52 +02:00
parent cb7f6f8e5d
commit f5f5626521
21 changed files with 299 additions and 284 deletions

View File

@@ -11,7 +11,19 @@ lexical syntax // Language
// # 1: General expressions
// ## Handling expressions for function calls
// ## Ids
LEX-id = ( [a-z] | [A-Z] ) ( [a-z] | [A-Z] | [0-9] )*
// ## Integers and decimals
LEX-DASH = "-"
LEX-decimal = [1-9] ( [0-9] )*
@@ -20,6 +32,18 @@ syntax // Language
// # 1: General expressions
// ## Handling expressions for function calls
// ## Ids
// ## Integers and decimals
L-int-CF.L-int--R-0 =
"0"
L-int-CF.L-int--C-DASH-Q-L-decimal-D =
@@ -71,6 +95,10 @@ context-free syntax // Language
L-exp.L-exp--L-exp-GREATER-L-exp =
L-exp ">" L-exp
// ## Handling expressions for function calls
L-paramvalues.L-paramvalues--L-exp-C-COMMA-L-paramvalues-D-Q =
L-exp L-COMMA-L-paramvalues?
@@ -78,8 +106,16 @@ context-free syntax // Language
"," L-paramvalues
// ## Ids
L-id.LEX-id =
LEX-id
// ## Integers and decimals
L-decimal.LEX-decimal =
LEX-decimal
@@ -90,11 +126,23 @@ context-free syntax // Semantics
FCT.T-eval-exp =
"eval-exp" "[:" L-exp ":]"
// ## Handling expressions for function calls
FCT.T-eval-params =
"eval-params" "[:" L-paramvalues? ":]"
// ## Ids
FCT-Quoted.L-id = L-id
FCT.T-id =
"id" "[:" L-id ":]"
// ## Integers and decimals
FCT.T-int-val =
"int-val" "[:" L-int ":]"
FCT-Quoted.L-decimal = L-decimal
@@ -107,6 +155,18 @@ context-free syntax // Desugaring
// ## Handling expressions for function calls
// ## Ids
// ## Integers and decimals
variables // Meta-variables
// # 1: General expressions
@@ -116,14 +176,26 @@ variables // Meta-variables
L-exp? = "(:Exp" [1-9]? "?:)" {prefer}
L-exp* = "(:Exp" [1-9]? "*:)" {prefer}
L-exp+ = "(:Exp" [1-9]? "+:)" {prefer}
// ## Handling expressions for function calls
L-paramvalues = "(:ParamValues" [1-9]? ":)" {prefer}
L-paramvalues? = "(:ParamValues" [1-9]? "?:)" {prefer}
L-paramvalues* = "(:ParamValues" [1-9]? "*:)" {prefer}
L-paramvalues+ = "(:ParamValues" [1-9]? "+:)" {prefer}
// ## Ids
L-id = "(:Id" [1-9]? ":)" {prefer}
L-id? = "(:Id" [1-9]? "?:)" {prefer}
L-id* = "(:Id" [1-9]? "*:)" {prefer}
L-id+ = "(:Id" [1-9]? "+:)" {prefer}
// ## Integers and decimals
L-int = "(:Int" [1-9]? ":)" {prefer}
L-int? = "(:Int" [1-9]? "?:)" {prefer}
L-int* = "(:Int" [1-9]? "*:)" {prefer}
@@ -139,5 +211,17 @@ variables // Meta-variables
// ## Handling expressions for function calls
// ## Ids
// ## Integers and decimals
sorts // ASTs
T-start

View File

@@ -45,13 +45,5 @@ variables // Meta-variables
lexical restrictions
LEX-id -/- [A-Za-z0-9]
context-free syntax
L-exp.L-exp--L-exp-PLUS-L-exp =
L-exp "+" L-exp
{assoc}
L-exp.L-exp--L-exp-AMPERSAND-AMPERSAND-L-exp =
L-exp "&&" L-exp
{assoc}
sorts // ASTs
T-start

View File

@@ -44,8 +44,8 @@ context-free syntax // Language
L-statement.L-statement--L-block =
L-block
L-statement.L-statement--R-print-LPAREN-L-exp-RPAREN-SEMI =
"print" "(" L-exp ")" ";"
L-statement.L-statement--R-print-L-exp-SEMI =
"print" L-exp ";"
L-statement.L-statement--R-int-L-id-SEMI =
"int" L-id ";"
L-statement.L-statement--L-id-EQUALS-L-exp-SEMI =
@@ -60,8 +60,6 @@ context-free syntax // Language
"if" "(" L-exp ")" L-block L-R-else-L-block?
L-statement.L-statement--R-while-LPAREN-L-exp-RPAREN-L-block =
"while" "(" L-exp ")" L-block
L-statement.L-statement--R-for-LPAREN-R-int-L-id-EQUALS-L-exp-SEMI-L-exp-RPAREN-L-block =
"for" "(" "int" L-id "=" L-exp ";" L-exp ")" L-block
L-R-else-L-block.L-R-else-L-block--R-else-L-block =
"else" L-block