idl-parser 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. idl_parser-0.1.0/.github/workflows/release.yml +84 -0
  2. idl_parser-0.1.0/.github/workflows/test.yml +35 -0
  3. idl_parser-0.1.0/.gitignore +5 -0
  4. idl_parser-0.1.0/PKG-INFO +110 -0
  5. idl_parser-0.1.0/README.md +76 -0
  6. idl_parser-0.1.0/README.rst +90 -0
  7. idl_parser-0.1.0/example.py +93 -0
  8. idl_parser-0.1.0/idl_parser/__init__.py +7 -0
  9. idl_parser-0.1.0/idl_parser/const.py +50 -0
  10. idl_parser-0.1.0/idl_parser/enum.py +114 -0
  11. idl_parser-0.1.0/idl_parser/exception.py +37 -0
  12. idl_parser-0.1.0/idl_parser/interface.py +226 -0
  13. idl_parser-0.1.0/idl_parser/module.py +314 -0
  14. idl_parser-0.1.0/idl_parser/node.py +123 -0
  15. idl_parser-0.1.0/idl_parser/parser.py +356 -0
  16. idl_parser-0.1.0/idl_parser/struct.py +155 -0
  17. idl_parser-0.1.0/idl_parser/token_buffer.py +25 -0
  18. idl_parser-0.1.0/idl_parser/type.py +283 -0
  19. idl_parser-0.1.0/idl_parser/typedef.py +84 -0
  20. idl_parser-0.1.0/idl_parser/union.py +188 -0
  21. idl_parser-0.1.0/idl_parser.egg-info/PKG-INFO +110 -0
  22. idl_parser-0.1.0/idl_parser.egg-info/SOURCES.txt +41 -0
  23. idl_parser-0.1.0/idl_parser.egg-info/dependency_links.txt +1 -0
  24. idl_parser-0.1.0/idl_parser.egg-info/scm_file_list.json +39 -0
  25. idl_parser-0.1.0/idl_parser.egg-info/scm_version.json +8 -0
  26. idl_parser-0.1.0/idl_parser.egg-info/top_level.txt +1 -0
  27. idl_parser-0.1.0/idls/basic_module_test.idl +103 -0
  28. idl_parser-0.1.0/idls/circular/circular_a.idl +7 -0
  29. idl_parser-0.1.0/idls/circular/circular_b.idl +7 -0
  30. idl_parser-0.1.0/idls/circular/diamond.idl +8 -0
  31. idl_parser-0.1.0/idls/generalization.idl +18 -0
  32. idl_parser-0.1.0/idls/included_idl.idl +8 -0
  33. idl_parser-0.1.0/idls/including_idl.idl +9 -0
  34. idl_parser-0.1.0/idls/invalid_idl.idl +12 -0
  35. idl_parser-0.1.0/idls/multi_module_test.idl +47 -0
  36. idl_parser-0.1.0/pyproject.toml +36 -0
  37. idl_parser-0.1.0/setup.cfg +4 -0
  38. idl_parser-0.1.0/tests/__init__.py +1 -0
  39. idl_parser-0.1.0/tests/generalization_test.py +37 -0
  40. idl_parser-0.1.0/tests/include_test.py +37 -0
  41. idl_parser-0.1.0/tests/invalid_idl_test.py +33 -0
  42. idl_parser-0.1.0/tests/module_test.py +299 -0
  43. idl_parser-0.1.0/tests/multimodule_test.py +82 -0
@@ -0,0 +1,84 @@
1
+ name: Release
2
+
3
+ # - pull_request : build only (checks that the package builds)
4
+ # - push to main : build and publish a .devN version to TestPyPI
5
+ # - push tag v* : build and publish the tagged version to PyPI
6
+ on:
7
+ push:
8
+ branches: [main]
9
+ tags: ["v*"]
10
+ pull_request:
11
+ workflow_dispatch:
12
+
13
+ permissions:
14
+ contents: read
15
+
16
+ jobs:
17
+ test:
18
+ uses: ./.github/workflows/test.yml
19
+
20
+ build:
21
+ name: Build distributions
22
+ needs: test
23
+ runs-on: ubuntu-latest
24
+ steps:
25
+ - uses: actions/checkout@v5
26
+ with:
27
+ fetch-depth: 0 # setuptools-scm needs tags and history
28
+ persist-credentials: false
29
+
30
+ - uses: actions/setup-python@v6
31
+ with:
32
+ python-version: "3.x"
33
+
34
+ - name: Build sdist and wheel
35
+ run: |
36
+ python -m pip install --upgrade build twine
37
+ python -m build
38
+ python -m twine check --strict dist/*
39
+ ls -l dist
40
+
41
+ - uses: actions/upload-artifact@v7
42
+ with:
43
+ name: dist
44
+ path: dist/
45
+ if-no-files-found: error
46
+
47
+ publish-testpypi:
48
+ name: Publish to TestPyPI
49
+ if: github.event_name == 'push' && github.ref == 'refs/heads/main'
50
+ needs: build
51
+ runs-on: ubuntu-latest
52
+ environment:
53
+ name: testpypi
54
+ url: https://test.pypi.org/p/idl_parser
55
+ permissions:
56
+ id-token: write # Trusted Publishing
57
+ steps:
58
+ - uses: actions/download-artifact@v8
59
+ with:
60
+ name: dist
61
+ path: dist/
62
+
63
+ - uses: pypa/gh-action-pypi-publish@release/v1
64
+ with:
65
+ repository-url: https://test.pypi.org/legacy/
66
+ skip-existing: true
67
+
68
+ publish-pypi:
69
+ name: Publish to PyPI
70
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
71
+ needs: build
72
+ runs-on: ubuntu-latest
73
+ environment:
74
+ name: pypi
75
+ url: https://pypi.org/p/idl_parser
76
+ permissions:
77
+ id-token: write # Trusted Publishing
78
+ steps:
79
+ - uses: actions/download-artifact@v8
80
+ with:
81
+ name: dist
82
+ path: dist/
83
+
84
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,35 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ workflow_dispatch:
8
+ workflow_call: # reused by release.yml before building
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ concurrency:
14
+ group: ${{ github.workflow }}-${{ github.ref }}
15
+ cancel-in-progress: true
16
+
17
+ jobs:
18
+ test:
19
+ name: Python ${{ matrix.python-version }}
20
+ runs-on: ubuntu-latest
21
+ strategy:
22
+ fail-fast: false
23
+ matrix:
24
+ python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
25
+
26
+ steps:
27
+ - uses: actions/checkout@v5
28
+
29
+ - uses: actions/setup-python@v6
30
+ with:
31
+ python-version: ${{ matrix.python-version }}
32
+
33
+ # Tests open IDL files by relative path (idls/...), so run from the repository root.
34
+ - name: Run tests
35
+ run: python -m unittest discover --start-directory tests --pattern '*_test.py' --top-level-directory . --verbose
@@ -0,0 +1,5 @@
1
+ *.pyc
2
+ *~
3
+ *.egg-info
4
+ build/*
5
+ dist/*
@@ -0,0 +1,110 @@
1
+ Metadata-Version: 2.4
2
+ Name: idl_parser
3
+ Version: 0.1.0
4
+ Summary: Very simple OMG IDL (Interface Definition Language) parser. This parses IDL files and outputs intermediate class objects.
5
+ Author-email: ysuga <ysuga@ysuga.net>
6
+ Project-URL: Homepage, http://www.sugarsweetrobotics.com/
7
+ Project-URL: Source, https://github.com/sugarsweetrobotics/idl_parser
8
+ Project-URL: Issues, https://github.com/sugarsweetrobotics/idl_parser/issues
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
13
+ Classifier: Natural Language :: English
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Topic :: Scientific/Engineering
18
+ Requires-Python: >=3.9
19
+ Description-Content-Type: text/x-rst
20
+
21
+ idl_parser
22
+ ============
23
+
24
+ |Test Status|
25
+
26
+ Description
27
+ -----------
28
+
29
+ OMG IDL file parser. This library just parse IDL files, and output intermidiate type objects.
30
+
31
+ Example
32
+ -----------
33
+
34
+ .. code:: python
35
+
36
+ """
37
+ example for idl_parser package
38
+ """
39
+
40
+ from idl_parser import parser
41
+ parser_ = parser.IDLParser()
42
+ idl_str = """
43
+ module my_module {
44
+ struct Time {
45
+ long sec;
46
+ long usec;
47
+ };
48
+
49
+ typedef sequence<double> DoubleSeq;
50
+
51
+ struct TimedDoubleSeq {
52
+ Time tm;
53
+ DoubleSeq data;
54
+ };
55
+
56
+ enum RETURN_VALUE {
57
+ RETURN_OK,
58
+ RETURN_FAILED,
59
+ };
60
+
61
+ interface DataGetter {
62
+ RETURN_VALUE getData(out TimedDoubleSeq data);
63
+ };
64
+
65
+ };
66
+ """
67
+
68
+ global_module = parser_.load(idl_str)
69
+ my_module = global_module.module_by_name('my_module')
70
+ dataGetter = my_module.interface_by_name('DataGetter')
71
+ print 'DataGetter interface'
72
+ for m in dataGetter.methods:
73
+ print '- method:'
74
+ print ' name:', m.name
75
+ print ' returns:', m.returns.name
76
+ print ' arguments:'
77
+ for a in m.arguments:
78
+ print ' name:', a.name
79
+ print ' type:', a.type
80
+ print ' direction:', a.direction
81
+
82
+ doubleSeq = my_module.typedef_by_name('DoubleSeq')
83
+ print 'typedef %s %s' % (doubleSeq.type.name, doubleSeq.name)
84
+
85
+ timedDoubleSeq = my_module.struct_by_name('TimedDoubleSeq')
86
+ print 'TimedDoubleSeq'
87
+ for m in timedDoubleSeq.members:
88
+ print '- member:'
89
+ print ' name:', m.name
90
+ print ' type:', m.type.name
91
+
92
+ How to install
93
+ ---------------
94
+
95
+ sudo pip install idl_parser
96
+
97
+
98
+ Copyright
99
+ ------------
100
+
101
+ - author: Yuki Suga
102
+
103
+ - copyright: Yuki Suga
104
+
105
+ - contact: please open an issue on `GitHub Issues <https://github.com/sugarsweetrobotics/idl_parser/issues>`_
106
+
107
+ - license: GPLv3
108
+
109
+ .. |Test Status| image:: https://github.com/sugarsweetrobotics/idl_parser/actions/workflows/test.yml/badge.svg?branch=main
110
+ :target: https://github.com/sugarsweetrobotics/idl_parser/actions/workflows/test.yml
@@ -0,0 +1,76 @@
1
+ # idl_parser
2
+
3
+ [![Test](https://github.com/sugarsweetrobotics/idl_parser/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/sugarsweetrobotics/idl_parser/actions/workflows/test.yml)
4
+
5
+
6
+ ## Description
7
+
8
+ OMG IDL file parser. This library just parse IDL files, and output intermidiate type objects.
9
+
10
+ ## Example
11
+ ```
12
+ """
13
+
14
+ """
15
+
16
+ from idl_parser import parser
17
+ parser_ = parser.IDLParser()
18
+ idl_str = """
19
+ module my_module {
20
+ struct Time {
21
+ long sec;
22
+ long usec;
23
+ };
24
+
25
+ typedef sequence<double> DoubleSeq;
26
+
27
+ struct TimedDoubleSeq {
28
+ Time tm;
29
+ DoubleSeq data;
30
+ };
31
+
32
+ enum RETURN_VALUE {
33
+ RETURN_OK,
34
+ RETURN_FAILED,
35
+ };
36
+
37
+ interface DataGetter {
38
+ RETURN_VALUE getData(out TimedDoubleSeq data);
39
+ };
40
+
41
+ };
42
+ """
43
+
44
+ global_module = parser_.load(idl_str)
45
+ my_module = global_module.module_by_name('my_module')
46
+ dataGetter = my_module.interface_by_name('DataGetter')
47
+ print 'DataGetter interface'
48
+ for m in dataGetter.methods:
49
+ print '- method:'
50
+ print ' name:', m.name
51
+ print ' returns:', m.returns.name
52
+ print ' arguments:'
53
+ for a in m.arguments:
54
+ print ' name:', a.name
55
+ print ' type:', a.type
56
+ print ' direction:', a.direction
57
+
58
+ doubleSeq = my_module.typedef_by_name('DoubleSeq')
59
+ print 'typedef %s %s' % (doubleSeq.type.name, doubleSeq.name)
60
+
61
+ timedDoubleSeq = my_module.struct_by_name('TimedDoubleSeq')
62
+ print 'TimedDoubleSeq'
63
+ for m in timedDoubleSeq.members:
64
+ print '- member:'
65
+ print ' name:', m.name
66
+ print ' type:', m.type.name
67
+ ```
68
+ ## How to install
69
+ sudo pip install idl_parser
70
+
71
+ ## Copyright
72
+ * author: Yuki Suga
73
+ * copyright: Yuki Suga
74
+ * contact: please open an issue on [GitHub Issues](https://github.com/sugarsweetrobotics/idl_parser/issues)
75
+ * license: GPLv3
76
+
@@ -0,0 +1,90 @@
1
+ idl_parser
2
+ ============
3
+
4
+ |Test Status|
5
+
6
+ Description
7
+ -----------
8
+
9
+ OMG IDL file parser. This library just parse IDL files, and output intermidiate type objects.
10
+
11
+ Example
12
+ -----------
13
+
14
+ .. code:: python
15
+
16
+ """
17
+ example for idl_parser package
18
+ """
19
+
20
+ from idl_parser import parser
21
+ parser_ = parser.IDLParser()
22
+ idl_str = """
23
+ module my_module {
24
+ struct Time {
25
+ long sec;
26
+ long usec;
27
+ };
28
+
29
+ typedef sequence<double> DoubleSeq;
30
+
31
+ struct TimedDoubleSeq {
32
+ Time tm;
33
+ DoubleSeq data;
34
+ };
35
+
36
+ enum RETURN_VALUE {
37
+ RETURN_OK,
38
+ RETURN_FAILED,
39
+ };
40
+
41
+ interface DataGetter {
42
+ RETURN_VALUE getData(out TimedDoubleSeq data);
43
+ };
44
+
45
+ };
46
+ """
47
+
48
+ global_module = parser_.load(idl_str)
49
+ my_module = global_module.module_by_name('my_module')
50
+ dataGetter = my_module.interface_by_name('DataGetter')
51
+ print 'DataGetter interface'
52
+ for m in dataGetter.methods:
53
+ print '- method:'
54
+ print ' name:', m.name
55
+ print ' returns:', m.returns.name
56
+ print ' arguments:'
57
+ for a in m.arguments:
58
+ print ' name:', a.name
59
+ print ' type:', a.type
60
+ print ' direction:', a.direction
61
+
62
+ doubleSeq = my_module.typedef_by_name('DoubleSeq')
63
+ print 'typedef %s %s' % (doubleSeq.type.name, doubleSeq.name)
64
+
65
+ timedDoubleSeq = my_module.struct_by_name('TimedDoubleSeq')
66
+ print 'TimedDoubleSeq'
67
+ for m in timedDoubleSeq.members:
68
+ print '- member:'
69
+ print ' name:', m.name
70
+ print ' type:', m.type.name
71
+
72
+ How to install
73
+ ---------------
74
+
75
+ sudo pip install idl_parser
76
+
77
+
78
+ Copyright
79
+ ------------
80
+
81
+ - author: Yuki Suga
82
+
83
+ - copyright: Yuki Suga
84
+
85
+ - contact: please open an issue on `GitHub Issues <https://github.com/sugarsweetrobotics/idl_parser/issues>`_
86
+
87
+ - license: GPLv3
88
+
89
+ .. |Test Status| image:: https://github.com/sugarsweetrobotics/idl_parser/actions/workflows/test.yml/badge.svg?branch=main
90
+ :target: https://github.com/sugarsweetrobotics/idl_parser/actions/workflows/test.yml
@@ -0,0 +1,93 @@
1
+ """
2
+
3
+ """
4
+
5
+ def test():
6
+ from idl_parser import parser
7
+ _parser = parser.IDLParser()
8
+ idl_str = '''
9
+ module my_module {
10
+ struct Time {
11
+ long sec;
12
+ long usec;
13
+ };
14
+
15
+ enum UNION_DESCRIMINATOR_KIND
16
+ {
17
+ DESCRIMINATOR_UNKNOWN,
18
+ DESCRIMINATOR_ULONGLONG,
19
+ DESCRIMINATOR_LONGLONG,
20
+ DESCRIMINATOR_DOUBLE,
21
+ DESCRIMINATOR_STRING,
22
+ DESCRIMINATOR_KIND_COUNT
23
+ };
24
+
25
+ union UnionType switch( UNION_DESCRIMINATOR_KIND )
26
+ {
27
+ case DESCRIMINATOR_UNKNOWN:
28
+ case DESCRIMINATOR_KIND_COUNT:
29
+ case DESCRIMINATOR_ULONGLONG:
30
+ unsigned long long ull_value;
31
+ case DESCRIMINATOR_LONGLONG:
32
+ long long ll_value;
33
+ case DESCRIMINATOR_DOUBLE:
34
+ double d_value;
35
+ case DESCRIMINATOR_STRING:
36
+ sequence<char> str_value;
37
+ };
38
+
39
+ typedef sequence<double> DoubleSeq;
40
+
41
+ struct TimedDoubleSeq {
42
+ Time tm;
43
+ DoubleSeq data;
44
+ };
45
+
46
+ enum RETURN_VALUE {
47
+ RETURN_OK,
48
+ RETURN_FAILED,
49
+ };
50
+
51
+ interface DataGetter {
52
+ RETURN_VALUE getData(out TimedDoubleSeq data);
53
+ };
54
+ };
55
+ '''
56
+
57
+ global_module = _parser.load(idl_str)
58
+ my_module = global_module.module_by_name('my_module')
59
+ dataGetter = my_module.interface_by_name('DataGetter')
60
+ print 'DataGetter interface'
61
+ for m in dataGetter.methods:
62
+ print '- method:'
63
+ print ' name:', m.name
64
+ print ' returns:', m.returns.name
65
+ print ' arguments:'
66
+ for a in m.arguments:
67
+ print ' name:', a.name
68
+ print ' type:', a.type
69
+ print ' direction:', a.direction
70
+
71
+ doubleSeq = my_module.typedef_by_name('DoubleSeq')
72
+ print 'typedef %s %s' % (doubleSeq.type.name, doubleSeq.name)
73
+
74
+ unionType = my_module.union_by_name('UnionType')
75
+ print 'descriminator kind: %s' % unionType.descriminator_kind
76
+ for m in unionType.members:
77
+ print '- member:'
78
+ print ' name:', m.name
79
+ print ' type:', m.type.name
80
+ print 'descriminator value associations:'
81
+ for a in m.descriminator_value_associations:
82
+ print ' %s' % a
83
+
84
+ timedDoubleSeq = my_module.struct_by_name('TimedDoubleSeq')
85
+ print 'TimedDoubleSeq'
86
+ for m in timedDoubleSeq.members:
87
+ print '- member:'
88
+ print ' name:', m.name
89
+ print ' type:', m.type.name
90
+
91
+
92
+ if __name__ == '__main__':
93
+ test()
@@ -0,0 +1,7 @@
1
+ #from parser import IDLParser
2
+ __all__=['parser', 'exception']
3
+
4
+
5
+
6
+
7
+
@@ -0,0 +1,50 @@
1
+ import os, sys, traceback
2
+
3
+ from . import node
4
+ sep = '::'
5
+
6
+
7
+ class IDLConst(node.IDLNode):
8
+
9
+ def __init__(self, name, typename, value, parent, filepath=None):
10
+ super(IDLConst, self).__init__('IDLConst', name, parent)
11
+ self._typename = typename
12
+ self._verbose = True
13
+ self._value = value
14
+ self._filepath= filepath
15
+
16
+ def to_simple_dic(self, quiet=False, full_path=False, recursive=False, member_only=False):
17
+ name = self.full_path if full_path else self.name
18
+ if quiet:
19
+ return 'const %s %s = %s' % (self.typename, name, self.value)
20
+ dic = { 'const %s' % name : { 'type' : self.typename,
21
+ 'value' : self.value } }
22
+ return dic
23
+
24
+ def to_dic(self):
25
+ dic = { 'name' : self.name,
26
+ 'filepath' : self.filepath,
27
+ 'classname' : self.classname,
28
+ 'typename' : self.typename,
29
+ 'value' : self.value }
30
+ return dic
31
+
32
+ @property
33
+ def typename(self):
34
+ return self._typename
35
+
36
+ @property
37
+ def type(self):
38
+ return self.root_node.find_types(self.typename)[0]
39
+ @property
40
+ def value(self):
41
+ return self._value
42
+
43
+ @property
44
+ def value_string(self):
45
+ return self._value
46
+
47
+ @property
48
+ def full_path(self):
49
+ return self.parent.full_path + sep + self.name
50
+
@@ -0,0 +1,114 @@
1
+ import os, sys, traceback
2
+
3
+ from . import node
4
+ sep = '::'
5
+
6
+ class IDLEnumValue(node.IDLNode):
7
+ def __init__(self, value, parent):
8
+ super(IDLEnumValue, self).__init__('IDLEnumValue', '', parent)
9
+ self._verbose = True
10
+ self._value = value
11
+
12
+ def parse_blocks(self, blocks, filepath=None):
13
+ self._filepath = filepath
14
+ if len(blocks) == 1:
15
+ self._name = blocks[0]
16
+ else:
17
+ sys.stdout.write('Unkown Enum format %s\n' % blocks)
18
+ #name, type = self._name_and_type(blocks)
19
+ #self._name = name
20
+ #self._type = type
21
+
22
+ @property
23
+ def full_path(self):
24
+ return self.full_path + '.' + self.name
25
+
26
+ def to_simple_dic(self):
27
+ dic = {self.name : self.value }
28
+ return dic
29
+
30
+ def to_dic(self):
31
+ dic = { 'name' : self.name,
32
+ 'filepath' : self.filepath,
33
+ 'classname' : self.classname,
34
+ 'value' : self.value }
35
+ return dic
36
+ @property
37
+ def value(self):
38
+ return self._value
39
+
40
+
41
+
42
+
43
+ class IDLEnum(node.IDLNode):
44
+
45
+ def __init__(self, name, parent):
46
+ super(IDLEnum, self).__init__('IDLEnum', name, parent)
47
+ self._verbose = True
48
+ self._values = []
49
+
50
+ def to_simple_dic(self, quiet=False, full_path=False, recursive=False, member_only=False):
51
+ name = self.full_path if full_path else self.name
52
+ if quiet:
53
+ return 'enum %s' % name
54
+ dic = { 'enum %s' % name : [v.to_simple_dic() for v in self.values] }
55
+ return dic
56
+
57
+
58
+ def to_dic(self):
59
+ dic = { 'name' : self.name,
60
+ 'classname' : self.classname,
61
+ 'values' : [v.to_dic() for v in self.values] }
62
+ return dic
63
+
64
+ @property
65
+ def full_path(self):
66
+ return self.parent.full_path + sep + self.name
67
+
68
+ def parse_tokens(self, token_buf, filepath=None):
69
+ self._filepath = filepath
70
+ self._counter = 0
71
+ ln, fn, kakko = token_buf.pop()
72
+ if not kakko == '{':
73
+ if self._verbose: sys.stdout.write('# Error. No kakko "{".\n')
74
+ raise InvalidIDLSyntaxError()
75
+
76
+ block_tokens = []
77
+ while True:
78
+ ln, fn, token = token_buf.pop()
79
+ if token == None:
80
+ if self._verbose: sys.stdout.write('# Error. No kokka "}".\n')
81
+ raise InvalidIDLSyntaxError()
82
+
83
+ elif token == '}':
84
+ ln, fn, token = token_buf.pop()
85
+ if not token == ';':
86
+ if self._verbose: sys.stdout.write('# Error. No semi-colon after "}".\n')
87
+ raise InvalidIDLSyntaxError()
88
+
89
+ if len(block_tokens) > 0:
90
+ self._parse_block(block_tokens)
91
+ break
92
+
93
+ if token == ',':
94
+ self._parse_block(block_tokens)
95
+ block_tokens = []
96
+ continue
97
+ block_tokens.append(token)
98
+
99
+ def _parse_block(self, blocks):
100
+ v = IDLEnumValue(self._counter, self)
101
+ self._counter = self._counter+ 1
102
+ v.parse_blocks(blocks, self.filepath)
103
+ self._values.append(v)
104
+
105
+ @property
106
+ def values(self):
107
+ return self._values
108
+
109
+
110
+ def value_by_name(self, name):
111
+ for m in self.values:
112
+ if m.name == name:
113
+ return m
114
+ return None
@@ -0,0 +1,37 @@
1
+
2
+
3
+
4
+ class IDLParserException(Exception):
5
+
6
+ def __init__(self, line_number=None, file_name=None, message='IDLParserException occurred.'):
7
+ self._className = 'IDLParserException'
8
+ self._line_number = line_number
9
+ self._file_name = file_name
10
+ self._message = message
11
+
12
+ @property
13
+ def message(self):
14
+ return 'File "' + self.file_name + '", line %s, ' % self.line_number + '(' + self._className + '):"' + self._message
15
+
16
+ @property
17
+ def line_number(self):
18
+ return self._line_number
19
+
20
+ @property
21
+ def file_name(self):
22
+ return self._file_name
23
+
24
+
25
+
26
+ class InvalidIDLSyntaxError(IDLParserException):
27
+
28
+ def __init__(self, line_number=None, file_name=None, message='IDLParserException occurred.'):
29
+ super(InvalidIDLSyntaxError, self).__init__(line_number, file_name, message)
30
+ self._className = 'InvalidIDLSyntaxError'
31
+ pass
32
+
33
+ class InvalidDataTypeException(IDLParserException):
34
+ pass
35
+
36
+ class IDLCanNotFindException(IDLParserException):
37
+ pass