Esempio n. 1
0
        /// <summary>
        /// Parses a DOT representation from the provided stream. The parse tree is then notified via the provided listener.
        /// </summary>
        /// <param name="stream">The stream from which to parse</param>
        /// <param name="listener">The listener which is notified of the abstract syntax nodes</param>
        private static T Parse <T>(AntlrInputStream stream, IDOTVisitor <T> visitor)
        {
            var lexer       = new DOTLexer(stream);
            var tokenstream = new CommonTokenStream(lexer);
            var parser      = new DOTParser(tokenstream);

            var graph = parser.graph();

            return(visitor.Visit(graph));
        }
            public override TResult Accept <TResult>(IParseTreeVisitor <TResult> visitor)
            {
                IDOTVisitor <TResult> typedVisitor = visitor as IDOTVisitor <TResult>;

                if (typedVisitor != null)
                {
                    return(typedVisitor.VisitNode_id(this));
                }
                else
                {
                    return(visitor.VisitChildren(this));
                }
            }
Esempio n. 3
0
 /// <summary>
 /// Parses a DOT representation from the provided stream. The parse tree is then notified via the provided listener.
 /// </summary>
 /// <param name="reader">The stream reader from which to parse</param>
 /// <param name="listener">The listener which is notified of the abstract syntax nodes</param>
 public static T Parse <T>(TextReader reader, IDOTVisitor <T> visitor)
 {
     return(Parse(new AntlrInputStream(reader), visitor));
 }
Esempio n. 4
0
 /// <summary>
 /// Parses a DOT representation from the provided stream. The parse tree is then notified via the provided listener.
 /// </summary>
 /// <param name="stream">The stream from which to parse</param>
 /// <param name="listener">The listener which is notified of the abstract syntax nodes</param>
 public static T Parse <T>(Stream stream, IDOTVisitor <T> visitor)
 {
     return(Parse(new AntlrInputStream(stream), visitor));
 }