public Context From(string source)
        {
            var stream = new ANTLRStringStream(source);
            var lexer = new MessageContractsLexer(stream);

            var tokens = new CommonTokenStream(lexer);

            var parser = new MessageContractsParser(tokens);

            var program = parser.GetProgram();

            var commonTree = (CommonTree) program.Tree;

            var node = commonTree as CommonErrorNode;

            if (node != null)
            {
                throw new InvalidOperationException(node.ToString());
            }

            var ctx = new Context();
            foreach (var child in commonTree.Children)
            {
                WalkDeclarations(child, ctx);
            }
            return ctx;
        }
예제 #2
0
        public Context From(string source)
        {
            var stream = new ANTLRStringStream(source);
            var lexer  = new MessageContractsLexer(stream);

            var tokens = new CommonTokenStream(lexer);

            var parser = new MessageContractsParser(tokens);

            var program = parser.GetProgram();

            var commonTree = (CommonTree)program.Tree;

            var node = commonTree as CommonErrorNode;

            if (node != null)
            {
                throw new InvalidOperationException(node.ToString());
            }


            var ctx = new Context();

            foreach (var child in commonTree.Children)
            {
                WalkDeclarations(child, ctx);
            }
            return(ctx);
        }