diff --git a/IBAF-cbs/IBAF/IBAF-Start/IBAF-Expressions.cbs b/IBAF-cbs/IBAF/IBAF-Start/IBAF-Expressions.cbs index fe8fafa..a6d4e74 100644 --- a/IBAF-cbs/IBAF/IBAF-Start/IBAF-Expressions.cbs +++ b/IBAF-cbs/IBAF/IBAF-Start/IBAF-Expressions.cbs @@ -74,29 +74,3 @@ Lexis Dec:decimal ::= '1'-'9'('0'-'9')* Semantics dec-val[[ _:decimal ]] : ints 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 ]] - - - - - diff --git a/IBAF-cbs/IBAF/IBAF-Start/IBAF-Start.cbs b/IBAF-cbs/IBAF/IBAF-Start/IBAF-Start.cbs index bfcb63d..8eecbf2 100644 --- a/IBAF-cbs/IBAF/IBAF-Start/IBAF-Start.cbs +++ b/IBAF-cbs/IBAF/IBAF-Start/IBAF-Start.cbs @@ -2,7 +2,7 @@ Language "IBAFlang" Syntax START:start ::= statement* Semantics start[[ _:start ]] : =>null-type -Rule start[[ Stmt* ]] = initialise-binding scope(collateral(collect-declared-vars[[ Stmt* ]]), execute[[ Stmt* ]]) +Rule start[[ Stmt* ]] = initialise-binding execute-block[[ Stmt* ]] diff --git a/IBAF-cbs/IBAF/IBAF-Start/IBAF-Statements.cbs b/IBAF-cbs/IBAF/IBAF-Start/IBAF-Statements.cbs index cf9d12b..aea817b 100644 --- a/IBAF-cbs/IBAF/IBAF-Start/IBAF-Statements.cbs +++ b/IBAF-cbs/IBAF/IBAF-Start/IBAF-Statements.cbs @@ -17,8 +17,8 @@ Syntax Stmt: statement ::= block Syntax Params: params ::= id (',' params)? -Semantics execute[[ Stmt*:statement* ]] : =>null-type +Semantics execute[[ Stmt*:statement* ]] : =>null-type Rule execute[[ Block ]] = execute-block[[ Block ]] Rule execute[[ 'print' Exp ';' ]] = print(to-string eval-exp[[ Exp ]], "\n") Rule execute[[ 'int' Id ';' ]] = initialise-variable(bound id[[ Id ]], 0) @@ -35,9 +35,7 @@ Rule execute[[ ]] = null Rule execute[[ Stmt Stmt+ ]] = sequential(execute[[ Stmt ]], execute[[ Stmt+ ]]) Semantics execute-block[[ _:block ]] : =>null-type -Rule execute-block[[ '{' Stmt* '}' ]] = execute[[ Stmt* ]] - - +Rule execute-block[[ '{' Stmt* '}' ]] = scope(collateral(collect-declared-vars[[ Stmt* ]]), execute[[ Stmt* ]]) @@ -55,7 +53,6 @@ Rule collect-params[[ Id ',' Params ]] = collect-params[[ Id ]], give(checked ta # Handling variable declarations Semantics collect-declared-vars[[ Stmt*:statement* ]] : (=>environments)+ - Rule collect-declared-vars[[ 'int' Id '=' Exp ';' ]] = bind(id[[ Id ]], allocate-variable(integers)) Rule collect-declared-vars[[ 'int' Id ';' ]] = bind(id[[ Id ]], allocate-variable(integers)) Rule collect-declared-vars[[ 'fun' Id '(' Params ')' '{' Stmt* '}' ]] = bind(id[[ Id ]], @@ -67,23 +64,6 @@ Rule collect-declared-vars[[ 'fun' Id '(' Params ')' '{' Stmt* '}' ]] = bind(id[ ) ) -Rule collect-declared-vars[[ '{' Stmt* '}' ]] = collect-declared-vars[[ Stmt* ]] -Rule collect-declared-vars[[ 'if' '(' Exp ')' Block ]] = collect-declared-vars[[ Block ]] -Rule collect-declared-vars[[ 'if' '(' Exp ')' Block1 'else' Block2 ]] = collect-declared-vars[[ Block1 ]], collect-declared-vars[[ Block2 ]] -Rule collect-declared-vars[[ 'while' '(' Exp ')' Block ]] = collect-declared-vars[[ Block ]] - Rule collect-declared-vars[[ ]] = map() Rule collect-declared-vars[[ Stmt ]] = map() Rule collect-declared-vars[[ Stmt1 Stmt2 Stmt* ]] = collect-declared-vars[[ Stmt1 ]], collect-declared-vars[[ Stmt2 ]], collect-declared-vars[[ Stmt* ]] - - - - - - - - - - - -