Commit | Line | Data |
---|---|---|
d44e3c4f | 1 | /****************************************************************************** |
2 | * Copyright (c) 2000-2016 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 | * Contributors: | |
9 | * Balasko, Jeno | |
10 | * Forstner, Matyas | |
11 | * | |
12 | ******************************************************************************/ | |
970ed795 EL |
13 | #include "Graph.hh" |
14 | #include "Symbol.hh" | |
15 | #include "Grammar.hh" | |
16 | #include "../common/memory.h" | |
17 | #include <stdio.h> | |
18 | ||
19 | void graph_use(Grammar* grammar) | |
20 | { | |
21 | expstring_t out=mcopystr("digraph G {\n"); | |
22 | size_t n=grammar->get_nof_symbols(); | |
23 | for(size_t i=0; i<n; i++) { | |
24 | Symbol *lhs=grammar->get_symbol_byIndex(i); | |
25 | const SymbolSet& ss=lhs->get_refs(); | |
26 | size_t n2=ss.get_nof_ss(); | |
27 | if(n2) { | |
28 | out=mputprintf(out, "%s -> { ", lhs->get_id_dot().c_str()); | |
29 | for(size_t i2=0; i2<n2; i2++) { | |
30 | Symbol *s=ss.get_s_byIndex(i2); | |
31 | if(!s->get_is_terminal()) | |
32 | out=mputprintf(out, "%s; ", s->get_id_dot().c_str()); | |
33 | } | |
34 | out=mputstr(out, "}\n"); | |
35 | } | |
36 | } | |
37 | out=mputstr(out, "}\n"); | |
38 | puts(out); | |
39 | Free(out); | |
40 | } | |
41 |