Skip to content

Commit cd98039

Browse files
committed
consistent naming
1 parent 6983508 commit cd98039

12 files changed

+76
-2655
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ All programs in this repository are runnable in the [Source Academy playground](
99
The evaluators in this section all follow the general style of SICP JS Chapter 4.
1010

1111
* [`src/evaluators/source-0.js`](https://github.com/source-academy/source-programs/blob/master/src/evaluators/source-0.js): evaluator for Source §0 (calculator language)
12-
* [`src/evaluators/source-0pp.js`](https://github.com/source-academy/source-programs/blob/master/src/evaluators/source-0pp.js): evaluator for Source §0++ (calculator language plus conditionals, blocks and sequences)
13-
* [`src/evaluators/source-4-1.js`](https://github.com/source-academy/source-programs/blob/master/src/evaluators/source-4-1.js): evaluator for Source §1, described in SICP JS 4.1
12+
* [`src/evaluators/source-0-pp.js`](https://github.com/source-academy/source-programs/blob/master/src/evaluators/source-0-pp.js): evaluator for Source §0++ (calculator language plus conditionals, blocks and sequences)
13+
* [`src/evaluators/source-2.js`](https://github.com/source-academy/source-programs/blob/master/src/evaluators/source-2.js): evaluator for Source §2, described in SICP JS 4.1
14+
* [`src/evaluators/source-2-lazy.js`](https://github.com/source-academy/source-programs/blob/master/src/evaluators/source-4-3.js): lazy evaluator for Source §2, described in SICP JS 4.2
15+
* [`src/evaluators/source-2-non-det.js`](https://github.com/source-academy/source-programs/blob/master/src/evaluators/source-2-non-det.js): evaluator for Source §2 with non-determinism, described in SICP JS 4.3
1416
* [`src/evaluators/typed-source.js`](https://github.com/source-academy/source-programs/blob/master/src/evaluators/typed-source.js): evaluator for Typed Source (typed version of a Source §1 sublanguage)
15-
* [`src/evaluators/source-4-3.js`](https://github.com/source-academy/source-programs/blob/master/src/evaluators/source-4-3.js): meta-circular evaluator for Source §4.3 (non-deterministic programming)
1617

1718
## Steppers
1819

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ provides for sequences of expressions.
99
1010
The covered Source §1 sublanguage is:
1111
12-
statement ::= expression ;
13-
| statement statement
12+
stmt ::= expr ;
13+
| stmt stmt
1414
| block
15-
block ::= { statement }
16-
expression ::= expression binop expression
17-
| unop expression
15+
block ::= { stmt }
16+
expr ::= expr binop expr
17+
| unop expr
1818
| number
1919
| true | false
2020
binop ::= + | - | * | / | % | < | > | <= | >= | === | !==

src/evaluators/source-2-lazy.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,38 @@
11
/*
2-
Evaluator for language with booleans, conditionals,
2+
Lazy evaluator for language with booleans, conditionals,
33
sequences, functions, constants, variables and blocks
4+
45
This is an evaluator for a language that lets you declare
56
functions, variables and constants, apply functions, and
67
carry out simple arithmetic calculations, boolean operations.
8+
79
The covered Source §1 sublanguage is:
810
stmt ::= const name = expr ;
911
| let name = expr ;
10-
| function name(params) block
12+
| function name ( params ) block
1113
| expr ;
1214
| stmt stmt
15+
| return expr ;
1316
| name = expr ;
1417
| block
1518
block ::= { stmt }
16-
expr ::= expr ? expr : expr
19+
params ::=  | name ( , name )...
20+
expr ::= number
21+
| true | false
22+
| null
23+
| string
24+
| name
1725
| expr binop expr
1826
| unop expr
19-
| name
20-
| number
21-
| expr(expr, expr, ...)
22-
binop ::= + | - | * | / | % | < | > | <= | >=
23-
| === | !== | && | ||
24-
unop ::= !
27+
| expr ( exprs )
28+
| ( params ) => expr
29+
| ( params ) => block
30+
| expr ? expr : expr
31+
| ( expression )
32+
binop ::= + | - | * | / | % | === | !==
33+
| > | < | >= | <=
34+
unop ::= ! | -
35+
exprs ::=  | expression ( , expression )...
2536
*/
2637

2738
/* CONSTANTS: NUMBERS, STRINGS, TRUE, FALSE */
Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,41 @@
11
/*
2-
Evaluator for language with booleans, conditionals,
2+
Non-deterministic evaluator for language with booleans, conditionals,
33
sequences, functions, constants, variables and blocks
4+
45
This is an evaluator for a language that lets you declare
56
functions, variables and constants, apply functions, and
67
carry out simple arithmetic calculations, boolean operations.
8+
79
The covered sublanguage of Source §2 is:
810
9-
program ::= statement
10-
statement ::= const name = expression ;
11-
| function name ( parameters )
12-
| return expression ;
13-
| block
14-
| expression ;
15-
parameters ::=  | name ( , name )
16-
block ::= { program }
17-
expression ::= number
18-
| true | false
19-
| null
20-
| string
21-
| name
22-
| expression binary-operator expression
23-
| unary-operator expression
24-
| expression ( expressions )
25-
| ( name | ( parameters ) ) => expression
26-
| ( name | ( parameters ) ) => block
27-
| expression ? expression : expression
28-
| ( expression )
29-
binary-operator ::= + | - | * | / | % | === | !==
30-
| > | < | >= | <=
31-
unary-operator ::= ! | -
32-
expressions ::=  | expression ( , expression )
11+
program ::= stmt
12+
stmt ::= const name = expression ;
13+
| let name = expression ;
14+
| function name ( params ) block
15+
| stmt stmt
16+
| return expression ;
17+
| name = expr ;
18+
| block
19+
block ::= { stmt }
20+
params ::=  | name ( , name )...
21+
expr ::= number
22+
| true | false
23+
| null
24+
| string
25+
| name
26+
| expr binop expr
27+
| unop expr
28+
| expr ( exprs )
29+
| ( params ) => expr
30+
| ( params ) => block
31+
| expr ? expr : expr
32+
| ( expression )
33+
binop ::= + | - | * | / | % | === | !==
34+
| > | < | >= | <=
35+
unop ::= ! | -
36+
exprs ::=  | expression ( , expression )...
3337
*/
38+
3439
function is_true(x) {
3540
return x === true;
3641
}
Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,30 @@ The covered Source §1 sublanguage is:
1010
1111
stmt ::= const name = expr ;
1212
| let name = expr ;
13-
| function name(params) block
13+
| function name ( params ) block
1414
| expr ;
1515
| stmt stmt
16+
| return expr ;
1617
| name = expr ;
1718
| block
1819
block ::= { stmt }
19-
expr ::= expr ? expr : expr
20+
params ::=  | name ( , name )...
21+
expr ::= number
22+
| true | false
23+
| null
24+
| string
25+
| name
2026
| expr binop expr
2127
| unop expr
22-
| name
23-
| number
24-
| expr(expr, expr, ...)
25-
binop ::= + | - | * | / | % | < | > | <= | >=
26-
| === | !== | && | ||
27-
unop ::= ! | -
28+
| expr ( exprs )
29+
| ( params ) => expr
30+
| ( params ) => block
31+
| expr ? expr : expr
32+
| ( expression )
33+
binop ::= + | - | * | / | % | === | !==
34+
| > | < | >= | <=
35+
unop ::= ! | -
36+
exprs ::=  | expression ( , expression )...
2837
*/
2938

3039
/* CONSTANTS: NUMBERS, STRINGS, TRUE, FALSE */

0 commit comments

Comments
 (0)