azkal-lang 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/ast.d.ts +165 -0
- package/dist/src/ast.js +2 -0
- package/dist/src/ast.js.map +1 -0
- package/dist/src/environment.d.ts +26 -0
- package/dist/src/environment.js +30 -0
- package/dist/src/environment.js.map +1 -0
- package/dist/src/errors.d.ts +16 -0
- package/dist/src/errors.js +35 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +61 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/interpreter.d.ts +34 -0
- package/dist/src/interpreter.js +619 -0
- package/dist/src/interpreter.js.map +1 -0
- package/dist/src/lexer.d.ts +23 -0
- package/dist/src/lexer.js +349 -0
- package/dist/src/lexer.js.map +1 -0
- package/dist/src/parser.d.ts +47 -0
- package/dist/src/parser.js +456 -0
- package/dist/src/parser.js.map +1 -0
- package/dist/src/repl.d.ts +1 -0
- package/dist/src/repl.js +60 -0
- package/dist/src/repl.js.map +1 -0
- package/dist/src/stdlib.d.ts +2 -0
- package/dist/src/stdlib.js +147 -0
- package/dist/src/stdlib.js.map +1 -0
- package/dist/src/tokens.d.ts +55 -0
- package/dist/src/tokens.js +74 -0
- package/dist/src/tokens.js.map +1 -0
- package/package.json +41 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
export type Node = Program | NumberLiteral | StringLiteral | TemplateLiteral | BooleanLiteral | NullLiteral | Identifier | BinaryExpr | UnaryExpr | LogicalExpr | PipeExpr | AssignExpr | CallExpr | IndexExpr | MemberExpr | ArrayLiteral | ObjectLiteral | SpreadExpr | FnExpr | LetDecl | FnDecl | ReturnStmt | IfStmt | WhileStmt | ForInStmt | BlockStmt | ExprStmt | BreakStmt | ContinueStmt;
|
|
2
|
+
export interface Program {
|
|
3
|
+
kind: "Program";
|
|
4
|
+
body: Node[];
|
|
5
|
+
line: number;
|
|
6
|
+
}
|
|
7
|
+
export interface NumberLiteral {
|
|
8
|
+
kind: "NumberLiteral";
|
|
9
|
+
value: number;
|
|
10
|
+
line: number;
|
|
11
|
+
}
|
|
12
|
+
export interface StringLiteral {
|
|
13
|
+
kind: "StringLiteral";
|
|
14
|
+
value: string;
|
|
15
|
+
line: number;
|
|
16
|
+
}
|
|
17
|
+
export interface TemplateLiteral {
|
|
18
|
+
kind: "TemplateLiteral";
|
|
19
|
+
parts: Node[];
|
|
20
|
+
line: number;
|
|
21
|
+
}
|
|
22
|
+
export interface BooleanLiteral {
|
|
23
|
+
kind: "BooleanLiteral";
|
|
24
|
+
value: boolean;
|
|
25
|
+
line: number;
|
|
26
|
+
}
|
|
27
|
+
export interface NullLiteral {
|
|
28
|
+
kind: "NullLiteral";
|
|
29
|
+
line: number;
|
|
30
|
+
}
|
|
31
|
+
export interface Identifier {
|
|
32
|
+
kind: "Identifier";
|
|
33
|
+
name: string;
|
|
34
|
+
line: number;
|
|
35
|
+
}
|
|
36
|
+
export interface BinaryExpr {
|
|
37
|
+
kind: "BinaryExpr";
|
|
38
|
+
op: string;
|
|
39
|
+
left: Node;
|
|
40
|
+
right: Node;
|
|
41
|
+
line: number;
|
|
42
|
+
}
|
|
43
|
+
export interface UnaryExpr {
|
|
44
|
+
kind: "UnaryExpr";
|
|
45
|
+
op: string;
|
|
46
|
+
operand: Node;
|
|
47
|
+
line: number;
|
|
48
|
+
}
|
|
49
|
+
export interface LogicalExpr {
|
|
50
|
+
kind: "LogicalExpr";
|
|
51
|
+
op: string;
|
|
52
|
+
left: Node;
|
|
53
|
+
right: Node;
|
|
54
|
+
line: number;
|
|
55
|
+
}
|
|
56
|
+
export interface PipeExpr {
|
|
57
|
+
kind: "PipeExpr";
|
|
58
|
+
left: Node;
|
|
59
|
+
right: Node;
|
|
60
|
+
line: number;
|
|
61
|
+
}
|
|
62
|
+
export interface AssignExpr {
|
|
63
|
+
kind: "AssignExpr";
|
|
64
|
+
target: Node;
|
|
65
|
+
value: Node;
|
|
66
|
+
line: number;
|
|
67
|
+
}
|
|
68
|
+
export interface CallExpr {
|
|
69
|
+
kind: "CallExpr";
|
|
70
|
+
callee: Node;
|
|
71
|
+
args: Node[];
|
|
72
|
+
line: number;
|
|
73
|
+
}
|
|
74
|
+
export interface IndexExpr {
|
|
75
|
+
kind: "IndexExpr";
|
|
76
|
+
object: Node;
|
|
77
|
+
index: Node;
|
|
78
|
+
line: number;
|
|
79
|
+
}
|
|
80
|
+
export interface MemberExpr {
|
|
81
|
+
kind: "MemberExpr";
|
|
82
|
+
object: Node;
|
|
83
|
+
property: string;
|
|
84
|
+
line: number;
|
|
85
|
+
}
|
|
86
|
+
export interface ArrayLiteral {
|
|
87
|
+
kind: "ArrayLiteral";
|
|
88
|
+
elements: Node[];
|
|
89
|
+
line: number;
|
|
90
|
+
}
|
|
91
|
+
export interface ObjectLiteral {
|
|
92
|
+
kind: "ObjectLiteral";
|
|
93
|
+
properties: {
|
|
94
|
+
key: string;
|
|
95
|
+
value: Node;
|
|
96
|
+
}[];
|
|
97
|
+
line: number;
|
|
98
|
+
}
|
|
99
|
+
export interface SpreadExpr {
|
|
100
|
+
kind: "SpreadExpr";
|
|
101
|
+
expr: Node;
|
|
102
|
+
line: number;
|
|
103
|
+
}
|
|
104
|
+
export interface FnExpr {
|
|
105
|
+
kind: "FnExpr";
|
|
106
|
+
params: string[];
|
|
107
|
+
body: Node;
|
|
108
|
+
line: number;
|
|
109
|
+
}
|
|
110
|
+
export interface LetDecl {
|
|
111
|
+
kind: "LetDecl";
|
|
112
|
+
name: string;
|
|
113
|
+
value: Node;
|
|
114
|
+
line: number;
|
|
115
|
+
}
|
|
116
|
+
export interface FnDecl {
|
|
117
|
+
kind: "FnDecl";
|
|
118
|
+
name: string;
|
|
119
|
+
params: string[];
|
|
120
|
+
body: Node;
|
|
121
|
+
line: number;
|
|
122
|
+
}
|
|
123
|
+
export interface ReturnStmt {
|
|
124
|
+
kind: "ReturnStmt";
|
|
125
|
+
value: Node | null;
|
|
126
|
+
line: number;
|
|
127
|
+
}
|
|
128
|
+
export interface IfStmt {
|
|
129
|
+
kind: "IfStmt";
|
|
130
|
+
condition: Node;
|
|
131
|
+
then: Node;
|
|
132
|
+
otherwise: Node | null;
|
|
133
|
+
line: number;
|
|
134
|
+
}
|
|
135
|
+
export interface WhileStmt {
|
|
136
|
+
kind: "WhileStmt";
|
|
137
|
+
condition: Node;
|
|
138
|
+
body: Node;
|
|
139
|
+
line: number;
|
|
140
|
+
}
|
|
141
|
+
export interface ForInStmt {
|
|
142
|
+
kind: "ForInStmt";
|
|
143
|
+
variable: string;
|
|
144
|
+
iterable: Node;
|
|
145
|
+
body: Node;
|
|
146
|
+
line: number;
|
|
147
|
+
}
|
|
148
|
+
export interface BlockStmt {
|
|
149
|
+
kind: "BlockStmt";
|
|
150
|
+
body: Node[];
|
|
151
|
+
line: number;
|
|
152
|
+
}
|
|
153
|
+
export interface ExprStmt {
|
|
154
|
+
kind: "ExprStmt";
|
|
155
|
+
expr: Node;
|
|
156
|
+
line: number;
|
|
157
|
+
}
|
|
158
|
+
export interface BreakStmt {
|
|
159
|
+
kind: "BreakStmt";
|
|
160
|
+
line: number;
|
|
161
|
+
}
|
|
162
|
+
export interface ContinueStmt {
|
|
163
|
+
kind: "ContinueStmt";
|
|
164
|
+
line: number;
|
|
165
|
+
}
|
package/dist/src/ast.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../../src/ast.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type AzkalValue = number | string | boolean | null | AzkalValue[] | AzkalObject | AzkalFunction | AzkalNativeFunction;
|
|
2
|
+
export interface AzkalObject {
|
|
3
|
+
type: "object";
|
|
4
|
+
properties: Map<string, AzkalValue>;
|
|
5
|
+
}
|
|
6
|
+
export interface AzkalFunction {
|
|
7
|
+
type: "function";
|
|
8
|
+
name: string;
|
|
9
|
+
params: string[];
|
|
10
|
+
body: any;
|
|
11
|
+
closure: Environment;
|
|
12
|
+
}
|
|
13
|
+
export interface AzkalNativeFunction {
|
|
14
|
+
type: "native";
|
|
15
|
+
name: string;
|
|
16
|
+
arity: number | -1;
|
|
17
|
+
call: (args: AzkalValue[]) => AzkalValue;
|
|
18
|
+
}
|
|
19
|
+
export declare class Environment {
|
|
20
|
+
parent: Environment | null;
|
|
21
|
+
private values;
|
|
22
|
+
constructor(parent?: Environment | null);
|
|
23
|
+
define(name: string, value: AzkalValue): void;
|
|
24
|
+
get(name: string, line: number): AzkalValue;
|
|
25
|
+
set(name: string, value: AzkalValue, line: number): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { RuntimeError } from "./errors.js";
|
|
2
|
+
export class Environment {
|
|
3
|
+
parent;
|
|
4
|
+
values = new Map();
|
|
5
|
+
constructor(parent = null) {
|
|
6
|
+
this.parent = parent;
|
|
7
|
+
}
|
|
8
|
+
define(name, value) {
|
|
9
|
+
this.values.set(name, value);
|
|
10
|
+
}
|
|
11
|
+
get(name, line) {
|
|
12
|
+
if (this.values.has(name))
|
|
13
|
+
return this.values.get(name);
|
|
14
|
+
if (this.parent)
|
|
15
|
+
return this.parent.get(name, line);
|
|
16
|
+
throw new RuntimeError(`Undefined variable '${name}'`, line, 0);
|
|
17
|
+
}
|
|
18
|
+
set(name, value, line) {
|
|
19
|
+
if (this.values.has(name)) {
|
|
20
|
+
this.values.set(name, value);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (this.parent) {
|
|
24
|
+
this.parent.set(name, value, line);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
throw new RuntimeError(`Undefined variable '${name}' — use 'let' to declare it first`, line, 0);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=environment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../src/environment.ts"],"names":[],"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|
+
line: number;
|
|
3
|
+
col: number;
|
|
4
|
+
source?: string | undefined;
|
|
5
|
+
constructor(message: string, line: number, col: number, source?: string | undefined);
|
|
6
|
+
format(filename?: string): string;
|
|
7
|
+
}
|
|
8
|
+
export declare class LexerError extends AzkalError {
|
|
9
|
+
constructor(message: string, line: number, col: number);
|
|
10
|
+
}
|
|
11
|
+
export declare class ParseError extends AzkalError {
|
|
12
|
+
constructor(message: string, line: number, col: number);
|
|
13
|
+
}
|
|
14
|
+
export declare class RuntimeError extends AzkalError {
|
|
15
|
+
constructor(message: string, line: number, col: number);
|
|
16
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export class AzkalError extends Error {
|
|
2
|
+
line;
|
|
3
|
+
col;
|
|
4
|
+
source;
|
|
5
|
+
constructor(message, line, col, source) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.line = line;
|
|
8
|
+
this.col = col;
|
|
9
|
+
this.source = source;
|
|
10
|
+
this.name = "AzkalError";
|
|
11
|
+
}
|
|
12
|
+
format(filename) {
|
|
13
|
+
const loc = filename ? `${filename}:${this.line}:${this.col}` : `line ${this.line}, col ${this.col}`;
|
|
14
|
+
return `\x1b[31merror\x1b[0m: ${this.message}\n \x1b[90m--> ${loc}\x1b[0m`;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export class LexerError extends AzkalError {
|
|
18
|
+
constructor(message, line, col) {
|
|
19
|
+
super(message, line, col);
|
|
20
|
+
this.name = "LexerError";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export class ParseError extends AzkalError {
|
|
24
|
+
constructor(message, line, col) {
|
|
25
|
+
super(message, line, col);
|
|
26
|
+
this.name = "ParseError";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export class RuntimeError extends AzkalError {
|
|
30
|
+
constructor(message, line, col) {
|
|
31
|
+
super(message, line, col);
|
|
32
|
+
this.name = "RuntimeError";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+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E,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
import { Lexer } from "./lexer.js";
|
|
5
|
+
import { Parser } from "./parser.js";
|
|
6
|
+
import { Interpreter } from "./interpreter.js";
|
|
7
|
+
import { AzkalError } from "./errors.js";
|
|
8
|
+
import { startRepl } from "./repl.js";
|
|
9
|
+
const VERSION = "0.1.0";
|
|
10
|
+
function runFile(filepath) {
|
|
11
|
+
const resolved = path.resolve(filepath);
|
|
12
|
+
if (!fs.existsSync(resolved)) {
|
|
13
|
+
console.error(`\x1b[31merror\x1b[0m: File not found: ${filepath}`);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
const source = fs.readFileSync(resolved, "utf-8");
|
|
17
|
+
const filename = path.basename(filepath);
|
|
18
|
+
try {
|
|
19
|
+
const tokens = new Lexer(source).tokenize();
|
|
20
|
+
const ast = new Parser(tokens).parse();
|
|
21
|
+
const interpreter = new Interpreter();
|
|
22
|
+
interpreter.run(ast);
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
if (e instanceof AzkalError) {
|
|
26
|
+
console.error(e.format(filename));
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
throw e;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function main() {
|
|
33
|
+
const args = process.argv.slice(2);
|
|
34
|
+
if (args.length === 0) {
|
|
35
|
+
startRepl();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (args[0] === "--version" || args[0] === "-v") {
|
|
39
|
+
console.log(`azkal ${VERSION}`);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (args[0] === "--help" || args[0] === "-h") {
|
|
43
|
+
console.log(`
|
|
44
|
+
\x1b[36mazkal\x1b[0m ${VERSION} — The Azkal Programming Language
|
|
45
|
+
|
|
46
|
+
\x1b[1mUSAGE:\x1b[0m
|
|
47
|
+
azkal Start the interactive REPL
|
|
48
|
+
azkal <file> Run an .azkal file
|
|
49
|
+
azkal --version Show version
|
|
50
|
+
azkal --help Show this help
|
|
51
|
+
|
|
52
|
+
\x1b[1mEXAMPLES:\x1b[0m
|
|
53
|
+
azkal hello.azkal
|
|
54
|
+
azkal examples/fibonacci.azkal
|
|
55
|
+
`);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
runFile(args[0]);
|
|
59
|
+
}
|
|
60
|
+
main();
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,OAAO,GAAG,OAAO,CAAC;AAExB,SAAS,OAAO,CAAC,QAAgB;IAC/B,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAExC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,OAAO,CAAC,KAAK,CAAC,yCAAyC,QAAQ,EAAE,CAAC,CAAC;QACnE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,MAAM,GAAG,EAAE,CAAC,YAAY,CA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AO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC;AAED,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as AST from "./ast.js";
|
|
2
|
+
import { Environment, AzkalValue } from "./environment.js";
|
|
3
|
+
export declare class Interpreter {
|
|
4
|
+
globals: Environment;
|
|
5
|
+
output: string[];
|
|
6
|
+
constructor(captureOutput?: boolean);
|
|
7
|
+
run(program: AST.Program): AzkalValue;
|
|
8
|
+
exec(node: AST.Node, env: Environment): AzkalValue;
|
|
9
|
+
private execProgram;
|
|
10
|
+
private execTemplate;
|
|
11
|
+
private execBinary;
|
|
12
|
+
private execUnary;
|
|
13
|
+
private execLogical;
|
|
14
|
+
private execPipe;
|
|
15
|
+
private execAssign;
|
|
16
|
+
private execCall;
|
|
17
|
+
private execIndex;
|
|
18
|
+
private execMember;
|
|
19
|
+
private execArray;
|
|
20
|
+
private execObject;
|
|
21
|
+
private execFnExpr;
|
|
22
|
+
private execLet;
|
|
23
|
+
private execFnDecl;
|
|
24
|
+
private execIf;
|
|
25
|
+
private execWhile;
|
|
26
|
+
private execForIn;
|
|
27
|
+
private execBlock;
|
|
28
|
+
private callValue;
|
|
29
|
+
private isAzkalObject;
|
|
30
|
+
private isEqual;
|
|
31
|
+
isTruthy(val: AzkalValue): boolean;
|
|
32
|
+
stringify(val: AzkalValue): string;
|
|
33
|
+
private assertNumbers;
|
|
34
|
+
}
|