Collect all declared variables at start of program execution
This commit is contained in:
@@ -20,10 +20,8 @@ Syntax Exp:exp ::= id
|
||||
| exp '>=' exp
|
||||
| exp '>' exp
|
||||
|
||||
Syntax ParamValues: paramvalues ::= exp (',' paramvalues)?
|
||||
|
||||
Semantics eval-exp[[ _:exp ]] : => values
|
||||
Rule eval-exp[[ Id ]] = assigned(bound(id[[ Id ]]))
|
||||
Semantics eval-exp[[ _:exp ]] : =>values
|
||||
Rule eval-exp[[ Id ]] = assigned bound id[[ Id ]]
|
||||
Rule eval-exp[[ Int ]] = int-val[[ Int ]]
|
||||
Rule eval-exp[[ 'true' ]] = true
|
||||
Rule eval-exp[[ 'false' ]] = false
|
||||
@@ -42,18 +40,28 @@ Rule eval-exp[[ Exp1 '<' Exp2 ]] = is-less(eval-exp[[ Exp1 ]], eval-exp[[ Exp2]]
|
||||
Rule eval-exp[[ Id '(' ParamValues? ')' ]] = handle-return apply(bound id[[ Id ]], eval-params[[ ParamValues? ]])
|
||||
Rule eval-exp[[ '(' Exp ')' ]] = eval-exp[[ Exp ]]
|
||||
|
||||
|
||||
## Handling expressions for function calls
|
||||
|
||||
Syntax ParamValues: paramvalues ::= exp (',' paramvalues)?
|
||||
|
||||
Semantics eval-params[[ _:paramvalues? ]] : lists(values)
|
||||
Rule eval-params[[ ]] = list()
|
||||
Rule eval-params[[ Exp ]] = list(eval-exp[[ Exp ]])
|
||||
Rule eval-params[[ Exp ',' ParamValues ]] = cons(eval-exp[[ Exp ]], eval-params[[ ParamValues ]])
|
||||
|
||||
|
||||
|
||||
## Ids
|
||||
Lexis Id:id ::= ('a'-'z' | 'A'-'Z') ('a'-'z' | 'A'-'Z' | '0'-'9')*
|
||||
|
||||
Semantics id[[ _:id ]] : identifiers
|
||||
Rule id[[ Id ]] = \"Id\"
|
||||
|
||||
|
||||
|
||||
## Integers and decimals
|
||||
|
||||
Syntax Int:int ::= '0' | ('-'?_decimal)
|
||||
|
||||
Semantics int-val[[ _:int ]] : ints
|
||||
@@ -71,4 +79,24 @@ Rule dec-val[[ Dec ]] = decimal-natural(\"Dec\")
|
||||
|
||||
|
||||
|
||||
//Semantics eval-exp[[ _:exp ]] : => values
|
||||
//
|
||||
//Rule eval-exp[[ Id ]] = assigned bound id[[ Id ]]
|
||||
//
|
||||
//Rule eval-exp[[ Int ]] = int-val[[ Int ]]
|
||||
//
|
||||
//Rule eval-exp[[ Exp1 '+' Exp2 ]] =
|
||||
// int-add(eval-exp[[ Exp1 ]], eval-exp[[ Exp2 ]])
|
||||
//
|
||||
//Rule eval-exp[[ Exp1 '/' Exp2 ]] =
|
||||
// checked int-div(eval-exp[[ Exp1 ]], eval-exp[[ Exp2 ]])
|
||||
//
|
||||
//Rule eval-exp[[ Id '(' ParamValues? ')' ]] =
|
||||
// handle-return apply(bound id[[ Id ]], eval-params[[ ParamValues? ]])
|
||||
//
|
||||
//Rule eval-exp[[ '(' Exp ')' ]] = eval-exp[[ Exp ]]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user