mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Clean up code and comments.
This commit is contained in:
parent
57f1763abe
commit
de939ab939
1 changed files with 7 additions and 8 deletions
|
@ -109,13 +109,12 @@ var PaperScript = Base.exports.PaperScript = (function(root) {
|
|||
*/
|
||||
function compile(code) {
|
||||
// Use Acorn or Esprima to translate the code into an AST structure
|
||||
// which is then walked and parsed for operators to overload.
|
||||
// Instead of modifying the AST and converting back to code, we directly
|
||||
// change the source code based on the parser's range information, so we
|
||||
// can preserve line-numbers in syntax errors and remove the need for
|
||||
// Escodegen.
|
||||
// which is then walked and parsed for operators to overload. Instead of
|
||||
// modifying the AST and translating it back to code, we directly change
|
||||
// the source code based on the parser's range information, to preserve
|
||||
// line-numbers in syntax errors and remove the need for Escodegen.
|
||||
|
||||
// Tracks code insertions so we can add their differences to the
|
||||
// Track code insertions so their differences can be added to the
|
||||
// original offsets.
|
||||
var insertions = [];
|
||||
|
||||
|
@ -143,8 +142,8 @@ var PaperScript = Base.exports.PaperScript = (function(root) {
|
|||
// information up-to-date.
|
||||
function replaceCode(node, str) {
|
||||
var start = getOffset(node.range[0]),
|
||||
end = getOffset(node.range[1]);
|
||||
var insert = 0;
|
||||
end = getOffset(node.range[1]),
|
||||
insert = 0;
|
||||
// Sort insertions by their offset, so getOffest() can do its thing
|
||||
for (var i = insertions.length - 1; i >= 0; i--) {
|
||||
if (start > insertions[i][0]) {
|
||||
|
|
Loading…
Reference in a new issue