笙默考试管理系统-MyExamTest----codemirror(68)

笙默考试管理系统-MyExamTest----codemirror( 68

目录

[一、 笙默考试管理系统-MyExamTest----codemirror](#一、 笙默考试管理系统-MyExamTest----codemirror)

[三、 笙默考试管理系统-MyExamTest----codemirror](#三、 笙默考试管理系统-MyExamTest----codemirror)

[四、 笙默考试管理系统-MyExamTest----codemirror](#四、 笙默考试管理系统-MyExamTest----codemirror)

[五、 笙默考试管理系统-MyExamTest----codemirror](#五、 笙默考试管理系统-MyExamTest----codemirror)

  • 笙默考试管理系统-MyExamTest----codemirror

}

// Combinator utils

var cx = {state: null, column: null, marked: null, cc: null};

function pass() {

for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);

}

function cont() {

pass.apply(null, arguments);

return true;

}

function register(varname) {

var state = cx.state;

if (state.context) {

  • 笙默考试管理系统-MyExamTest----codemirror

cx.marked = "def";

for (var v = state.localVars; v; v = v.next)

if (v.name == varname) return;

state.localVars = {name: varname, next: state.localVars};

}

}

// Combinators

var defaultVars = {name: "this", next: {name: "arguments"}};

function pushcontext() {

if (!cx.state.context) cx.state.localVars = defaultVars;

cx.state.context = {prev: cx.state.context, vars: cx.state.localVars};

}

function popcontext() {

cx.state.localVars = cx.state.context.vars;

cx.state.context = cx.state.context.prev;

}

  • 笙默考试管理系统-MyExamTest----codemirror

function pushlex(type, info) {

var result = function() {

var state = cx.state;

state.lexical = new JSLexical(state.indented, cx.stream.column(), type, null, state.lexical, info)

};

result.lex = true;

return result;

}

function poplex() {

var state = cx.state;

if (state.lexical.prev) {

if (state.lexical.type == ")")

state.indented = state.lexical.indented;

state.lexical = state.lexical.prev;

}

}

  • 笙默考试管理系统-MyExamTest----codemirror

poplex.lex = true;

function expect(wanted) {

return function expecting(type) {

if (type == wanted) return cont();

else if (wanted == ";") return pass();

else return cont(arguments.callee);

};

}

function statement(type) {

if (type == "var") return cont(pushlex("vardef"), vardef1, expect(";"), poplex);

if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex);

if (type == "keyword b") return cont(pushlex("form"), statement, poplex);

if (type == "{") return cont(pushlex("}"), block, poplex);

if (type == ";") return cont();

if (type == "function") return cont(functiondef);

if (type == "for") return cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"),

poplex, statement, poplex);

if (type == "variable") return cont(pushlex("stat"), maybelabel);

  • 笙默考试管理系统-MyExamTest----codemirror

if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),

block, poplex, poplex);

if (type == "case") return cont(expression, expect(":"));

if (type == "default") return cont(expect(":"));

if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),

statement, poplex, popcontext);

return pass(pushlex("stat"), expression, expect(";"), poplex);

}

function expression(type) {

if (atomicTypes.hasOwnProperty(type)) return cont(maybeoperator);

if (type == "function") return cont(functiondef);

if (type == "keyword c") return cont(maybeexpression);

if (type == "(") return cont(pushlex(")"), expression, expect(")"), poplex, maybeoperator);

if (type == "operator") return cont(expression);

if (type == "[") return cont(pushlex("]"), commasep(expression, "]"), poplex, maybeoperator);

if (type == "{") return cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeoperator);

return cont();

}

function maybeexpression(type) {

if (type.match(/[;\}\)\],]/)) return pass();

return pass(expression);

}

function maybeoperator(type, value) {

if (type == "operator" && /\+\+|--/.test(value)) return cont(maybeoperator);

if (type == "operator") return cont(expression);

if (type == ";") return;

if (type == "(") return cont(pushlex(")"), commasep(expression, ")"), poplex, maybeoperator);

if (type == ".") return cont(property, maybeoperator);

if (type == "[") return cont(pushlex("]"), expression, expect("]"), poplex, maybeoperator);

}

function maybelabel(type) {

if (type == ":") return cont(poplex, statement);

return pass(maybeoperator, expect(";"), poplex);

}

function property(type) {

if (type == "variable") {cx.marked = "property"; return cont();}

}

function objprop(type) {

if (type == "variable") cx.marked = "property";

if (atomicTypes.hasOwnProperty(type)) return cont(expect(":"), expression);

}

function commasep(what, end) {

function proceed(type) {

if (type == ",") return cont(what, proceed);

if (type == end) return cont();

return cont(expect(end));

}

return function commaSeparated(type) {

if (type == end) return cont();

else return pass(what, proceed);

};

相关推荐
正小安1 小时前
如何在微信小程序中实现分包加载和预下载
前端·微信小程序·小程序
_.Switch3 小时前
Python Web 应用中的 API 网关集成与优化
开发语言·前端·后端·python·架构·log4j
一路向前的月光3 小时前
Vue2中的监听和计算属性的区别
前端·javascript·vue.js
长路 ㅤ   3 小时前
vite学习教程06、vite.config.js配置
前端·vite配置·端口设置·本地开发
长路 ㅤ   3 小时前
vue-live2d看板娘集成方案设计使用教程
前端·javascript·vue.js·live2d
Fan_web3 小时前
jQuery——事件委托
开发语言·前端·javascript·css·jquery
安冬的码畜日常3 小时前
【CSS in Depth 2 精译_044】第七章 响应式设计概述
前端·css·css3·html5·响应式设计·响应式
赛男丨木子丿小喵4 小时前
visual studio2022添加新项中没有html和css
css·html·visual studio
莹雨潇潇4 小时前
Docker 快速入门(Ubuntu版)
java·前端·docker·容器
Jiaberrr4 小时前
Element UI教程:如何将Radio单选框的圆框改为方框
前端·javascript·vue.js·ui·elementui