Sync with 5.4.0
[deliverable/titan.core.git] / langviz / Iterator.cc
CommitLineData
970ed795 1///////////////////////////////////////////////////////////////////////////////
3abe9331 2// Copyright (c) 2000-2015 Ericsson Telecom AB
970ed795
EL
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 "Iterator.hh"
9#include "Grammar.hh"
10#include "Rule.hh"
11#include "Symbol.hh"
12
13// =================================
14// ===== Iterator
15// =================================
16
17void Iterator::visitGrammar(Grammar *p_grammar)
18{
19 grammar=p_grammar;
20 actionGrammar();
21 size_t n=grammar->get_nof_groupings();
22 for(size_t i=0; i<n; i++)
23 visitGrouping(grammar->get_grouping_byIndex(i));
24}
25
26void Iterator::visitGrouping(Grouping *p_grouping)
27{
28 grouping=p_grouping;
29 lhs=p_grouping->get_lhs();
30 actionGrouping();
31 size_t n=grouping->get_nof_rules();
32 for(size_t i=0; i<n; i++)
33 visitRule(grouping->get_rule_byIndex(i));
34}
35
36void Iterator::visitRule(Rule *p_rule)
37{
38 rule=p_rule;
39 actionRule();
40 size_t n=rule->get_nof_ss();
41 for(size_t i=0; i<n; i++)
42 visitSymbol(rule->get_s_byIndex(i));
43}
44
45void Iterator::visitSymbol(Symbol *p_symbol)
46{
47 symbol=p_symbol;
48 actionSymbol();
49}
50
51// =================================
52// ===== ItRefBuild
53// =================================
54
55void ItRefBuild::actionSymbol()
56{
57 if(symbol==lhs)
58 symbol->set_is_recursive();
59 else {
60 symbol->add_refd_by(lhs);
61 lhs->add_refs(symbol);
62 }
63}
This page took 0.028556 seconds and 5 git commands to generate.