Skip to content

Commit

Permalink
straighten out some leftover crud from the last few commits
Browse files Browse the repository at this point in the history
  • Loading branch information
schanzer committed Mar 17, 2016
1 parent c80eb00 commit 5d36f73
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 28 deletions.
48 changes: 20 additions & 28 deletions src/lex.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,35 +66,25 @@ var jsnums = require('./runtime/js-numbers');

// the location struct
// endCol and endRow are included for pyret error location
var Location = function(startCol, startRow, startChar, span, theSource) {
this.startCol = startCol; // starting index into the line
this.startRow = startRow; // starting line # (1-index)
this.startChar = startChar; // ch index of lexeme start, from beginning
this.span = span; // num chrs between lexeme start and end
this.source = theSource || source; // [OPTIONAL] id of the containing DOM element

this.endCol = column; // ending index into the line
this.endRow = line; // ending index into the line
this.endChar = startChar + span; // ch index of lexeme end, from beginning

this.start = function() {
return new Location("", "", this.startChar, 1);
};
this.end = function() {
return new Location("", "", this.startChar + this.span - 1, 1);
};
this.toString = function() {
return "Loc(" + this.startCol + ", " + this.startRow + ", " + (this.startChar + 1) + "," + this.span + ")";
};
this.toVector = function() {
class Location {
constructor(startCol, startRow, startChar, span, theSource) {
this.startCol = startCol; // starting index into the line
this.startRow = startRow; // starting line # (1-index)
this.startChar = startChar; // ch index of lexeme start, from beginning
this.span = span; // num chrs between lexeme start and end
this.source = theSource || source; // [OPTIONAL] id of the containing DOM element

this.endCol = column; // ending index into the line
this.endRow = line; // ending index into the line
this.endChar = startChar + span; // ch index of lexeme end, from beginning
}
start() { return new Location("", "", this.startChar, 1); };
end() { return new Location("", "", this.startChar + this.span - 1, 1); };
toVector() {
return new types.vector(['"' + this.source + '"' // add quotes to the source, since it's a str (not a symbol)



, this.startChar + 1, this.startRow, this.startCol, this.span
]);
, this.startChar + 1, this.startRow, this.startCol, this.span]);
};
this.toString = function() {
toString() {
return {
line: this.startRow.toString()
, id: this.source
Expand Down Expand Up @@ -184,7 +174,9 @@ var jsnums = require('./runtime/js-numbers');
i = chewWhiteSpace(str, 0);
while (i < str.length) {
sexp = readSExpByIndex(str, i);
sexps.push(sexp);
if (!(sexp instanceof compiler.comment)) {
sexps.push(sexp);
}
i = chewWhiteSpace(str, sexp.location.startChar + sexp.location.span);
}
sexps.location = new Location(startCol, startRow, 0, i, source);
Expand Down
1 change: 1 addition & 0 deletions src/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ var compiler = require('./compiler');
, ["list*", 1, true]
, ["list-ref", 2]
, ["remove", 2]
, ["remove-all", 2]
, ["member", 2]
, ["member?", 2]
, ["memq", 2]
Expand Down

0 comments on commit 5d36f73

Please sign in to comment.