1 using System;
2 using System.Collections;
3
4
5
6
7
8 namespace soulcm.scmpg
9 {
10 public class Domain
11 {
12 public const List<ParserFile*>& ParserFiles() const
13 {
14 return parserFiles;
15 }
16 public void Accept(Visitor& visitor)
17 {
18 visitor.Visit(*this);
19 }
20 public void AddParserFile(ParserFile* parserFile)
21 {
22 parserFiles.Add(parserFile);
23 }
24 public void AddParser(GrammarParser* parser)
25 {
26 Map<ustring, GrammarParser*>.ConstIterator it = parserMap.CFind(parser->Name());
27 if (it != parserMap.CEnd())
28 {
29 throw Exception("parser \'" + ToUtf8(parser->Name()) + "\' already exists");
30 }
31 parserMap[parser->Name()] = parser;
32 }
33 public GrammarParser* GetParser(const ustring& parserName) const
34 {
35 Map<ustring, GrammarParser*>.ConstIterator it = parserMap.CFind(parserName);
36 if (it != parserMap.CEnd())
37 {
38 return it->second;
39 }
40 else
41 {
42 throw Exception("parser \'" + ToUtf8(parserName) + "\' not found");
43 }
44 }
45 public nothrow void AddRule(RuleParser* rule)
46 {
47 int ruleId = cast<int>(rules.Count());
48 rule->SetId(ruleId);
49 rules.Add(rule);
50 }
51 public const List<RuleParser*>& Rules() const
52 {
53 return rules;
54 }
55 public nothrow const string& RuleFilePath() const
56 {
57 return ruleFilePath;
58 }
59 public nothrow void SetRuleFilePath(const string& ruleFilePath_)
60 {
61 ruleFilePath = ruleFilePath_;
62 }
63 private List<ParserFile*> parserFiles;
64 private Map<ustring, GrammarParser*> parserMap;
65 private List<RuleParser*> rules;
66 private string ruleFilePath;
67 }
68 }