Skip to content

Commit a347396

Browse files
committed
remove watch mode
1 parent 4431c87 commit a347396

File tree

3 files changed

+11
-22
lines changed

3 files changed

+11
-22
lines changed

src/ast.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,16 @@ export namespace syxparser {
4444

4545
let program: ProgramStatement;
4646

47-
let watchMode: boolean;
48-
4947
/**
5048
* Parses the token list given into statements and expressions.
5149
* @param {Token[]} t Token list to parse.
52-
* @param {boolean} watch Whether is it watch mode or not. Errors will exit process if it isn't watch mode, throwing an error otherwise.
5350
* @returns Main {@link ProgramStatement} containing all other statements.
5451
* @author efekos
55-
* @version 1.0.1
52+
* @version 1.0.2
5653
* @since 0.0.1-alpha
5754
*/
58-
export function parseTokens(t: Token[], watch: boolean): ProgramStatement {
55+
export function parseTokens(t: Token[]): ProgramStatement {
5956
tokens = t;
60-
watchMode = watch;
6157

6258
const eof = t.find(r => r.type === TokenType.EndOfFile);
6359
program = { body: [], type: NodeType.Program, range: { end: eof.range.end, start: { line: 0, character: 0 } } };
@@ -398,7 +394,6 @@ export namespace sysparser {
398394
}
399395

400396
let program: ProgramStatement;
401-
let watchMode: boolean;
402397

403398
/**
404399
* Combines the start of first range with the end of second range to create a range.
@@ -415,15 +410,13 @@ export namespace sysparser {
415410
/**
416411
* Parses the token list given into statements and expressions.
417412
* @param {Token[]} t Token list to parse.
418-
* @param {boolean} watch Whether is it watch mode or not. Errors will exit process if it isn't watch mode, throwing an error otherwise.
419413
* @returns Main {@link ProgramStatement} containing all other statements.
420414
* @author efekos
421-
* @version 1.0.0
415+
* @version 1.0.1
422416
* @since 0.0.1-alpha
423417
*/
424-
export function parseTokens(t: Token[], watch: boolean): ProgramStatement {
418+
export function parseTokens(t: Token[]): ProgramStatement {
425419
tokens = t;
426-
watchMode = watch;
427420

428421
const eof = t.find(r => r.type === TokenType.EndOfFile);
429422
program = { body: [], type: NodeType.Program, range: {start:{character:0,line:0},end:eof.range.end}};

src/compiler.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export class SyntaxScriptCompiler {
1414
private readonly rootDir: string;
1515
private readonly outDir: string;
1616
private readonly mainFileFormat: string;
17-
private readonly watchMode: boolean;
1817

1918
public readonly exportData: Record<string, AnyExportable[]> = {};
2019

@@ -23,16 +22,14 @@ export class SyntaxScriptCompiler {
2322
* @param {string} rootDir Root dir to search for source files.
2423
* @param {string} outDir Out dir to write compiled files.
2524
* @param {string} format File format to compile.
26-
* @param {boolean} watch Whether is it watch mode or not. Will affect how errors are handled.
2725
* @author efekos
28-
* @version 1.0.0
26+
* @version 1.0.1
2927
* @since 0.0.1-alpha
3028
*/
31-
constructor(rootDir: string, outDir: string, format: string, watch: boolean = false) {
29+
constructor(rootDir: string, outDir: string, format: string) {
3230
this.rootDir = join(process.cwd(), rootDir);
3331
this.outDir = join(process.cwd(), outDir);
3432
this.mainFileFormat = format;
35-
this.watchMode = watch;
3633
}
3734

3835
/**
@@ -72,7 +69,7 @@ export class SyntaxScriptCompiler {
7269
* @since 0.0.1-alpha
7370
*/
7471
public compileSyx(file: string) {
75-
const ast = syxparser.parseTokens(tokenizeSyx(readFileSync(file).toString(), this.watchMode), this.watchMode);
72+
const ast = syxparser.parseTokens(tokenizeSyx(readFileSync(file).toString()));
7673
const out: AnyExportable[] = [];
7774

7875
ast.body.forEach(statement => {
@@ -200,7 +197,7 @@ export class SyntaxScriptCompiler {
200197
* @version 1.0.2
201198
*/
202199
public compileSys(file: string) {
203-
const ast = sysparser.parseTokens(tokenizeSys(readFileSync(file).toString()), this.watchMode);
200+
const ast = sysparser.parseTokens(tokenizeSys(readFileSync(file).toString()));
204201

205202
//# Handle import statements
206203
var imported: AnyExportable[] = [];

src/lexer.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,13 @@ function tpr(start: Position, end: Position): Range {
6767
/**
6868
* Tokenizes a .syx file.
6969
* @param {string} source Source string.
70-
* @param {boolean} watchMode Whether is it watch mode or not. Errors will throw an error instead of exiting if this value is set to `true`.
7170
* @returns A list of tokens generated from source string.
7271
* @author efekos
73-
* @version 1.0.5
72+
* @version 1.0.6
7473
* @since 0.0.1-alpha
7574
* @throws LexerError if an error occurs.
7675
*/
77-
export function tokenizeSyx(source: string, watchMode: boolean): Token[] {
76+
export function tokenizeSyx(source: string): Token[] {
7877
const tokens: Token[] = [];
7978
const src = source.split('');
8079
let curPos = 0;
@@ -138,7 +137,7 @@ export function tokenizeSyx(source: string, watchMode: boolean): Token[] {
138137
/**
139138
* Tokenizes a .sys file. Stops when the file end marker (:::) is encountered.
140139
* @param {string} source Source string.
141-
* @returns A list of tokens generated from th esource file.
140+
* @returns A list of tokens generated from the source file.
142141
* @author efekos
143142
* @version 1.0.3
144143
* @since 0.0.1-alpha

0 commit comments

Comments
 (0)