Skip to content

Commit

Permalink
Fix parser packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
beikov committed Feb 15, 2021
1 parent fead5d2 commit 4f6c8d4
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 49 deletions.
7 changes: 0 additions & 7 deletions editor/monaco/package-lock.json

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

1 change: 0 additions & 1 deletion editor/monaco/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"devDependencies": {
"@types/chai": "^4.2.11",
"@types/mocha": "^7.0.2",
"blaze-expression-predicate": "file:./target/blaze-expression-predicate/",
"chai": "4.1.2",
"css-loader": "^3.5.3",
"esm": "^3.2.25",
Expand Down
10 changes: 4 additions & 6 deletions editor/monaco/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@
<include name="*.g4" />
</fileset>
</copy>
<copy todir="${project.build.directory}/blaze-expression-predicate">
<fileset dir="${project.basedir}/src/main/antlr4">
<include name="*.json" />
</fileset>
</copy>
</target>
</configuration>
<goals>
Expand Down Expand Up @@ -171,10 +166,13 @@
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/dist/blaze-expression-predicate</outputDirectory>
<outputDirectory>${basedir}/dist</outputDirectory>
<resources>
<resource>
<directory>${project.build.directory}/blaze-expression-predicate</directory>
<includes>
<include>**/*.js</include>
</includes>
</resource>
</resources>
</configuration>
Expand Down
12 changes: 0 additions & 12 deletions editor/monaco/src/main/antlr4/package.json

This file was deleted.

44 changes: 22 additions & 22 deletions editor/monaco/src/main/typescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ import {
import {CommonTokenStream, error, InputStream, Parser, ParserRuleContext, Token} from 'antlr4/index.js'
import {TerminalNode} from 'antlr4/tree/Tree.js'
import {DefaultErrorStrategy} from 'antlr4/error/ErrorStrategy.js'
import {BlazeExpressionLexer} from "blaze-expression-predicate/BlazeExpressionLexer.js"
import {BlazeExpressionParser} from "blaze-expression-predicate/BlazeExpressionParser.js"
import {BlazeExpressionParserVisitor} from "blaze-expression-predicate/BlazeExpressionParserVisitor.js"
import {BlazeExpressionLexer} from "./BlazeExpressionLexer.js"
import {BlazeExpressionParser} from "./BlazeExpressionParser.js"
import {BlazeExpressionParserVisitor} from "./BlazeExpressionParserVisitor.js"

let symbolTables: StringMap<SymbolTable> = {};

Expand Down Expand Up @@ -1114,15 +1114,15 @@ class CollectorErrorListener extends error.ErrorListener {

}

export function createLexer(input: String) {
function createLexer(input: String) {
const chars = new InputStream(input);
const lexer = new BlazeExpressionLexer(chars);
return lexer;
}

export function getTokens(input: String) : Token[] {
return createLexer(input).getAllTokens()
}
// function getTokens(input: String) : Token[] {
// return createLexer(input).getAllTokens()
// }

function createParser(input) {
const lexer = createLexer(input);
Expand All @@ -1140,19 +1140,19 @@ function parseTree(input) {
return parser.parsePredicateOrExpression();
}

export function parseTreeStr(input) {
const lexer = createLexer(input);
lexer.removeErrorListeners();
lexer.addErrorListener(new ConsoleErrorListener());

const parser = createParserFromLexer(lexer);
parser.removeErrorListeners();
parser.addErrorListener(new ConsoleErrorListener());

const tree = parser.parsePredicateOrExpression();

return tree.toStringTree(parser.ruleNames);
}
// function parseTreeStr(input) {
// const lexer = createLexer(input);
// lexer.removeErrorListeners();
// lexer.addErrorListener(new ConsoleErrorListener());
//
// const parser = createParserFromLexer(lexer);
// parser.removeErrorListeners();
// parser.addErrorListener(new ConsoleErrorListener());
//
// const tree = parser.parsePredicateOrExpression();
//
// return tree.toStringTree(parser.ruleNames);
// }

class BlazeExpressionErrorStrategy extends DefaultErrorStrategy {

Expand Down Expand Up @@ -1187,7 +1187,7 @@ class BlazeExpressionErrorStrategy extends DefaultErrorStrategy {

}

export function resolveType(input: string, symbolTable: SymbolTable) : DomainType {
function resolveType(input: string, symbolTable: SymbolTable) : DomainType {
const lexer = createLexer(input);
lexer.removeErrorListeners();
lexer.addErrorListener(new ConsoleErrorListener());
Expand All @@ -1204,7 +1204,7 @@ export function resolveType(input: string, symbolTable: SymbolTable) : DomainTyp
}
}

export function validate(input: string, symbolTable: SymbolTable, expectedResultTypes: string[], errorMessage: string) : ErrorEntry[] {
function validate(input: string, symbolTable: SymbolTable, expectedResultTypes: string[], errorMessage: string) : ErrorEntry[] {
let errors : ErrorEntry[] = [];

const lexer = createLexer(input);
Expand Down
5 changes: 4 additions & 1 deletion editor/monaco/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
"moduleResolution": "node",
"declaration": true,
"target": "es5",
"outDir": "dist"
"outDir": "dist",
"rootDirs": [
"src/main/typescript", "target/blaze-expression-predicate"
]
},
"exclude": [
"node_modules",
Expand Down

0 comments on commit 4f6c8d4

Please sign in to comment.