Skip to content

Commit ea03644

Browse files
committed
why so slow
1 parent d21af44 commit ea03644

File tree

12 files changed

+1584
-132
lines changed

12 files changed

+1584
-132
lines changed

masm-tasm/src/language/ast/ast.ts

Lines changed: 3 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -1,134 +1,5 @@
1-
// Define token types
2-
export type TokenType =
3-
| 'COMMENT'
4-
| 'INSTRUCTION'
5-
| 'REGISTER'
6-
| 'NUMBER'
7-
| 'COMMA'
8-
| 'SEGMENT'
9-
| 'ENDS'
10-
| 'LABEL'
11-
| 'INCLUDE'
12-
| 'PROCESSOR_DIRECTIVE'
13-
| 'MACRO_START'
14-
| 'MACRO_END'
15-
| 'PROC'
16-
| 'ENDP'
17-
| 'STRING'
18-
| 'EQU'
19-
| 'DB'
20-
| 'DW';
21-
22-
// Define token interface
23-
export interface Token {
24-
type: TokenType;
25-
value: string;
26-
position: number;
27-
}
28-
29-
// Define AST node types
30-
export type ASTNode =
31-
| InstructionNode
32-
| SegmentNode
33-
| LabelNode
34-
| IncludeNode
35-
| ProcessorDirectiveNode
36-
| MacroDefinitionNode
37-
| ProcedureNode
38-
| StringNode
39-
| EquNode
40-
| DataNode;
41-
42-
// Define instruction node interface
43-
export interface InstructionNode {
44-
type: 'INSTRUCTION';
45-
name: string;
46-
operands: (RegisterNode | NumberNode | LabelReferenceNode | StringNode)[];
47-
}
48-
49-
// Define register node interface
50-
export interface RegisterNode {
51-
type: 'REGISTER';
52-
name: string;
53-
}
54-
55-
// Define number node interface
56-
export interface NumberNode {
57-
type: 'NUMBER';
58-
value: number;
59-
}
60-
61-
// Define label reference node interface
62-
export interface LabelReferenceNode {
63-
type: 'LABEL_REFERENCE';
64-
name: string;
65-
}
66-
67-
// Define segment node interface
68-
export interface SegmentNode {
69-
type: 'SEGMENT';
70-
name: string;
71-
instructions: ASTNode[];
72-
}
73-
74-
// Define label node interface
75-
export interface LabelNode {
76-
type: 'LABEL';
77-
name: string;
78-
position: number;
79-
}
80-
81-
// Define include node interface
82-
export interface IncludeNode {
83-
type: 'INCLUDE';
84-
filename: string;
85-
ast: ASTNode[];
86-
}
87-
88-
// Define processor directive node interface
89-
export interface ProcessorDirectiveNode {
90-
type: 'PROCESSOR_DIRECTIVE';
91-
directive: string;
92-
}
93-
94-
// Define macro definition node interface
95-
export interface MacroDefinitionNode {
96-
type: 'MACRO_DEFINITION';
97-
name: string;
98-
body: ASTNode[];
99-
}
100-
101-
// Define procedure node interface
102-
export interface ProcedureNode {
103-
type: 'PROCEDURE';
104-
name: string;
105-
instructions: ASTNode[];
106-
}
107-
108-
// Define string node interface
109-
export interface StringNode {
110-
type: 'STRING';
111-
value: string;
112-
}
113-
114-
// Define EQU node interface
115-
export interface EquNode {
116-
type: 'EQU';
117-
label: string;
118-
value: number | LabelReferenceNode;
119-
}
120-
121-
// Define data node interface
122-
export interface DataNode {
123-
type: 'DATA';
124-
directive: 'DB' | 'DW';
125-
values: (NumberNode | StringNode)[];
126-
}
127-
128-
// Define error information interface
129-
export interface ErrorInfo {
130-
type: string;
131-
position: number;
132-
message: string;
1+
type ASTNode={
2+
type:string,
3+
1334
}
1345

packages/jsmasm/.vscode/launch.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Run mocha",
11+
"runtimeExecutable": "mocha",
12+
"cwd": "${workspaceFolder}",
13+
"args": []
14+
},
15+
{
16+
"type": "node",
17+
"request": "launch",
18+
"name": "Launch Program",
19+
"skipFiles": [
20+
"<node_internals>/**"
21+
],
22+
"program": "${workspaceFolder}\\dist\\app.js",
23+
"preLaunchTask": "tsc: build - tsconfig.json",
24+
"outFiles": [
25+
"${workspaceFolder}/dist/**/*.js"
26+
]
27+
}
28+
]
29+
}

packages/jsmasm/README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# TypeScript Mocha Project
2+
3+
This project is a TypeScript application that uses Mocha as the testing framework. It is structured to separate the application logic from the tests, ensuring a clean and maintainable codebase.
4+
5+
## Project Structure
6+
7+
```
8+
typescript-mocha-project
9+
├── src
10+
│ ├── app.ts # Main application file containing core logic
11+
│ └── types
12+
│ └── index.ts # Type definitions and interfaces
13+
├── test
14+
│ └── app.test.ts # Test cases for the application
15+
├── package.json # NPM configuration file
16+
├── tsconfig.json # TypeScript configuration file
17+
└── README.md # Project documentation
18+
```
19+
20+
## Setup Instructions
21+
22+
1. **Clone the repository:**
23+
```
24+
git clone <repository-url>
25+
cd typescript-mocha-project
26+
```
27+
28+
2. **Install dependencies:**
29+
```
30+
npm install
31+
```
32+
33+
3. **Compile TypeScript:**
34+
```
35+
npx tsc
36+
```
37+
38+
4. **Run tests:**
39+
```
40+
npx mocha
41+
```
42+
43+
## Usage
44+
45+
- Modify the `src/app.ts` file to implement your application logic.
46+
- Define any necessary types or interfaces in `src/types/index.ts`.
47+
- Write your test cases in `test/app.test.ts` to ensure your application behaves as expected.
48+
49+
## Contributing
50+
51+
Feel free to submit issues or pull requests to improve the project. Please ensure that your code adheres to the existing style and includes appropriate tests.

packages/jsmasm/package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "typescript-mocha-project",
3+
"version": "1.0.0",
4+
"description": "A TypeScript project with Mocha for testing.",
5+
"main": "dist/app.js",
6+
"scripts": {
7+
"test": "mocha -r ts-node/register test/**/*.test.ts",
8+
"build": "tsc"
9+
},
10+
"dependencies": {
11+
"typescript": "^4.0.0"
12+
},
13+
"devDependencies": {
14+
"mocha": "^9.0.0",
15+
"ts-node": "^10.0.0",
16+
"@types/mocha": "^9.0.0"
17+
},
18+
"keywords": [],
19+
"author": "",
20+
"license": "ISC"
21+
}

0 commit comments

Comments
 (0)