mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-01-15 20:29:46 +00:00
ecs: debug info
This commit is contained in:
parent
3f241bfcc2
commit
9b6f797451
@ -183,7 +183,13 @@ export class ECSCompiler extends Tokenizer {
|
||||
}
|
||||
|
||||
parseCode(): string {
|
||||
return this.expectTokenTypes([TokenType.CodeFragment]).str;
|
||||
let tok = this.expectTokenTypes([TokenType.CodeFragment]);
|
||||
let code = tok.str;
|
||||
let lines = code.split('\n');
|
||||
for (let i=0; i<lines.length; i++) {
|
||||
lines[i] = ` .dbg line, "${this.path}", ${tok.$loc.line+i}\n` + lines[i];
|
||||
}
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
parseScope() : EntityScope {
|
||||
@ -263,6 +269,7 @@ export class ECSCompiler extends Tokenizer {
|
||||
|
||||
export() {
|
||||
let src = new SourceFileExport();
|
||||
src.debug_file(this.path);
|
||||
this.exportToFile(src);
|
||||
return src.toString();
|
||||
}
|
||||
|
@ -220,6 +220,12 @@ export class SourceFileExport {
|
||||
for (let l of s.split('\n'))
|
||||
this.lines.push(l);
|
||||
}
|
||||
debug_file(path: string) {
|
||||
this.lines.push(` .dbg file, "${path}", 0, 0`);
|
||||
}
|
||||
debug_line(path: string, line: number) {
|
||||
this.lines.push(` .dbg line, "${path}", ${line}`);
|
||||
}
|
||||
toString() {
|
||||
return this.lines.join('\n');
|
||||
}
|
||||
|
@ -71,6 +71,7 @@ export class Tokenizer {
|
||||
includeEOL = false;
|
||||
errorOnCatchAll = false;
|
||||
codeFragment : string | null = null;
|
||||
codeFragmentStart : SourceLocation | null = null;
|
||||
|
||||
constructor() {
|
||||
this.lineno = 0;
|
||||
@ -110,9 +111,13 @@ export class Tokenizer {
|
||||
switch (rule.type) {
|
||||
case TokenType.CodeFragment:
|
||||
if (this.codeFragment) {
|
||||
this._pushToken({ str: this.codeFragment, type: rule.type, $loc: loc }); //TODO: merge start/end
|
||||
let codeLoc = mergeLocs(this.codeFragmentStart, loc);
|
||||
this._pushToken({ str: this.codeFragment, type: rule.type, $loc: codeLoc }); //TODO: merge start/end
|
||||
this.codeFragmentStart = null;
|
||||
this.codeFragment = null;
|
||||
} else {
|
||||
loc.line++;
|
||||
this.codeFragmentStart = loc;
|
||||
this.codeFragment = '';
|
||||
return; // don't add any more tokens (TODO: check for trash?)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user