Commit | Line | Data |
---|---|---|
970ed795 EL |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Copyright (c) 2000-2014 Ericsson Telecom AB | |
3 | // All rights reserved. This program and the accompanying materials | |
4 | // are made available under the terms of the Eclipse Public License v1.0 | |
5 | // which accompanies this distribution, and is available at | |
6 | // http://www.eclipse.org/legal/epl-v10.html | |
7 | /////////////////////////////////////////////////////////////////////////////// | |
8 | #include "Graph.hh" | |
9 | #include "Symbol.hh" | |
10 | #include "Grammar.hh" | |
11 | #include "../common/memory.h" | |
12 | #include <stdio.h> | |
13 | ||
14 | void graph_use(Grammar* grammar) | |
15 | { | |
16 | expstring_t out=mcopystr("digraph G {\n"); | |
17 | size_t n=grammar->get_nof_symbols(); | |
18 | for(size_t i=0; i<n; i++) { | |
19 | Symbol *lhs=grammar->get_symbol_byIndex(i); | |
20 | const SymbolSet& ss=lhs->get_refs(); | |
21 | size_t n2=ss.get_nof_ss(); | |
22 | if(n2) { | |
23 | out=mputprintf(out, "%s -> { ", lhs->get_id_dot().c_str()); | |
24 | for(size_t i2=0; i2<n2; i2++) { | |
25 | Symbol *s=ss.get_s_byIndex(i2); | |
26 | if(!s->get_is_terminal()) | |
27 | out=mputprintf(out, "%s; ", s->get_id_dot().c_str()); | |
28 | } | |
29 | out=mputstr(out, "}\n"); | |
30 | } | |
31 | } | |
32 | out=mputstr(out, "}\n"); | |
33 | puts(out); | |
34 | Free(out); | |
35 | } | |
36 |