Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/js/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2675,6 +2675,9 @@ function loadFile(str) {
formatHomePage(state);

delete state.commentLevel;
delete state.line_should_end;
delete state.line_should_end_because;
delete state.sol_after_comment;
delete state.names;
delete state.abbrevNames;
delete state.objects_candname;
Expand Down Expand Up @@ -2789,4 +2792,4 @@ function qualifyURL(url) {
var a = document.createElement('a');
a.href = url;
return a.href;
}
}
43 changes: 33 additions & 10 deletions src/js/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ var codeMirrorFn = function() {
section: state.section,
visitedSections: state.visitedSections.concat([]),

line_should_end: state.line_should_end,
line_should_end_because: state.line_should_end_because,

sol_after_comment: state.sol_after_comment,

objects_candname: state.objects_candname,
objects_section: state.objects_section,
objects_spritematrix: state.objects_spritematrix.concat([]),
Expand Down Expand Up @@ -324,10 +329,11 @@ var codeMirrorFn = function() {
},
token: function(stream, state) {
var mixedCase = stream.string;
var sol = stream.sol();
if (sol) {
var normal_sol = stream.sol();
if (normal_sol) {
stream.string = stream.string.toLowerCase();
state.tokenIndex=0;
state.line_should_end = false;
/* if (state.lineNumber==undefined) {
state.lineNumber=1;
}
Expand All @@ -336,6 +342,12 @@ var codeMirrorFn = function() {
}*/

}
// White-out initial comments to reduce parser confusion (e.g., code that accesses and reparses stream.string)
if (state.sol_after_comment === true) {
stream.string = ' '.repeat(stream.pos) + stream.string.substr(stream.pos);
}
var sol = normal_sol || state.sol_after_comment;
state.sol_after_comment = false;

function registerOriginalCaseName(candname){

Expand All @@ -361,16 +373,11 @@ var codeMirrorFn = function() {
if (ch === '(' && state.tokenIndex !== -4) { // tokenIndex -4 indicates message command
stream.next();
state.commentLevel++;
} else if (ch === ')') {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note to self: this is a bit that just gobbles up all right-parentheses without so much as dropping an error if something's amiss.

stream.next();
if (state.commentLevel > 0) {
state.commentLevel--;
if (state.commentLevel === 0) {
return 'comment';
}
}
}
if (state.commentLevel > 0) {
if (sol) {
state.sol_after_comment = true;
}
while (true) {
stream.eatWhile(/[^\(\)]+/);

Expand Down Expand Up @@ -400,17 +407,27 @@ var codeMirrorFn = function() {
return blankLineHandle(state);
}

if (state.line_should_end && !stream.eol()) {
logError('Only comments should go after ' + state.line_should_end_because + ' on a line.', state.lineNumber);
stream.skipToEnd();
return 'ERROR';
}

// if (sol)
{

//MATCH '==="s AT START OF LINE
if (sol && stream.match(reg_equalsrow, true)) {
state.line_should_end = true;
state.line_should_end_because = 'an equals decorator (\'===\')';
return 'EQUALSBIT';
}

//MATCH SECTION NAME
if (sol && stream.match(reg_sectionNames, true)) {
state.section = stream.string.slice(0, stream.pos).trim();
state.line_should_end = true;
state.line_should_end_because = 'a section name';
if (state.visitedSections.indexOf(state.section) >= 0) {
logError('cannot duplicate sections (you tried to duplicate \"' + state.section.toUpperCase() + '").', state.lineNumber);
}
Expand Down Expand Up @@ -1252,6 +1269,12 @@ var codeMirrorFn = function() {
section: '',
visitedSections: [],

line_should_end: false,
line_should_end_because: '',

sol_after_comment: false,


objects_candname: '',
objects_section: 0, //whether reading name/color/spritematrix
objects_spritematrix: [],
Expand Down
Loading