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

本文介绍了笙默考试管理系统中基于Codemirror的代码编辑器,涉及词法分析、标识符处理、字符串和注释的token化,以及解析过程的细节。
摘要由CSDN通过智能技术生成

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

  

目录

一、 笙默考试管理系统-MyExamTest----codemirror

二、 笙默考试管理系统-MyExamTest----codemirror

三、 笙默考试管理系统-MyExamTest----codemirror

四、 笙默考试管理系统-MyExamTest----codemirror

五、 笙默考试管理系统-MyExamTest----codemirror

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

 

        }

        else if (ch == "#") {

            stream.skipToEnd();

            return ret("error", "error");

        }

        else if (isOperatorChar.test(ch)) {

            stream.eatWhile(isOperatorChar);

            return ret("operator", null, stream.current());

        }

        else {

            stream.eatWhile(/[\w\$_]/);

            var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];

            return (known && state.kwAllowed) ? ret(known.type, known.style, word) :

                ret("variable", "variable", word);

        }

    }

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

    function jsTokenString(quote) {

        return function(stream, state) {

            if (!nextUntilUnescaped(stream, quote))

                state.tokenize = jsTokenBase;

            return ret("string", "string");

        };

    }

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

    function jsTokenComment(stream, state) {

        var maybeEnd = false, ch;

        while (ch = stream.next()) {

            if (ch == "/" && maybeEnd) {

                state.tokenize = jsTokenBase;

                break;

            }

            maybeEnd = (ch == "*");

        }

        return ret("comment", "comment");

    }

    // Parser

    var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true};

    function JSLexical(indented, column, type, align, prev, info) {

        this.indented = indented;

        this.column = column;

        this.type = type;

        this.prev = prev;

        this.info = info;

        if (align != null) this.align = align;

    }

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

    function inScope(state, varname) {

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

            if (v.name == varname) return true;

    }

    function parseJS(state, style, type, content, stream) {

        var cc = state.cc;

        // Communicate our context to the combinators.

        // (Less wasteful than consing up a hundred closures on every call.)

        cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc;

        if (!state.lexical.hasOwnProperty("align"))

            state.lexical.align = true;

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

        while(true) {

            var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;

            if (combinator(type, content)) {

                while(cc.length && cc[cc.length - 1].lex)

                    cc.pop()();

                if (cx.marked) return cx.marked;

                if (type == "variable" && inScope(state, content)) return "variable-2";

                return style;

            }

        }

  • 15
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

N201871643

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值