This commit is contained in:
Olivier Gagnon
2021-05-07 21:24:16 -04:00
committed by hydroflame
parent 9a9d2e1f81
commit 6dde89f3c4
23 changed files with 76 additions and 262 deletions

View File

@@ -1,5 +1,7 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
import CodeMirror from "codemirror/lib/codemirror.js";
import { NetscriptFunctions } from "../NetscriptFunctions";
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
@@ -26,7 +28,7 @@ CodeMirror.defineMode("netscript", function(config, parserConfig) {
var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"), D = kw("keyword d");
var operator = kw("operator"), atom = {type: "atom", style: "atom"};
return {
const ret = {
"if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
"return": D, "break": D, "continue": D, "new": kw("new"), "delete": C, "void": C, "throw": C,
"debugger": kw("debugger"), "var": kw("var"), "const": kw("var"), "let": kw("var"),
@@ -40,234 +42,16 @@ CodeMirror.defineMode("netscript", function(config, parserConfig) {
// Netscript Basic Functions
"hack": atom,
"hackAnalyzeThreads": atom,
"hackAnalyzePercent": atom,
"hackChance": atom,
"sleep": atom,
"grow": atom,
"weaken": atom,
"growthAnalyze": atom,
"print": atom,
"tprint": atom,
"scan": atom,
"nuke": atom,
"brutessh": atom,
"ftpcrack": atom,
"clearLog": atom,
"disableLog": atom,
"enableLog": atom,
"isLogEnabled": atom,
"getScriptLogs": atom,
"tail": atom,
"relaysmtp": atom,
"httpworm": atom,
"sqlinject": atom,
"run": atom,
"exec": atom,
"spawn": atom,
"kill": atom,
"killall": atom,
"exit": atom,
"scp": atom,
"ls": atom,
"ps": atom,
"hasRootAccess": atom,
"getIp": atom,
"getHackingMultipliers": atom,
"getBitNodeMultipliers": atom,
"getStats": atom,
"isBusy": atom,
"getHacknetMultipliers": atom,
"getHostname": atom,
"getHackingLevel": atom,
"getServerMoneyAvailable": atom,
"getServerMaxMoney": atom,
"getServerGrowth": atom,
"getServerSecurityLevel": atom,
"getServerBaseSecurityLevel": atom,
"getServerMinSecurityLevel": atom,
"getServerRequiredHackingLevel": atom,
"getServerNumPortsRequired": atom,
"getServerRam": atom,
"serverExists": atom,
"fileExists": atom,
"isRunning": atom,
"deleteServer": atom,
"getPurchasedServers": atom,
"getPurchasedServerLimit": atom,
"getPurchasedServerMaxRam": atom,
"getPurchasedServerCost": atom,
"purchaseServer": atom,
"round": atom,
"write": atom,
"tryWrite": atom,
"read": atom,
"peek": atom,
"clear": atom,
"rm": atom,
"getPortHandle": atom,
"scriptRunning": atom,
"scriptKill": atom,
"getScriptName": atom,
"getScriptRam": atom,
"getHackTime": atom,
"getGrowTime": atom,
"getWeakenTime": atom,
"getScriptIncome": atom,
"getScriptExpGain": atom,
"getTimeSinceLastAug": atom,
"prompt": atom,
// Netscript Singularity Functions
"universityCourse": atom,
"getCharacterInformation": atom,
"gymWorkout": atom,
"travelToCity": atom,
"purchaseTor": atom,
"purchaseProgram": atom,
"upgradeHomeRam": atom,
"getUpgradeHomeRamCost": atom,
"workForCompany": atom,
"applyToCompany": atom,
"getCompanyRep": atom,
"getCompanyFavor": atom,
"stopAction": atom,
"getFactionFavor": atom,
"getFavorToDonate": atom,
"getFactionFavorGain": atom,
"getCompanyFavorGain": atom,
"checkFactionInvitations": atom,
"joinFaction": atom,
"workForFaction": atom,
"getFactionRep": atom,
"donateToFaction": atom,
"createProgram": atom,
"commitCrime": atom,
"getCrimeChance": atom,
"getOwnedAugmentations": atom,
"getOwnedSourceFiles": atom,
"getAugmentationsFromFaction": atom,
"getAugmentationPrereq": atom,
"getAugmentationCost": atom,
"purchaseAugmentation": atom,
"installAugmentations": atom,
// Netscript TIX API
"getStockPrice": atom,
"getStockAskPrice": atom,
"getStockBidPrice": atom,
"getStockPosition": atom,
"getStockSymbols": atom,
"getStockMaxShares": atom,
"getStockPurchaseCost": atom,
"getStockSaleGain": atom,
"buyStock": atom,
"sellStock": atom,
"shortStock": atom,
"sellShort": atom,
"placeOrder": atom,
"cancelOrder": atom,
"getOrders": atom,
"getStockVolatility": atom,
"getStockForecast": atom,
"purchase4SMarketData": atom,
"purchase4SMarketDataTixApi": atom,
// Netscript Hacknet Node API
"hacknet": atom,
"numNodes": atom,
"purchaseNode": atom,
"getPurchaseNodeCost": atom,
"getNodeStats": atom,
"upgradeLevel": atom,
"upgradeRam": atom,
"upgradeCore": atom,
"upgradeCache": atom,
"getLevelUpgradeCost": atom,
"getRamUpgradeCost": atom,
"getCoreUpgradeCost": atom,
"getCacheUpgradeCost": atom,
// Netscript Gang API
"gang": atom,
"getMemberNames": atom,
"getGangInformation": atom,
"getMemberInformation": atom,
"canRecruitMember": atom,
"recruitMember": atom,
"getTaskNames": atom,
"setMemberTask": atom,
"getEquipmentNames": atom,
"getEquipmentCost": atom,
"getEquipmentType": atom,
"purchaseEquipment": atom,
"ascendMember": atom,
"setTerritoryWarfare": atom,
"getChanceToWinClash": atom,
"getBonusTime": atom,
// Netscript Bladeburner API
"bladeburner": atom,
"getContractNames": atom,
"getOperationNames": atom,
"getBlackOpNames": atom,
"getGeneralActionNames": atom,
"getSkillNames": atom,
"startAction": atom,
"stopBladeburnerAction": atom,
"getCurrentAction": atom,
"getActionTime": atom,
"getActionEstimatedSuccessChance": atom,
"getActionCountRemaining": atom,
"getActionMaxLevel": atom,
"getActionCurrentLevel": atom,
"getActionAutolevel": atom,
"getActionRepGain": atom,
"setActionAutolevel": atom,
"setActionLevel": atom,
"getRank": atom,
"getBlackOpRank": atom,
"getSkillPoints": atom,
"getSkillLevel": atom,
"getSkillUpgradeCost": atom,
"upgradeSkill": atom,
"getTeamSize": atom,
"getCity": atom,
"setTeamSize": atom,
"getCityEstimatedPopulation": atom,
"getCityEstimatedCommunities": atom,
"getCityChaos": atom,
"switchCity": atom,
"getStamina": atom,
"joinBladeburnerFaction": atom,
// Repeat of above "getBonusTime": atom,
// Netscript Coding Contract API
"codingcontract": atom,
"attempt": atom,
"getContractType": atom,
"getData": atom,
"getDescription": atom,
"getNumTriesRemaining": atom,
// Sleeve API
"sleeve": atom,
"getNumSleeves": atom,
"setToShockRecovery": atom,
"setToSynchronize": atom,
"setToCommitCrime": atom,
"setToUniversityCourse": atom,
"travel": atom,
"setToCompanyWork": atom,
"setToFactionWork": atom,
"setToGymWorkout": atom,
"getSleeveStats": atom,
"getTask": atom,
"getInformation": atom,
"getSleeveAugmentations": atom,
"getSleevePurchasableAugs": atom,
"purchaseSleeveAug": atom,
};
function push(obj) {
for(const key of Object.keys(obj)) {
if(typeof obj[key] === 'function') ret[key] = atom;
if(typeof obj[key] === 'object') push(obj[key]);
}
}
push(NetscriptFunctions(null));
return ret;
}());
var isOperatorChar = /[+\-*&%=<>!?|~^@]/;