Skip to content

Commit af83135

Browse files
committed
Modularize the code base.
This is still the initial step where the scanner and the parser are separated into two big chunks (with utility modules on the side as well). It is expected that the coupling between the two will be better defined in the subsequent refactoring. Closes jquery#1176 Closes jquerygh-1350
1 parent 85b2dcf commit af83135

File tree

11 files changed

+5720
-5698
lines changed

11 files changed

+5720
-5698
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
coverage
22
node_modules
33
test/dist
4+
src/*.js

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"temp": "~0.8.3",
5858
"tslint": "~2.5.1",
5959
"typescript": "~1.6.2",
60+
"typescript-formatter": "~1.1.0",
6061
"unicode-7.0.0": "~0.1.5",
6162
"webpack": "~1.12.1"
6263
},
@@ -71,7 +72,7 @@
7172
"scripts": {
7273
"check-version": "node test/check-version.js",
7374
"tslint": "tslint src/*.ts",
74-
"code-style": "jscs -p crockford test/*.js",
75+
"code-style": "tsfmt --verify src/*.ts && jscs -p crockford test/*.js",
7576
"complexity": "node test/check-complexity.js",
7677
"static-analysis": "npm run check-version && npm run tslint && npm run code-style && npm run complexity",
7778
"unit-tests": "node test/unit-tests.js",
@@ -95,7 +96,7 @@
9596
"downstream": "node test/downstream.js",
9697
"travis": "npm test",
9798
"circleci": "npm test && npm run codecov && npm run downstream",
98-
"appveyor": "npm run all-tests && npm run browser-tests && npm run dynamic-analysis",
99+
"appveyor": "npm run compile && npm run all-tests && npm run browser-tests && npm run dynamic-analysis",
99100
"droneio": "npm test && npm run saucelabs-evergreen && npm run saucelabs-ie && npm run saucelabs-safari",
100101
"generate-regex": "node tools/generate-identifier-regex.js"
101102
}

src/assert.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Ensure the condition is true, otherwise throw an error.
2+
// This is only to have a better contract semantic, i.e. another safety net
3+
// to catch a logic error. The condition shall be fulfilled in normal case.
4+
// Do NOT use this to enforce a certain condition on any user input.
5+
6+
export function assert(condition: boolean, message: string): void {
7+
/* istanbul ignore if */
8+
if (!condition) {
9+
throw new Error('ASSERT: ' + message);
10+
}
11+
}

src/character.ts

Lines changed: 66 additions & 0 deletions
Large diffs are not rendered by default.

src/esprima.ts

Lines changed: 4 additions & 5695 deletions
Large diffs are not rendered by default.

src/messages.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Error messages should be identical to V8.
2+
export const Messages = {
3+
UnexpectedToken: 'Unexpected token %0',
4+
UnexpectedNumber: 'Unexpected number',
5+
UnexpectedString: 'Unexpected string',
6+
UnexpectedIdentifier: 'Unexpected identifier',
7+
UnexpectedReserved: 'Unexpected reserved word',
8+
UnexpectedTemplate: 'Unexpected quasi %0',
9+
UnexpectedEOS: 'Unexpected end of input',
10+
NewlineAfterThrow: 'Illegal newline after throw',
11+
InvalidRegExp: 'Invalid regular expression',
12+
UnterminatedRegExp: 'Invalid regular expression: missing /',
13+
InvalidLHSInAssignment: 'Invalid left-hand side in assignment',
14+
InvalidLHSInForIn: 'Invalid left-hand side in for-in',
15+
InvalidLHSInForLoop: 'Invalid left-hand side in for-loop',
16+
MultipleDefaultsInSwitch: 'More than one default clause in switch statement',
17+
NoCatchOrFinally: 'Missing catch or finally after try',
18+
UnknownLabel: 'Undefined label \'%0\'',
19+
Redeclaration: '%0 \'%1\' has already been declared',
20+
IllegalContinue: 'Illegal continue statement',
21+
IllegalBreak: 'Illegal break statement',
22+
IllegalReturn: 'Illegal return statement',
23+
StrictModeWith: 'Strict mode code may not include a with statement',
24+
StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode',
25+
StrictVarName: 'Variable name may not be eval or arguments in strict mode',
26+
StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode',
27+
StrictParamDupe: 'Strict mode function may not have duplicate parameter names',
28+
StrictFunctionName: 'Function name may not be eval or arguments in strict mode',
29+
StrictOctalLiteral: 'Octal literals are not allowed in strict mode.',
30+
StrictDelete: 'Delete of an unqualified identifier in strict mode.',
31+
StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode',
32+
StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode',
33+
StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode',
34+
StrictReservedWord: 'Use of future reserved word in strict mode',
35+
TemplateOctalLiteral: 'Octal literals are not allowed in template strings.',
36+
ParameterAfterRestParameter: 'Rest parameter must be last formal parameter',
37+
DefaultRestParameter: 'Unexpected token =',
38+
ObjectPatternAsRestParameter: 'Unexpected token {',
39+
DuplicateProtoProperty: 'Duplicate __proto__ fields are not allowed in object literals',
40+
ConstructorSpecialMethod: 'Class constructor may not be an accessor',
41+
DuplicateConstructor: 'A class may only have one constructor',
42+
StaticPrototype: 'Classes may not have static property named prototype',
43+
MissingFromClause: 'Unexpected token',
44+
NoAsAfterImportNamespace: 'Unexpected token',
45+
InvalidModuleSpecifier: 'Unexpected token',
46+
IllegalImportDeclaration: 'Unexpected token',
47+
IllegalExportDeclaration: 'Unexpected token',
48+
DuplicateBinding: 'Duplicate binding %0'
49+
};

0 commit comments

Comments
 (0)