diff --git a/src/common/baseplatform.ts b/src/common/baseplatform.ts index e7af32e6..c3a6754d 100644 --- a/src/common/baseplatform.ts +++ b/src/common/baseplatform.ts @@ -431,6 +431,7 @@ export function getToolForFilename_6502(fn:string) : string { if (fn.endsWith(".dasm")) return "dasm"; if (fn.endsWith(".acme")) return "acme"; if (fn.endsWith(".wiz")) return "wiz"; + if (fn.endsWith(".ecs")) return "ecs"; return "dasm"; // .a } diff --git a/src/common/ecs/compiler.ts b/src/common/ecs/compiler.ts index ec6aa5fc..5b35a017 100644 --- a/src/common/ecs/compiler.ts +++ b/src/common/ecs/compiler.ts @@ -69,7 +69,7 @@ export class ECSCompiler extends Tokenizer { parseComponentField(): DataField { let name = this.expectIdent(); - this.expectToken(':'); + this.expectToken(':', 'I expected either a ":" or "end" here.'); // TODO let type = this.parseDataType(); return { name: name.str, ...type }; } @@ -260,4 +260,10 @@ export class ECSCompiler extends Tokenizer { scope.dump(src); } } + + export() { + let src = new SourceFileExport(); + this.exportToFile(src); + return src.toString(); + } } diff --git a/src/platform/vcs.ts b/src/platform/vcs.ts index cd42dbf2..9be588ab 100644 --- a/src/platform/vcs.ts +++ b/src/platform/vcs.ts @@ -60,6 +60,7 @@ function getToolForFilename_vcs(fn: string) { if (fn.endsWith(".wiz")) return "wiz"; if (fn.endsWith(".bb") || fn.endsWith(".bas")) return "bataribasic"; if (fn.endsWith(".ca65")) return "ca65"; + if (fn.endsWith(".ecs")) return "ecs"; return "dasm"; } diff --git a/src/worker/tools/ecs.ts b/src/worker/tools/ecs.ts new file mode 100644 index 00000000..cfb01d80 --- /dev/null +++ b/src/worker/tools/ecs.ts @@ -0,0 +1,30 @@ +import { ECSCompiler } from "../../common/ecs/compiler"; +import { CompileError } from "../../common/tokenizer"; +import { CodeListingMap } from "../../common/workertypes"; +import { BuildStep, BuildStepResult, gatherFiles, getWorkFileAsString, putWorkFile, staleFiles } from "../workermain"; + +export function assembleECS(step: BuildStep): BuildStepResult { + let compiler = new ECSCompiler(); + gatherFiles(step, { mainFilePath: "main.ecs" }); + var destpath = step.prefix + '.ca65'; + if (staleFiles(step, [destpath])) { + let code = getWorkFileAsString(step.path); + try { + compiler.parseFile(code, step.path); + } catch (e) { + if (e instanceof CompileError) { + return { errors: compiler.errors }; + } else { + throw e; + } + } + //var listings: CodeListingMap = {}; + putWorkFile(destpath, compiler.export().toString()); + } + return { + nexttool: "ca65", + path: destpath, + args: [destpath], + files: [destpath, 'vcs-ca65.h'], //TODO + }; +} diff --git a/src/worker/workermain.ts b/src/worker/workermain.ts index ffde5d72..be050701 100644 --- a/src/worker/workermain.ts +++ b/src/worker/workermain.ts @@ -1063,6 +1063,7 @@ import * as z80 from './tools/z80' import * as x86 from './tools/x86' import * as arm from './tools/arm' import * as script from './tools/script' +import * as ecs from './tools/ecs' var TOOLS = { 'dasm': dasm.assembleDASM, @@ -1098,7 +1099,8 @@ var TOOLS = { 'wiz': misc.compileWiz, 'armips': arm.assembleARMIPS, 'vasmarm': arm.assembleVASMARM, - 'js': script.runJavascript, + //'js': script.runJavascript, + 'ecs': ecs.assembleECS, } var TOOL_PRELOADFS = { @@ -1125,6 +1127,7 @@ var TOOL_PRELOADFS = { 'fastbasic': '65-atari8', 'silice': 'Silice', 'wiz': 'wiz', + 'ecs': '65-none', // TODO: support multiple platforms } //const waitFor = delay => new Promise(resolve => setTimeout(resolve, delay)); // for testing