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
12 ******************************************************************************/
13 #ifndef _langviz_Rule_HH
14 #define _langviz_Rule_HH
18 #include "../compiler2/string.hh"
25 class Rule : public Node {
33 virtual Rule* clone() const {return new Rule(*this);}
34 size_t get_nof_ss() {return rhs->get_nof_ss();}
35 Symbol* get_s_byIndex(size_t p_i) {return rhs->get_s_byIndex(p_i);}
36 void replace_aliases(Grammar *grammar);
40 * Ordered list of rules.
42 class Rules : public Node {
44 vector<Rule> rs; /**< rules */
46 Rules(const Rules& p);
50 virtual Rules* clone() const {return new Rules(*this);}
51 void add_r(Rule *p_r);
52 size_t get_nof_rs() const {return rs.size();}
53 const Rule* get_r_byIndex(size_t p_i) const {return rs[p_i];}
54 Rule*& get_r_byIndex(size_t p_i) {return rs[p_i];}
55 void steal_rules(Rules *p_other);
56 void replace_aliases(Grammar *grammar);
60 * Represents a grouping (rules of a single nonterminal symbol).
62 class Grouping : public Node {
67 Grouping(const Grouping& p);
69 Grouping(Symbol *p_lhs, Rules *p_rhss);
71 virtual Grouping* clone() const {return new Grouping(*this);}
72 const string& get_id() const {return lhs->get_id();}
73 void steal_rules(Grouping *p_other);
74 void replace_aliases(Grammar *grammar);
75 Symbol* get_lhs() {return lhs;}
76 size_t get_nof_rules() const {return rhss->get_nof_rs();}
77 Rule* get_rule_byIndex(size_t p_i) {return rhss->get_r_byIndex(p_i);}
80 #endif // _langviz_Rule_HH