Skip to content

Commit 88e20e3

Browse files
remo5000ning-y
authored andcommitted
Add Chapter 3 (#22)
* Move some builtins to chapter 3 * Move some syntax rules to chapter 3 * Set disableOn for some rules * Fix elaboration for noImplicitDeclareUndefined
1 parent 4265174 commit 88e20e3

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

src/createContext.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,22 @@ export const importBuiltins = (context: Context, externalBuiltIns: CustomBuiltIn
125125
defineSymbol(context, 'equal', list.equal)
126126
}
127127

128+
if (context.chapter >= 3) {
129+
defineSymbol(context, 'set_head', list.set_head)
130+
defineSymbol(context, 'set_tail', list.set_tail)
131+
defineSymbol(context, 'array_length', misc.array_length)
132+
}
133+
128134
if (context.chapter >= Infinity) {
129135
// previously week 4
130136
defineSymbol(context, 'alert', alert)
131-
defineSymbol(context, 'math_floor', Math.floor)
132137
// tslint:disable-next-line:ban-types
133138
defineSymbol(context, 'timed', (f: Function) => misc.timed(context, f, context.externalContext, externalBuiltIns.display))
134139
// previously week 5
135140
defineSymbol(context, 'assoc', list.assoc)
136141
defineSymbol(context, 'draw', visualiseList)
137142
// previously week 6
138143
defineSymbol(context, 'is_number', misc.is_number)
139-
// previously week 8
140-
defineSymbol(context, 'undefined', undefined)
141-
defineSymbol(context, 'set_head', list.set_head)
142-
defineSymbol(context, 'set_tail', list.set_tail)
143-
// previously week 9
144-
defineSymbol(context, 'array_length', misc.array_length)
145144
}
146145
}
147146

src/rules/noDeclareMutable.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export class NoDeclareMutableError implements SourceError {
2727

2828
const noDeclareMutable: Rule<es.VariableDeclaration> = {
2929
name: 'no-declare-mutable',
30+
disableOn: 3,
3031

3132
checkers: {
3233
VariableDeclaration(node: es.VariableDeclaration) {

src/rules/noImplicitDeclareUndefined.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class NoImplicitDeclareUndefinedError implements SourceError {
2222
A variable declaration assigns a value to a name.
2323
For instance, to assign 20 to ${this.node.name}, you can write:
2424
25-
var ${this.node.name} = 20;
25+
let ${this.node.name} = 20;
2626
2727
${this.node.name} + ${this.node.name}; // 40
2828
`

src/rules/noNonEmptyList.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class NoNonEmptyListError implements SourceError {
2424
const noNonEmptyList: Rule<es.ArrayExpression> = {
2525
name: 'no-non-empty-list',
2626

27-
disableOn: 9,
27+
disableOn: 3,
2828

2929
checkers: {
3030
ArrayExpression(node: es.ArrayExpression) {

src/syntaxTypes.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ const syntaxTypes: { [nodeName: string]: number } = {
1919
// Chapter 2
2020
ArrayExpression: 2,
2121

22+
// Chapter 3
23+
AssignmentExpression: 3,
24+
ForStatement: 3,
25+
WhileStatement: 3,
26+
BreakStatement: 3,
27+
ContinueStatement: 3,
28+
ThisExpression: 3,
29+
ObjectExpression: 3,
30+
MemberExpression: 3,
31+
Property: 3,
32+
UpdateExpression: 3,
33+
2234
// Week 5
2335
EmptyStatement: 5,
24-
// preivously Week 8
25-
AssignmentExpression: 8,
26-
WhileStatement: 8,
27-
// previously Week 9
28-
ForStatement: 9,
29-
BreakStatement: 9,
30-
ContinueStatement: 9,
31-
MemberExpression: 9,
3236
// previously Week 10
33-
ThisExpression: 10,
34-
ObjectExpression: 10,
35-
Property: 10,
36-
UpdateExpression: 10,
3737
NewExpression: 10,
3838
// Disallowed Forever
3939
SwitchStatement: Infinity,

0 commit comments

Comments
 (0)