Esempio n. 1
0
        bool IsLet()
        {
            if (Type != TokenType.Name || Options.EcmaVersion < 6 || (string)Value != "let")
            {
                return(false);
            }
            var skip   = SkipWhiteSpace.Match(_input, _pos.Index);
            var next   = _pos.Index + skip.Groups[0].Length;
            var nextCh = _input[next];

            if (nextCh == 91 || nextCh == 123)
            {
                return(true);                               // '{' and '['
            }
            if (IsIdentifierStart(nextCh, true))
            {
                var pos = next + 1;
                while (IsIdentifierChar(_input.Get(pos), true))
                {
                    ++pos;
                }
                var ident = _input.Substring(next, pos - next);
                if (!KeywordRelationalOperator.IsMatch(ident))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 2
0
    bool IsLet()
    {
        if (Type != TokenType.Name || !"let".Equals(Value))
        {
            return(false);
        }
        var skip   = SkipWhiteSpace.Match(_input, _pos.Index);
        var next   = _pos.Index + skip.Groups[0].Length;
        var nextCh = _input[next];

        if (nextCh == CharCode.LeftSquareBracket || nextCh == CharCode.LeftCurlyBracket)
        {
            return(true);                                                                             // '{' and '['
        }
        if (IsIdentifierStart(nextCh, true))
        {
            var pos = next + 1;
            while (IsIdentifierChar(_input.Get(pos), true))
            {
                ++pos;
            }
            var ident = _input.Substring(next, pos - next);
            if (!KeywordRelationalOperator.IsMatch(ident))
            {
                return(true);
            }
        }

        return(false);
    }
Esempio n. 3
0
        // check 'async [no LineTerminator here] function'
        // - 'async /*foo*/ function' is OK.
        // - 'async /*\n*/ function' is invalid.
        bool IsAsyncFunction()
        {
            if (Type != TokenType.Name || Options.EcmaVersion < 8 || (string)Value != "async")
            {
                return(false);
            }

            var skip = SkipWhiteSpace.Match(_input, _pos.Index);
            var next = _pos.Index + skip.Groups[0].Length;

            return(!LineBreak.IsMatch(_input.Substring(_pos.Index, next - _pos.Index)) &&
                   _input.Length >= next + 8 && _input.AsSpan(next, 8).SequenceEqual("function") &&
                   (next + 8 == _input.Length || !IsIdentifierChar(_input.Get(next + 8))));
        }