笙默考试管理系统-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);

};

相关推荐
文心快码BaiduComate12 小时前
我用文心快码Spec 模式搓了个“pre作弊器”,妈妈再也不用担心我开会忘词了(附源码)
前端·后端·程序员
JH灰色12 小时前
【大模型】-LangChain--stream流式同步异步
服务器·前端·langchain
lxh011312 小时前
二叉树中的最大路径和
前端·算法·js
CC码码13 小时前
前端字符串排序搜索可以更加细化了
前端·javascript·面试
喵爱吃鱼13 小时前
kuma-ui中Flex vs FlexMin的关键区别
前端
codingMan13 小时前
[Android Compose] 拒绝闪烁!打造丝滑的聊天页面列表(仿微信效果)
前端
你别追我跑不动13 小时前
基于代码扫描的 Icon 优化实践
前端·性能优化
磊磊磊磊磊13 小时前
用AI做了个排版工具,分享一下如何高效省钱地用AI!
前端·后端·react.js
喵爱吃鱼13 小时前
flex 0 flex 1 flex none flex auto 应该在什么场景下使用
前端
雾散声声慢13 小时前
解决 iOS 上 Swiper 滑动图片闪烁问题:原因分析与最有效的修复方式
前端·css·ios