Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(public connection: IConnection) {
this.connection = connection;
this.originalOpenDocuments = [];
this.gmlGrammar = grammar(fse.readFileSync(path.join(__dirname, path.normalize('../lib/gmlGrammar.ohm')), 'utf-8'));
this.__dirName = path.normalize(__dirname);
// Create our tools:
this.reference = new Reference(this);
this.fsManager = new FileSystem(this.gmlGrammar, this);
this.initialStartup = new InitialAndShutdown(this.reference, this.gmlGrammar, this);
//#region Language Services
this.gmlHoverProvider = new GMLHoverProvider(this.reference, this.fsManager);
this.gmlDefinitionProvider = new GMLDefinitionProvider(this.reference, this);
this.gmlSignatureProvider = new GMLSignatureProvider(this.reference, this.fsManager);
this.gmlCompletionProvider = new GMLCompletionProvider(this.reference, this.fsManager);
this.timer = new TimeUtil();
// Basic User Settings
this.userSettings = {
for (var i = 0; i < flatChildren.length; ++i) {
var child = flatChildren[i];
// Restore any discarded whitespace between this node and the previous one.
if (child.source.startIdx > prevEndIdx) {
code += node.source.sourceString.slice(prevEndIdx, child.source.startIdx);
}
code += child.toES5();
prevEndIdx = child.source.endIdx;
}
return code;
}
// Instantiate the ES5 grammar.
var contents = fs.readFileSync(path.join(__dirname, 'es5.ohm'));
var g = ohm.grammars(contents).ES5;
var semantics = g.createSemantics();
semantics.addOperation('toES5()', {
Program: function(_, sourceElements) {
// Top-level leading and trailing whitespace is not handled by nodeToES5(), so do it here.
var sourceString = this.source.sourceString;
return sourceString.slice(0, this.source.startIdx) +
nodeToES5(this, [sourceElements]) +
sourceString.slice(this.source.endIdx);
},
_nonterminal: function(children) {
return nodeToES5(this, children);
},
_terminal: function() {
return this.sourceString;
}
function makeGrammar(source, optNamespace) {
if (Array.isArray(source)) {
source = source.join('\n');
}
return ohm.grammar(source, optNamespace);
}
function makeGrammars(source, optNamespace) {
if (Array.isArray(source)) {
source = source.join('\n');
}
return ohm.grammars(source, optNamespace);
}
constructor() {
const grammarPath = path.join(
__dirname, '..', 'component', 'component.grammar.ohm');
this.grammar = ohm.grammar(readFileSync(grammarPath, 'utf-8'));
this.semantics = this.grammar.createSemantics();
}
= "(" Exp ")" -- paren
| "+" PriExp -- pos
| "-" PriExp -- neg
| cell
| number
cell (a cell)
= upper+ digit+
number (a number)
= digit* "." digit+ -- fract
| digit+ -- whole
}
`;
const formulaGrammar = ohm.grammar(GRAMMAR_SRC);
class UnOp {
constructor(child) {
this.child = child;
}
}
class BinOp {
constructor(left, right) {
this.left = left;
this.right = right;
}
}
class Plus extends BinOp {
eval(name, cells) {
constructor() {
const grammar_path = path.join(__dirname, "grammar.ohm");
this._grammar = ohm.grammar(fs.readFileSync(grammar_path, "utf-8"));
this._semantics = this._grammar.createSemantics()
.addOperation("tbonds", {
ClicheDecl: (cliche, name, uses, key1, para, key2) => {
this.cliche_map = this._get_cliche_map(name.sourceString, uses);
return _u
.chain(para.tbonds())
.flatten()
.reject(_u.isEmpty)
.value();
},
Paragraph_widget: decl => [],
Paragraph_data: decl => decl.tbonds(),
Paragraph_assignment: decl => [],
DataDecl: (data, name, key1, fields, key2, bond) => {
const subtype = name.sourceString;
const mapped_cliche = this.cliche_map["this"];
constructor() {
this.contents = fs.readFileSync(__dirname + "/src/moniel.ohm", "utf8")
this.grammar = ohm.grammar(this.contents)
this.semantics = this.grammar.createSemantics().addOperation("eval", this.evalOperation)
}