Skip to content

Commit

Permalink
style: Create motc
Browse files Browse the repository at this point in the history
  • Loading branch information
NriotHrreion committed Nov 2, 2024
1 parent 0c97f83 commit 715fd93
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/motc/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { MOT } from "./types";

export class MOTC {
private _mot: MOT = {
metadata: {},
chunks: []
};

private constructor(private _src: string) { }

private _tokenize(): MOT {
/** @todo */

return this._mot;
}

public static parse(src: string): MOT {
return new MOTC(src)._tokenize();
}
}
24 changes: 24 additions & 0 deletions src/motc/sample.mot
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#name Sample Map
#description This is a sample description!
#author NriotHrreion

@objects {
ball {
id: ball1;
name: m;
mass: 5;
}

block {
id: block1;
name: M;
mass: 10;
}
}

@when {
3s {
delete ball1;
delete block1;
}
}
50 changes: 50 additions & 0 deletions src/motc/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
export interface MOT {
metadata: {
name?: string
description?: string
author?: string
}

chunks: Chunk[]
}

type ChunkName = "objects" | "when";

export interface Chunk {
name: ChunkName
members: Scope[]
}

export interface ObjectsChunk extends Chunk {
name: "objects"
members: ObjectScope[]
}

export interface WhenChunk extends Chunk {
name: "when"
members: TimeScope[]
}

export interface Scope {
name: string
}

export interface ObjectScope extends Scope {
properties: Property[]
}

export interface TimeScope extends Scope {
statements: Statement[]
}

export interface Property {
key: string
value: string
}

type StatementVerb = "move" | "delete";

export interface Statement {
verb: StatementVerb
args: string[]
}

0 comments on commit 715fd93

Please sign in to comment.