Bitstream Interpretation Library (BIL)  0.1
XDLParserImp.hpp
Go to the documentation of this file.
1 
6 #pragma once
7 #ifndef BIL_XDLPARSERIMP_HPP
8 #define BIL_XDLPARSERIMP_HPP
9 
10 #include <map>
11 #include <set>
12 #include <util/StreamTokenizer.hpp>
13 #include <xdl/model/Design.hpp>
14 #include <xdlrc/model/Device.hpp>
15 
16 
17 namespace bil { namespace xdlparser_detail {
18 
19  typedef std::map<std::string, size_t> nameIndexMap_t;
20  typedef std::map<PIP, size_t> pipIndexMap_t;
21  typedef std::set<std::string> nameSet_t;
22 
23  struct TileTypeEx {
26  };
27 
28 
34  class XDLParserImp {
35  public:
36 
37  XDLParserImp();
38  ~XDLParserImp();
39 
40  void parseHeader(StreamTokenizer& tokenizer, Design& design);
41  void parseBody(const Device& device);
42 
43  private:
44 
45  XDLParserImp(const XDLParserImp&);
46  XDLParserImp& operator=(const XDLParserImp&);
47 
48  void setupSyntax();
49  void fillDeviceLookups();
50  void clearAll();
51  void clearTemporaryData();
52 
53  void parseInstance();
54  void parseNet();
55  void parseQuotedString();
56 
57  void addInstance(const char* instanceName);
58  void addNet(const char* netName);
59 
60  size_t findTile(const char* tileName) const;
61  size_t findWire(const char* wireName, const nameIndexMap_t& wireMap) const;
62  size_t findPIP(const PIP& pip, const pipIndexMap_t& pipMap) const;
63  size_t findPrimitiveSite(const char* siteName, size_t tileIndex) const;
64  size_t findPrimitiveType(const char* typeName) const;
65  size_t findInstance(const char* instanceName) const;
66  size_t findPin(const char* pinName, size_t instanceIndex) const;
67 
68  bool m_headerParsed;
69  StreamTokenizer* m_tok;
70  char* m_quoteBuffer;
71  static const size_t QUOTE_BUFFER_SIZE = 0x1ffff;
72 
73  const Device* m_device;
74  const Tiles* m_tiles;
75 
76  Design* m_design;
77  Instances* m_instances;
78  Instance* m_instance;
79  Nets* m_nets;
80  Net* m_net;
81 
82  nameIndexMap_t m_tileMap;
83  std::vector<TileTypeEx> m_wirePIPMaps;
84  std::vector<nameIndexMap_t> m_pinMaps;
85  nameIndexMap_t m_primitiveTypesMap;
86  nameIndexMap_t m_instanceMap;
87  nameSet_t m_netSet;
88  };
89 
90 }}
91 
92 #endif