Пример #1
0
        protected void GetErrorLaconicTags(
            ref List <ITagSpan <IErrorTag> > tags,
            string src,
            int startPosition = 0)
        {
            var ml  = new MessageList();
            var lxr = new LaconfigLexer(new StringSource(src), ml);
            var cfg = new LaconicConfiguration();
            var ctx = new LaconfigData(cfg);
            var p   = new LaconfigParser(ctx, lxr, ml);

            p.Parse();
            TaskManager.Refresh(m_DocName);
            foreach (var message in ml)
            {
                TaskManager.AddError(message, m_DocName);


                var start = message.Token == null ?
                            message.Position.CharNumber :
                            message.Token.StartPosition.CharNumber > 4 ?
                            message.Token.StartPosition.CharNumber - 5 :
                            0;

                var length = message.Token == null ?
                             src.Length - 1 - start :
                             src.Length - start > 10 ?
                             10 :
                             src.Length - start;

                tags.Add(CreateTagSpan(start, length));
            }
        }
Пример #2
0
        private void read(ISourceText source)
        {
            var context = new LaconfigData(this);

            var lexer  = new LaconfigLexer(source, throwErrors: true);
            var parser = new LaconfigParser(context, lexer, throwErrors: true);

            parser.Parse();
        }
Пример #3
0
            private void read(ISourceText source)
            {
              var context = new LaconfigData(this);

              var lexer = new LaconfigLexer(source, throwErrors: true);
              var parser = new LaconfigParser(context, lexer, throwErrors: true);

              parser.Parse();
            }
Пример #4
0
        protected void GetLaconicTags(
            ref List <ITagSpan <IClassificationTag> > classifierTags,
            string src,
            int startPosition = 0)
        {
            var ml  = new MessageList();
            var lxr = new LaconfigLexer(new StringSource(src), ml);
            var cfg = new LaconicConfiguration();
            var ctx = new LaconfigData(cfg);
            var p   = new LaconfigParser(ctx, lxr, ml);

            p.Parse();
            for (var i = 0; i < lxr.Tokens.Count; i++)
            {
                NfxTokenTypes?curType = null;
                var           token   = lxr.Tokens[i];
                if (token.IsComment)
                {
                    curType = NfxTokenTypes.Comment;
                }
                else if (token.IsIdentifier)
                {
                    curType = NfxTokenTypes.KeyWord;
                }
                else if (token.IsSymbol || token.IsOperator)
                {
                    curType = NfxTokenTypes.Brace;
                }
                else if (token.IsLiteral)
                {
                    curType = NfxTokenTypes.Literal;
                }

                if (!curType.HasValue ||
                    (curType != NfxTokenTypes.Comment && curType != NfxTokenTypes.Literal))
                {
                    if (Configurator.GetGroupKeywords(NfxTokenTypes.Group1.ToString()).Contains(token.Text))
                    {
                        curType = NfxTokenTypes.Group1;
                    }

                    if (Configurator.GetGroupKeywords(NfxTokenTypes.Group2.ToString()).Contains(token.Text))
                    {
                        curType = NfxTokenTypes.Group2;
                    }

                    if (Configurator.GetGroupKeywords(NfxTokenTypes.Group3.ToString()).Contains(token.Text))
                    {
                        curType = NfxTokenTypes.Group3;
                    }

                    if (Configurator.GetGroupKeywords(NfxTokenTypes.Group4.ToString()).Contains(token.Text))
                    {
                        curType = NfxTokenTypes.Group4;
                    }

                    if (Configurator.GetGroupKeywords(NfxTokenTypes.Group5.ToString()).Contains(token.Text))
                    {
                        curType = NfxTokenTypes.Group5;
                    }

                    if (Configurator.GetGroupKeywords(NfxTokenTypes.Group6.ToString()).Contains(token.Text))
                    {
                        curType = NfxTokenTypes.Group6;
                    }

                    if (Configurator.GetGroupKeywords(NfxTokenTypes.Group7.ToString()).Contains(token.Text))
                    {
                        curType = NfxTokenTypes.Group7;
                    }
                }

                if (curType.HasValue)
                {
                    classifierTags.Add(CreateTagSpan(startPosition + token.StartPosition.CharNumber - 1, token.EndPosition.CharNumber - token.StartPosition.CharNumber + 1, curType.Value));
                }
            }
        }