当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript reporters.parser_error函数代码示例

本文整理汇总了TypeScript中@core/util/reporters.parser_error函数的典型用法代码示例。如果您正苦于以下问题:TypeScript parser_error函数的具体用法?TypeScript parser_error怎么用?TypeScript parser_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了parser_error函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: _consume

export function _consume (tokens, str, index, length, out, isOptional){
		var index_ = index;
		var imax = tokens.length,
			i = 0, token, start;
		for(; i < imax; i++) {
			token = tokens[i];
			start = index;
			index = token.consume(str, index, length, out);
			if (index === start) {
				if (token.optional === true) {
					continue;
				}
				if (isOptional === true) {
					return index_;
				}
				// global require is also not optional: throw error
				var msg = 'Token of type `' + token.name + '`';
				if (token.token) {
					msg += ' Did you mean: `' + token.token + '`?';
				}
				parser_error(msg, str, index);
				return index_;
			}
		}
		return index;
	};
开发者ID:atmajs,项目名称:MaskJS,代码行数:26,代码来源:consume.ts

示例2: util_throw

export function util_throw(
    template: string,
    index: number,
    msg: string,
    token?,
    astNode?
) {
    return parser_error(
        msg + util_getNodeStack(astNode),
        template.toString(),
        index,
        token,
        'expr'
    );
}
开发者ID:atmajs,项目名称:MaskJS,代码行数:15,代码来源:util.ts

示例3: parser_parseLiteral

export function parser_parseLiteral (str, start, imax){
    var i = cursor_skipWhitespace(str, start, imax);

    var c = str.charCodeAt(i);
    if (c !== 34 && c !== 39) {
        // "'
        parser_error("A quote is expected", str, i);
        return null;
    }

    var isEscaped = false,
        isUnescapedBlock = false,
        _char = c === 39 ? "'" : '"';

    start = ++i;

    while ((i = str.indexOf(_char, i)) > -1) {
        if (str.charCodeAt(i - 1) !== 92 /*'\\'*/ ) {
            break;
        }
        isEscaped = true;
        i++;
    }

    if (i === -1) {
        parser_warn('Literal has no ending', str, start - 1);
        i = imax;
    }

    if (i === start) {
        var nextC = str.charCodeAt(i + 1);
        if (nextC === c) {
            isUnescapedBlock = true;
            start = i + 2;
            i = str.indexOf(_char + _char + _char, start);
            if (i === -1)
                i = imax;
        }
    }

    var token = str.substring(start, i);
    if (isEscaped === true) {
        token = token.replace(__rgxEscapedChar[_char], _char);
    }
    i += isUnescapedBlock ? 3 : 1;
    return [ token, i ];
};
开发者ID:atmajs,项目名称:MaskJS,代码行数:47,代码来源:literal.ts

示例4: function

 return function(str, i, imax, parent) {
     var start = str.indexOf('{', i) + 1,
         head = parseHead(
             //tagName, str.substring(i, start - 1)
             tagName,
             str,
             i,
             start
         );
     if (head == null) {
         parser_error('Method head syntax error', str, i);
     }
     var end = cursor_groupEnd(str, start, imax, 123, 125),
         body = str.substring(start, end),
         node =
             head == null
                 ? null
                 : new MethodNode(tagName, head, body, parent);
     return [node, end + 1, 0];
 };
开发者ID:atmajs,项目名称:MaskJS,代码行数:20,代码来源:parsers.ts

示例5: function

custom_Parsers['var'] = function(str, index, length, parent){
    var node = new VarNode('var', parent),
        start,
        c;

    var go_varName = 1,
        go_assign = 2,
        go_value = 3,
        go_next = 4,
        state = go_varName,
        token,
        key;
    while(true) {
        if (index < length && (c = str.charCodeAt(index)) < 33) {
            index++;
            continue;
        }

        if (state === go_varName) {
            start = index;
            index = cursor_refEnd(str, index, length);
            key = str.substring(start, index);
            state = go_assign;
            continue;
        }

        if (state === go_assign) {
            if (c !== 61 ) {
                // =
                parser_error(
                    'Assignment expected'
                    , str
                    , index
                    , c
                    , 'var'
                );
                return [node, index];
            }
            state = go_value;
            index++;
            continue;
        }
        if (state === go_value) {
            start = index;
            index++;
            switch(c){
                case 123:
                case 91:
                    // { [
                    index = cursor_groupEnd(str, index, length, c, c + 2);
                    break;
                case 39:
                case 34:
                    // ' "
                    index = cursor_quoteEnd(str, index, length, c === 39 ? "'" : '"')
                    break;
                default:
                    while (index < length) {
                        c = str.charCodeAt(index);
                        if (c === 91 || c === 40) {
                            // [ (
                            index = cursor_groupEnd(str, index + 1, length, c, c === 91 ? 93 : 41);
                            continue;
                        }
                        if (c === 44 || c === 59) {
                            //, ;
                            break;
                        }
                        index++;
                    }
                    index--;
                    break;
            }
            index++;
            node.attr[key] = str.substring(start, index);
            state = go_next;
            continue;
        }
        if (state === go_next) {
            if (c === 44) {
                // ,
                state = go_varName;
                index++;
                continue;
            }
            break;
        }
    }
    return [node, index, 0];
};
开发者ID:atmajs,项目名称:MaskJS,代码行数:90,代码来源:var.ts

示例6: parser_parse


//.........这里部分代码省略.........
                }
                index += isUnescapedBlock ? 3 : 1;
                continue;
        }
        if (state === go_tag) {
            last = state_tag;
            state = state_tag;
            if (c === 46 /* . */ || c === 35 /* # */) {
                tokenIndex = index;
                token = 'div';
                continue;
            }
            if (c === 91 /*[*/) {
                start = index + 1;
                index = cursor_groupEnd(template, start, length, c, 93 /* ] */);
                if (index === 0) {
                    parser_warn('Attribute not closed', template, start - 1);
                    index = length;
                    continue;
                }
                var expr = template.substring(start, index);
                var deco = new Dom.DecoratorNode(expr, current);
                deco.sourceIndex = start;
                current.appendChild(deco);

                index = cursor_skipWhitespace(template, index + 1, length);
                if (index !== length) {
                    c = template.charCodeAt(index);
                    if (c === 46 || c === 35 || c === 91 || (c >= 65 && c <= 122) || c === 36 || c === 95) {
                        // .#[A-z$_
                        last = state = go_tag;
                        continue;
                    }
                    parser_error('Unexpected char after decorator. Tag is expected', template, index, c, state);
                    break outer;
                }
            }
        }

        else if (state === state_attr) {
            if (c === 46) {
                // .
                index++;
                key = 'class';
                state = go_attrHeadVal;
            }
            else if (c === 35) {
                // #
                index++;
                key = 'id';
                state = go_attrHeadVal;
            }
            else if (c === 61) {
                // =;
                index++;
                state = go_attrVal;

                if (last === state_tag && key == null) {
                    parser_warn('Unexpected tag assignment', template, index, c, state);
                }
                continue;
            }
            else if (c === 40) {
                // (
                start = 1 + index;
                index = 1 + cursor_groupEnd(template, start, length, c, 41 /* ) */);
开发者ID:atmajs,项目名称:MaskJS,代码行数:67,代码来源:parser.ts


注:本文中的@core/util/reporters.parser_error函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。