Skip to content

Commit c8704a9

Browse files
committed
format code
1 parent 2c49915 commit c8704a9

File tree

8 files changed

+24
-24
lines changed

8 files changed

+24
-24
lines changed

src/ast.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const caf = {
1818
edit: {
1919
changes: {
2020
[filePath]: [{
21-
range:subRange(range),
21+
range: subRange(range),
2222
newText: word
2323
}]
2424
}
@@ -508,7 +508,7 @@ export namespace syxparser {
508508

509509
export namespace sysparser {
510510

511-
511+
512512
//#
513513
//# STATEMENT PARSERS
514514
//#
@@ -524,7 +524,7 @@ export namespace sysparser {
524524
return node({ type: NodeType.Import, path: (ex as Expression).value, range: combineTwo(token, ex.range) }, put);
525525
}
526526

527-
//#
527+
//#
528528
//# EXPRESSION PARSERS
529529
//#
530530
/**

src/compiler.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class SyntaxScriptCompiler {
6969
* @since 0.0.1-alpha
7070
*/
7171
public compileSyx(file: string) {
72-
const ast = syxparser.parseTokens(tokenizeSyx(readFileSync(file).toString()),file);
72+
const ast = syxparser.parseTokens(tokenizeSyx(readFileSync(file).toString()), file);
7373
const out: AnyExportable[] = [];
7474

7575
ast.body.forEach(statement => {
@@ -197,7 +197,7 @@ export class SyntaxScriptCompiler {
197197
* @version 1.0.3
198198
*/
199199
public compileSys(file: string) {
200-
const ast = sysparser.parseTokens(tokenizeSys(readFileSync(file).toString()),file);
200+
const ast = sysparser.parseTokens(tokenizeSys(readFileSync(file).toString()), file);
201201

202202
//# Handle import statements
203203
var imported: AnyExportable[] = [];
@@ -232,11 +232,11 @@ export class SyntaxScriptCompiler {
232232
imported.forEach(i => {
233233

234234
if (i.type === ExportType.Operator) {
235-
if (i.outputGenerators[this.mainFileFormat] === undefined) throw new CompilerError({end:{character:0,line:0},start:{character:0,line:0}}, `Can't compile operator to target language (${this.mainFileFormat}).`);
235+
if (i.outputGenerators[this.mainFileFormat] === undefined) throw new CompilerError({ end: { character: 0, line: 0 }, start: { character: 0, line: 0 } }, `Can't compile operator to target language (${this.mainFileFormat}).`);
236236
fileContent = fileContent.replace(new RegExp(i.regexMatcher.source, 'g'), i.outputGenerators[this.mainFileFormat]);
237237
if (i.imports[this.mainFileFormat] !== undefined && !imports.includes(i.imports[this.mainFileFormat])) imports.push(i.imports[this.mainFileFormat]);
238238
} else if (i.type === ExportType.Function) {
239-
if (i.formatNames[this.mainFileFormat] === undefined) throw new CompilerError({end:{character:0,line:0},start:{character:0,line:0}}, `Can't compile function to target language (${this.mainFileFormat}).`);
239+
if (i.formatNames[this.mainFileFormat] === undefined) throw new CompilerError({ end: { character: 0, line: 0 }, start: { character: 0, line: 0 } }, `Can't compile function to target language (${this.mainFileFormat}).`);
240240
fileContent = fileContent.replace(new RegExp(i.name + '\\(' + i.args.map(m => m.source).join(',') + '\\)', 'g'), (m) => m.replace(i.name, i.formatNames[this.mainFileFormat]));
241241
}
242242

src/diagnostic.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CodeAction, CodeActionKind, Diagnostic, DiagnosticSeverity, DocumentDiagnosticReportKind, FullDocumentDiagnosticReport,Range } from 'lsp-types';
1+
import { CodeAction, CodeActionKind, Diagnostic, DiagnosticSeverity, DocumentDiagnosticReportKind, FullDocumentDiagnosticReport, Range } from 'lsp-types';
22
import { sysparser, syxparser } from './ast.js';
33
import { tokenizeSys, tokenizeSyx } from './lexer.js';
44
import { isCompilerError } from './types.js';
@@ -21,7 +21,7 @@ export function createSyntaxScriptDiagnosticReport(filePath: string, fileContent
2121

2222
const content = fileContent ?? readFileSync(filePath).toString();
2323
const tokens = (isSyx ? tokenizeSyx : tokenizeSys)(content);
24-
(isSyx ? syxparser : sysparser).parseTokens(tokens,filePath);
24+
(isSyx ? syxparser : sysparser).parseTokens(tokens, filePath);
2525

2626
} catch (error) {
2727
if (isCompilerError(error)) {
@@ -48,11 +48,11 @@ export function createSyntaxScriptDiagnosticReport(filePath: string, fileContent
4848
* @version 1.0.0
4949
* @since 0.0.1-alpha
5050
*/
51-
export function subRange(r:Range):Range {
51+
export function subRange(r: Range): Range {
5252
const a = r.start.character;
5353
const b = r.start.line;
5454
const c = r.end.character;
5555
const d = r.end.line;
5656

57-
return {start:{character:a===0?0:a-1,line:b===0?0:b-1},end:{character:c===0?0:c-1,line:d===0?0:d-1}};
57+
return { start: { character: a === 0 ? 0 : a - 1, line: b === 0 ? 0 : b - 1 }, end: { character: c === 0 ? 0 : c - 1, line: d === 0 ? 0 : d - 1 } };
5858
}

src/dictionary/functionaries.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
export interface Functionary {
88
name: string;
9-
value:FunctionaryValueType;
9+
value: FunctionaryValueType;
1010
}
1111

1212
/**

src/dictionary/rules.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Value type of a rule.
33
*/
4-
export type RuleType = 'keyword'|'boolean';
4+
export type RuleType = 'keyword' | 'boolean';
55

66
/**
77
* Base interface for rules. Represents a rule that can be modified by any file using `rule` modifier.

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AnyExportable, Export, ExportType, Function, Keyword, OneParameterMethod, Operator, ReturnerMethod, SyntaxScriptCompiler, escapeRegex } from './compiler.js';
2-
import { BaseRule,BooleanRule,Functionary,FunctionaryValueType,Rule,RuleType,StringRule, dictionary } from './dictionary/index.js';
2+
import { BaseRule, BooleanRule, Functionary, FunctionaryValueType, Rule, RuleType, StringRule, dictionary } from './dictionary/index.js';
33
import { BraceExpression, CompileStatement, ExportStatement, Expression, FunctionStatement, ImportStatement, ImportsStatement, KeywordStatement, OperatorStatement, ParenExpression, PrimitiveTypeExpression, ProgramStatement, RuleStatement, SquareExpression, Statement, StringExpression, VariableExpression, WhitespaceIdentifierExpression } from './types.js';
44
import { CompilerError, isCompilerError } from './types.js';
55
import { Node, NodeType, Token, TokenType } from './types.js';
@@ -12,8 +12,8 @@ import { createSyntaxScriptDiagnosticReport } from './diagnostic.js';
1212
export { sysparser, syxparser, dictionary };
1313
export { escapeRegex, createSyntaxScriptDiagnosticReport, tokenizeSys, tokenizeSyx, isCompilerError };
1414

15-
export {BaseRule,BooleanRule,Rule,RuleType,StringRule};
16-
export {Functionary,FunctionaryValueType};
15+
export { BaseRule, BooleanRule, Rule, RuleType, StringRule };
16+
export { Functionary, FunctionaryValueType };
1717

1818

1919
export { SyntaxScriptCompiler, ExportType };

src/lexer.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export function tokenizeSyx(source: string): Token[] {
8181

8282
while (src.length > 0) {
8383
if (src[0] === '/' && src[1] === '/') {
84-
while (src.length > 0 && src[0] as string !== '\n' ) {
84+
while (src.length > 0 && src[0] as string !== '\n') {
8585
src.shift();
8686
}
8787
}
@@ -120,7 +120,7 @@ export function tokenizeSyx(source: string): Token[] {
120120
}
121121

122122
const reserved = keywords[ident];
123-
tokens.push({ type: reserved ?? TokenType.Identifier, value: ident, range:tpr(pos(curLine,startPos),pos(curLine,curPos))});
123+
tokens.push({ type: reserved ?? TokenType.Identifier, value: ident, range: tpr(pos(curLine, startPos), pos(curLine, curPos)) });
124124
} else if (isSkippable(src[0])) {
125125
src.shift();
126126
curPos++;
@@ -129,7 +129,7 @@ export function tokenizeSyx(source: string): Token[] {
129129
else tokens.push({ type: TokenType.Raw, value: src.shift(), range: opr(curLine, curPos++) });
130130
}
131131

132-
tokens.push({ type: TokenType.EndOfFile, value: 'EOF', range:opr(curLine,0)});
132+
tokens.push({ type: TokenType.EndOfFile, value: 'EOF', range: opr(curLine, 0) });
133133
return tokens;
134134
}
135135

@@ -161,7 +161,7 @@ export function tokenizeSys(source: string): Token[] {
161161
}
162162

163163
const reserved = keywords[ident];
164-
tokens.push({ type: reserved ?? TokenType.Identifier, value: ident, range:tpr(pos(curLine,startPos),pos(curLine,curPos)) });
164+
tokens.push({ type: reserved ?? TokenType.Identifier, value: ident, range: tpr(pos(curLine, startPos), pos(curLine, curPos)) });
165165
} else if (isSkippable(src[0])) {
166166
src.shift();
167167
curPos++;

src/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ export interface ProgramStatement extends Statement {
286286
*/
287287
export interface Statement {
288288
type: NodeType;
289-
range:Range;
289+
range: Range;
290290
}
291291

292292
/**
@@ -533,13 +533,13 @@ export class CompilerError extends Error {
533533
* @param {Range} range Range where the error is.
534534
* @param {string} message Error message.
535535
*/
536-
constructor(range: Range, message: string, file?: string,actions?:CodeAction[]) {
536+
constructor(range: Range, message: string, file?: string, actions?: CodeAction[]) {
537537
super();
538538
this.range = range;
539539
this.message = message;
540540
this.file = file;
541541
this.name = 'CompilerError';
542-
if(actions!==undefined) this.actions = actions;
542+
if (actions !== undefined) this.actions = actions;
543543
}
544544
}
545545

@@ -551,6 +551,6 @@ export class CompilerError extends Error {
551551
* @since 0.0.1-alpha
552552
* @returns Whether it is a {@link CompilerError} or not.
553553
*/
554-
export function isCompilerError(error:Error):error is CompilerError{
554+
export function isCompilerError(error: Error): error is CompilerError {
555555
return error.name === 'CompilerError';
556556
}

0 commit comments

Comments
 (0)