Ejemplo n.º 1
0
        static void Try(string input)
        {
            var str             = new AntlrInputStream(input);
            var lexer           = new DartLexer(str);
            var tokens          = new CommonTokenStream(lexer);
            var parser          = new DartParser(tokens);
            var listener_lexer  = new ErrorListener <int>();
            var listener_parser = new ErrorListener <IToken>();

            lexer.AddErrorListener(listener_lexer);
            parser.AddErrorListener(listener_parser);
            var tree = parser.libraryDefinition();

            if (display_tokens)
            {
                foreach (var t in tokens.GetTokens())
                {
                    System.Console.WriteLine(t.ToString());
                }
            }
            if (display_tree)
            {
                System.Console.WriteLine(TreeOutput.OutputTree(tree, lexer, tokens).ToString());
            }
            if (listener_lexer.had_error || listener_parser.had_error)
            {
                System.Console.WriteLine("error in parse.");
                throw new Exception();
            }
            else
            {
                System.Console.WriteLine("parse completed.");
            }
        }
Ejemplo n.º 2
0
        public IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
        {
            var calassificationSpans = new List<ClassificationSpan>();

            var lexer = new DartLexer(new ANTLRStringStream(_buffer.CurrentSnapshot.GetText(span)));
            for (var token = lexer.NextToken(); token.Type != DartLexer.EOF; token = lexer.NextToken())
            {
                IClassificationType classificationType;
                if (_registry.TryGetGetClassificationType(token.Type, out classificationType))
                {
                    ClassificationSpan classificationSpan;
                    if (TryCreateClassificationSpan(span, token, classificationType, out classificationSpan))
                    {
                        calassificationSpans.Add(classificationSpan);
                    }
                }
            }

            return calassificationSpans;
        }
Ejemplo n.º 3
0
        public IList <ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
        {
            var calassificationSpans = new List <ClassificationSpan>();

            var lexer = new DartLexer(new ANTLRStringStream(_buffer.CurrentSnapshot.GetText(span)));

            for (var token = lexer.NextToken(); token.Type != DartLexer.EOF; token = lexer.NextToken())
            {
                IClassificationType classificationType;
                if (_registry.TryGetGetClassificationType(token.Type, out classificationType))
                {
                    ClassificationSpan classificationSpan;
                    if (TryCreateClassificationSpan(span, token, classificationType, out classificationSpan))
                    {
                        calassificationSpans.Add(classificationSpan);
                    }
                }
            }

            return(calassificationSpans);
        }