Skip to content

Commit

Permalink
Merge pull request #3 from ing-bank/clean-references
Browse files Browse the repository at this point in the history
Clean old references and fix findings.
  • Loading branch information
mreitsmaing committed Nov 24, 2023
2 parents 6c6e2de + 002051d commit 0b765c2
Show file tree
Hide file tree
Showing 23 changed files with 195 additions and 119 deletions.
21 changes: 21 additions & 0 deletions .dictionaries/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Dictionaries

This folder contains dictionaries to be used by spell checkers programs to
validate the special words used in this project.

## Available dictionaries

### Words

Contains words used in this project.

File: [words.dic](words.dic)

## File format

Plain text files with the dic extension, containing words separated with a
newline.

## Adding words guidelines

Please only add words that make sense, and in the appropriate dictionary.
4 changes: 4 additions & 0 deletions .dictionaries/words.dic
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CLASSDEF
ENDDOC
PROPERTYDEF
REVHIST
2 changes: 1 addition & 1 deletion .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ jobs:
node-version: '16.x'
cache: 'npm'
- run: npm install
- run: npm run compile
- run: npm run build
- run: npm test
17 changes: 9 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
*.jrnl
*.log
out
node_modules
*.vsix
.project
.settings
.classpath
# Dependency directory
node_modules/

# Editors
.idea/

# Project build
lib/
*.tgz
17 changes: 12 additions & 5 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
*.ts
!*.d.ts
tsconfig.json
*.tgz
.npmrc*
# Exclude all files
*

# Add lib/
!lib/**
# Exclude exceptions from lib/
*.map
*.tsbuildinfo

# Add documentation
!LICENSE
!CHANGELOG.md
!README.md
4 changes: 4 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
always-auth=true
registry=https://registry.npmjs.org
//registry.npmjs.org/:_authToken=${PARSER_TOKEN}
//registry.npmjs.org/:username=${PARSER_USER}
9 changes: 4 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
"lib": false
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
"lib": true
},
"editor.rulers": [120] // Recommended typescript ruler
}
"editor.rulers": [120]
}
25 changes: 25 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 12 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,27 @@
"scripting",
"language"
],
"homepage": "https://github.com/ing-bank/vscode-psl#readme",
"homepage": "https://github.com/ing-bank/psl-parser#readme",
"bugs": {
"url": "https://github.com/ing-bank/vscode-psl/issues"
"url": "https://github.com/ing-bank/psl-parser/issues"
},
"license": "MIT",
"author": "atiplea",
"contributors": [
"SOliveira"
],
"main": "out/index.js",
"main": "lib/index.js",
"types": "lib/types/index.js",
"repository": {
"type": "git",
"url": "https://github.com/ing-bank/vscode-psl.git"
"url": "https://github.com/ing-bank/psl-parser.git"
},
"scripts": {
"compile": "tsc -p ./",
"watch": "npm run compile -- -watch",
"prebuild": "rimraf lib",
"build": "tsc --build src",
"lint": "tslint -c tslint.json --project .",
"watch": "npm run build -- -watch",
"pretest": "tsc --build src",
"test": "jest"
},
"dependencies": {
Expand All @@ -39,6 +43,7 @@
"ts-jest": "^29.0.3",
"tslint": "^5.20.1",
"typescript": "^4.8.4",
"jsonc-parser": "^3.2.0"
"jsonc-parser": "^3.2.0",
"rimraf": "^3.0.2"
}
}
File renamed without changes.
File renamed without changes.
13 changes: 8 additions & 5 deletions src/parser/parser.ts → src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export interface ParsedDocument {
declarations: Declaration[];

/**
* An array of PROPERTYDEFs
* An array of PROPERTYDEF
*/
properties: Property[];

Expand Down Expand Up @@ -328,16 +328,17 @@ class Parser {
if (documentation) this.activeMethod.documentation = documentation;
}
}
else if (this.activeToken.isNewLine()) continue;
else this.throwAwayTokensTil(Type.NewLine);
else if (!this.activeToken.isNewLine()) {
this.throwAwayTokensTil(Type.NewLine);
}
}
return {
comments: this.comments,
declarations: this.declarations,
extending: this.extending,
pslPackage: this.pslPackage,
methods: this.methods,
properties: this.properties,
pslPackage: this.pslPackage,
tokens: this.tokens,
};
}
Expand Down Expand Up @@ -580,7 +581,9 @@ class Parser {
}

private throwAwayTokensTil(type: Type) {
while (this.next() && this.activeToken.type !== type);
while (this.next()) {
if (this.activeToken.type === type) break;
}
}

private loadTokenBuffer() {
Expand Down
8 changes: 4 additions & 4 deletions src/parser/statementParser.ts → src/statementParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getTokens, Token, Type } from './tokenizer';
import {getTokens, Token, Type} from './tokenizer';

export enum SyntaxKind {
ASSIGNMENT,
Expand Down Expand Up @@ -402,7 +402,7 @@ export class StatementParser {
const spaceOrExpression = this.activeToken;
if (spaceOrExpression.isSpace()) {
this.next();
return forStatement; // argumentless for
return forStatement; // argument less for
}
const expression = this.parseExpression();
if (expression) forStatement.expressions.push(expression);
Expand Down Expand Up @@ -484,13 +484,12 @@ export class StatementParser {
while (this.activeToken && this.activeToken.isColon()) {
const colonToken = this.activeToken;
this.next(true);
const colon: BinaryOperator = {
rootNode = {
kind: SyntaxKind.BINARY_OPERATOR,
left: rootNode,
operator: [colonToken],
right: this.parseValue(),
};
rootNode = colon;
}
return rootNode;
}
Expand Down Expand Up @@ -747,6 +746,7 @@ export function forEachChild(node: Node, f: (n: Node) => boolean) {
const declaration = node as DeclarationStatement;
if (declaration.args) declaration.args.forEach(arg => forEachChild(arg, f));
f(declaration.type);
break;
case SyntaxKind.NUMERIC_LITERAL:
case SyntaxKind.STRING_LITERAL:
f(node);
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../tsconfig-base.json",
"compilerOptions": {
"composite": true,
}
}

File renamed without changes.
18 changes: 9 additions & 9 deletions test/parser.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as parser from '../src/parser/parser';
import * as tokenizer from '../src/parser/tokenizer';
import * as parser from '../src/parser';
import * as tokenizer from '../src/tokenizer';

function getMethod(methodString: string): parser.Method | undefined {
const d = parser.parseText(methodString);
Expand Down Expand Up @@ -209,7 +209,7 @@ describe('Argument Names', () => {
expect(argNameValues).toEqual(['x1', 'x2']);
});

test('1 argument multitype', () => {
test('1 argument multi type', () => {
const methodString = 'public static void main(void x1(Integer, Record))';
const result = getMethod(methodString);
if (!result) {
Expand All @@ -220,7 +220,7 @@ describe('Argument Names', () => {
expect(argNameValues).toEqual(['x1']);
});

test('2 argument multitype', () => {
test('2 argument multi type', () => {
const methodString = 'public static void main(void x1(Integer, Record), void x2(void, String))';
const result = getMethod(methodString);
if (!result) {
Expand All @@ -231,7 +231,7 @@ describe('Argument Names', () => {
expect(argNameValues).toEqual(['x1', 'x2']);
});

test('2 argument multitype', () => {
test('2 argument multiline and multi type', () => {
const methodString = 'public static void main(void x1(Integer, Record)\n\t, void x2(void, String))';
const result = getMethod(methodString);
if (!result) {
Expand Down Expand Up @@ -299,7 +299,7 @@ describe('Argument Types', () => {
expect(argValues).toEqual([['String']]);
});

test('1 argument multitype', () => {
test('1 argument multi type', () => {
const methodString = 'public static void main(String x1(Number))';
const result = getMethod(methodString);
if (!result) {
Expand Down Expand Up @@ -681,15 +681,15 @@ describe('type declarations', () => {
expect(doc.declarations[0].types[0].value).toEqual('String');
expect(doc.declarations[0].id.value).toEqual('x');
});
test('mutliple type declaration', () => {
test('multiple type declaration', () => {
const declarationString = '\ttype public literal String x,y';
const doc = getParsedDoc(declarationString);
expect(doc.declarations[0].types[0].value).toEqual('String');
expect(doc.declarations[0].id.value).toEqual('x');
expect(doc.declarations[1].types[0].value).toEqual('String');
expect(doc.declarations[1].id.value).toEqual('y');
});
test('mutliple multitype type declaration', () => {
test('multiple multi type type declaration', () => {
const declarationString = '\ttype public literal String x(Number,Boolean),y';
const doc = getParsedDoc(declarationString);
expect(doc.declarations[0].types[0].value).toEqual('String');
Expand All @@ -699,7 +699,7 @@ describe('type declarations', () => {
expect(doc.declarations[1].types[0].value).toEqual('String');
expect(doc.declarations[1].id.value).toEqual('y');
});
test('mutliple type declaration equal sign', () => {
test('multiple type declaration equal sign', () => {
const declarationString = '\ttype String x = "hi", y = "hi"';
const doc = getParsedDoc(declarationString);
expect(doc.declarations[0].types[0].value).toEqual('String');
Expand Down
14 changes: 7 additions & 7 deletions test/statementParser.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
BinaryOperator, DeclarationStatement, Expression, Identifier, MultiSet, NumericLiteral,
PostCondition, Statement, StatementParser, StringLiteral, SyntaxKind, TypeIdentifier, Value,
} from '../src/parser/statementParser';
import { getTokens, Token } from '../src/parser/tokenizer';
} from '../src';
import { getTokens, Token } from '../src/tokenizer';

function parse(text: string) {
return new StatementParser(getTokens(text));
Expand Down Expand Up @@ -126,18 +126,18 @@ describe('recursive tests', () => {
expect(start.id).toBe(parser.tokens[2]);
});
test('Runtime start', () => {
const parser = parse('Runtime.start("BA",varlist)');
const parser = parse('Runtime.start("BA",varList)');
const dotNode = parser.parseExpression() as BinaryOperator;
const runtime = dotNode.left as Identifier;
const start = dotNode.right as Identifier;
const args = start.args as Value[];
const ba = args[0];
const varlist = args[1];
const varList = args[1];
expect(dotNode.kind === SyntaxKind.BINARY_OPERATOR);
expect(runtime.id).toBe(parser.tokens[0]);
expect((start).id).toBe(parser.tokens[2]);
expect(ba.id).toBe(parser.tokens[5]);
expect(varlist.id).toBe(parser.tokens[8]);
expect(varList.id).toBe(parser.tokens[8]);
});
test('grandchild', () => {
const parser = parse('a.b.c');
Expand Down Expand Up @@ -545,7 +545,7 @@ describe('recursive tests', () => {
expect(i.id.value).toBe('i');
expect(initial.id.value).toBe('1');
});
test('argumentless for loop', () => {
test('argument less for loop', () => {
const parser = parse('for set x = 1');
const statements = parser.parseLine();
const forStatement = statements[0];
Expand All @@ -563,7 +563,7 @@ describe('recursive tests', () => {
expect(args.length).toBe(3);
});
test('for order', () => {
const parser = parse('for set seq=tras(seq).order() quit:seq.isNull() do set(tras(seq))');
const parser = parse('for set seq=array(seq).order() quit:seq.isNull() do set(array(seq))');
const statements = parser.parseLine();
const setStatement = statements[1];
const equal = setStatement.expressions[0] as BinaryOperator;
Expand Down

0 comments on commit 0b765c2

Please sign in to comment.