Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} catch (error) {
Object.assign(error, { varName, funcName, args, code })
console.warn(error)
log.push({
severity: 'warning',
msg: `Can't process function call: “${code}”.`
})
}
}
})
// Process the tree
const tree = parse(input)
const walker = new antlr4.tree.ParseTreeWalker()
walker.walk(printer, tree)
antlr4.tree.ParseTreeWalker.DEFAULT.walk(printer, tree)
// Prepare ports without IPs
const hostDevs = new Set()
links.forEach(link => hostDevs.add(link.from).add(link.to))
links.forEach(edge => {
edge.from = fixNextHostDev(hostDevs, edge.from)
edge.to = fixNextHostDev(hostDevs, edge.to)
})
links.forEach(edge => {
;[edge.from, edge.to].forEach(hostDev => {
const [nodename, portname] = hostDev.split('-')
ips.$push(nodename, portname, hostIPs[nodename] || [])
delete hostIPs[nodename]
})
})
// Generated from ./lang/presto/SqlBase.g4 by ANTLR 4.7
// jshint ignore: start
var antlr4 = require('antlr4');
// This class defines a complete listener for a parse tree produced by SqlBaseParser.
function SqlBaseListener() {
antlr4.tree.ParseTreeListener.call(this);
return this;
}
SqlBaseListener.prototype = Object.create(antlr4.tree.ParseTreeListener.prototype);
SqlBaseListener.prototype.constructor = SqlBaseListener;
// Enter a parse tree produced by SqlBaseParser#multiStatement.
SqlBaseListener.prototype.enterMultiStatement = function(ctx) {
};
// Exit a parse tree produced by SqlBaseParser#multiStatement.
SqlBaseListener.prototype.exitMultiStatement = function(ctx) {
};
// Enter a parse tree produced by SqlBaseParser#singleStatement.
SqlBaseListener.prototype.enterSingleStatement = function(ctx) {
};
// Exit a parse tree produced by SqlBaseParser#singleStatement.
const tokens = new antlr4.CommonTokenStream(lexer);
const parser = new ElectroGrammarParser(tokens);
// enable grammar ambiguity diagnostic output
// see Antlr book ch 9.2, page 156
// https://github.com/antlr/antlr4/issues/2206
parser.removeErrorListeners();
parser.addErrorListener(new antlr4.error.DiagnosticErrorListener());
parser._interp.PredictionMode =
antlr4.atn.PredictionMode.LL_EXACT_AMBIG_DETECTION;
parser.buildParseTrees = true;
const tree = parser[start_rule]();
const listener = new ElectroGrammarToObjectListener();
const walker = antlr4.tree.ParseTreeWalker.DEFAULT.walk(listener, tree);
return listener.obj;
}
return parse;
// Generated from ./lang/presto/SqlBase.g4 by ANTLR 4.7
// jshint ignore: start
var antlr4 = require('antlr4');
// This class defines a complete generic visitor for a parse tree produced by SqlBaseParser.
function SqlBaseVisitor() {
antlr4.tree.ParseTreeVisitor.call(this);
return this;
}
SqlBaseVisitor.prototype = Object.create(antlr4.tree.ParseTreeVisitor.prototype);
SqlBaseVisitor.prototype.constructor = SqlBaseVisitor;
// Visit a parse tree produced by SqlBaseParser#multiStatement.
SqlBaseVisitor.prototype.visitMultiStatement = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by SqlBaseParser#singleStatement.
SqlBaseVisitor.prototype.visitSingleStatement = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by SqlBaseParser#singleExpression.
SqlBaseVisitor.prototype.visitSingleExpression = function(ctx) {
function processStr(inputStr, config = {}, fileName = '') {
const chars = new antlr4.InputStream(inputStr)
const lexer = new SolidityLexer(chars)
const tokens = new antlr4.CommonTokenStream(lexer)
const parser = new SolidityParser(tokens)
parser.buildParseTrees = true
const tree = parser.sourceUnit()
const reporter = new Reporter(tokens, config)
const listener = new TreeListener(checkers(reporter, config, inputStr, fileName))
antlr4.tree.ParseTreeWalker.DEFAULT.walk(listener, tree)
return reporter
}
private parseStream (stream: any): void {
if (this.isComplete) {
throw new EvalError("The Observable has been completed.");
}
const lexer = new Lexer(stream);
const tokens = new antlr4.CommonTokenStream(lexer);
const parser = new Parser(tokens);
parser.buildParseTrees = true;
parser.removeErrorListeners();
parser.addErrorListener(this.errorListener);
const tree = parser.sourceUnit();
antlr4.tree.ParseTreeWalker.DEFAULT.walk(this.ruleListener, tree);
parser.removeErrorListeners();
if (this.fireComplete) {
this.complete();
}
}
}
export const parsePrestoSql = (input: string) => {
const parser = createParser(input);
const prestoListener = new PrestoListener();
parser.removeErrorListeners();
const tree = parser.multiStatement();
antlr4.tree.ParseTreeWalker.DEFAULT.walk(prestoListener, tree);
return prestoListener.parseResults();
};
Listener.prototype.buildAST = function(tree, ruleNames) {
ruleNames = ruleNames || null;
let s = antlr4.tree.Trees.getNodeText(tree, ruleNames);
s = antlr4.Utils.escapeWhitespace(s, false);
const c = tree.getChildCount();
if (c === 0) {
return s;
}
const res = {type: s, node: tree.constructor.name};
if (c > 0) {
s = this.buildAST(tree.getChild(0), ruleNames);
res.children = [...(res.children || []), s];
}
function parse(input) {
const chars = new antlr4.InputStream(input);
const lexer = new ElectroGrammarLexer(chars);
const tokens = new antlr4.CommonTokenStream(lexer);
const parser = new ElectroGrammarParser(tokens);
parser.buildParseTrees = true;
const tree = parser[start_rule]();
antlr4.tree.ParseTreeWalker.DEFAULT.walk(listener, tree);
return listener.obj;
}
return parse;
function walkIt(tree, walker) {
antlr4.tree.ParseTreeWalker.DEFAULT.walk(walker, tree);
}