Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong cstNode data when using colon newlines #214

Open
dhuebner opened this issue Dec 5, 2024 · 1 comment
Open

Wrong cstNode data when using colon newlines #214

dhuebner opened this issue Dec 5, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@dhuebner
Copy link
Collaborator

dhuebner commented Dec 5, 2024

Following example:

if sys = "1" then
:     input(0,err=1)'ask'
:     goto *NEXT

An error is reported on line break after then saying "Symbolic label reference may not contain whitespace." which is wrong.
The SymbolicLabelRef CST node text returns oto * but should return *NEXT

@dhuebner dhuebner added the bug Something isn't working label Dec 5, 2024
@msujew
Copy link
Collaborator

msujew commented Dec 5, 2024

The lexer performs a bunch of manipulation when it encounters a line splitter:

private prepareLineSplitter(text: string): string {
const windowsEol = text.includes('\r\n');
const lines = text.split(/\r?\n/g);
for (let i = 0; i < lines.length - 1; i++) {
const start = i + 1;
let lineIndex = start;
let nextLine = lines[lineIndex];
let end = 0;
while (nextLine && nextLine.charAt(0) === ':') {
end = lineIndex;
nextLine = lines[++lineIndex];
}
if (end > 0) {
let line = lines[i];
const lineAmount = end - start + 1;
const replaceLines = new Array<string>(lineAmount).fill('');
const splitLines = lines.splice(start, lineAmount, ...replaceLines).map(e => e.substring(1));
const padding = ' '.repeat(splitLines.length);
line = [line, ...splitLines, padding].join('');
lines[i] = line;
i = end;
}
}
const eol = windowsEol ? '\r\n' : '\n';
return lines.join(eol) + eol;
}

This results in the lexer processing different text than what is actually contained in the document.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants