Merge pull request #75 from balaskoa/master
[deliverable/titan.core.git] / langviz / Iterator.cc
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 ******************************************************************************/
13 #include "Iterator.hh"
14 #include "Grammar.hh"
15 #include "Rule.hh"
16 #include "Symbol.hh"
17
18 // =================================
19 // ===== Iterator
20 // =================================
21
22 void Iterator::visitGrammar(Grammar *p_grammar)
23 {
24 grammar=p_grammar;
25 actionGrammar();
26 size_t n=grammar->get_nof_groupings();
27 for(size_t i=0; i<n; i++)
28 visitGrouping(grammar->get_grouping_byIndex(i));
29 }
30
31 void Iterator::visitGrouping(Grouping *p_grouping)
32 {
33 grouping=p_grouping;
34 lhs=p_grouping->get_lhs();
35 actionGrouping();
36 size_t n=grouping->get_nof_rules();
37 for(size_t i=0; i<n; i++)
38 visitRule(grouping->get_rule_byIndex(i));
39 }
40
41 void Iterator::visitRule(Rule *p_rule)
42 {
43 rule=p_rule;
44 actionRule();
45 size_t n=rule->get_nof_ss();
46 for(size_t i=0; i<n; i++)
47 visitSymbol(rule->get_s_byIndex(i));
48 }
49
50 void Iterator::visitSymbol(Symbol *p_symbol)
51 {
52 symbol=p_symbol;
53 actionSymbol();
54 }
55
56 // =================================
57 // ===== ItRefBuild
58 // =================================
59
60 void ItRefBuild::actionSymbol()
61 {
62 if(symbol==lhs)
63 symbol->set_is_recursive();
64 else {
65 symbol->add_refd_by(lhs);
66 lhs->add_refs(symbol);
67 }
68 }
This page took 0.031511 seconds and 5 git commands to generate.