diff options
Diffstat (limited to 'python-textx.spec')
| -rw-r--r-- | python-textx.spec | 688 |
1 files changed, 688 insertions, 0 deletions
diff --git a/python-textx.spec b/python-textx.spec new file mode 100644 index 0000000..3cca598 --- /dev/null +++ b/python-textx.spec @@ -0,0 +1,688 @@ +%global _empty_manifest_terminate_build 0 +Name: python-textX +Version: 3.1.1 +Release: 1 +Summary: Meta-language for DSL implementation inspired by Xtext +License: MIT +URL: https://github.com/textX/textX +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/32/e5/04de728335471537acd49a5ca025e697b7b303e40d46facf143294b5a989/textX-3.1.1.tar.gz +BuildArch: noarch + +Requires: python3-Arpeggio +Requires: python3-click +Requires: python3-textX-dev +Requires: python3-click +Requires: python3-setuptools-scm +Requires: python3-mkdocs +Requires: python3-mike +Requires: python3-twine +Requires: python3-click +Requires: python3-flake8 +Requires: python3-tox +Requires: python3-jinja2 +Requires: python3-coverage +Requires: python3-coveralls +Requires: python3-pytest +Requires: python3-html5lib + +%description + + +[](https://pypi.python.org/pypi/textX) + +[](https://github.com/textx/textx/actions) +[](https://coveralls.io/github/textX/textX?branch=master) +[](http://textx.github.io/textX/latest/) + + +textX is a meta-language for building Domain-Specific Languages (DSLs) in +Python. It is inspired by [Xtext]. + +In a nutshell, textX will help you build your textual language in an easy way. +You can invent your own language or build a support for already existing textual +language or file format. + +From a single language description (grammar), textX will build a parser and a +meta-model (a.k.a. abstract syntax) for the language. See the docs for the +details. + +textX follows the syntax and semantics of Xtext but [differs in some +places](http://textx.github.io/textX/latest/about/comparison/) and is +implemented 100% in Python using [Arpeggio] PEG parser - no grammar ambiguities, +unlimited lookahead, interpreter style of work. + + +## Quick intro + +Here is a complete example that shows the definition of a simple DSL for +drawing. We also show how to define a custom class, interpret models and search +for instances of a particular type. + +```python +from textx import metamodel_from_str, get_children_of_type + +grammar = """ +Model: commands*=DrawCommand; +DrawCommand: MoveCommand | ShapeCommand; +ShapeCommand: LineTo | Circle; +MoveCommand: MoveTo | MoveBy; +MoveTo: 'move' 'to' position=Point; +MoveBy: 'move' 'by' vector=Point; +Circle: 'circle' radius=INT; +LineTo: 'line' 'to' point=Point; +Point: x=INT ',' y=INT; +""" + +# We will provide our class for Point. +# Classes for other rules will be dynamically generated. +class Point(object): + def __init__(self, parent, x, y): + self.parent = parent + self.x = x + self.y = y + + def __str__(self): + return "{},{}".format(self.x, self.y) + + def __add__(self, other): + return Point(self.parent, self.x + other.x, self.y + other.y) + +# Create meta-model from the grammar. Provide `Point` class to be used for +# the rule `Point` from the grammar. +mm = metamodel_from_str(grammar, classes=[Point]) + +model_str = """ + move to 5, 10 + line to 10, 10 + line to 20, 20 + move by 5, -7 + circle 10 + line to 10, 10 +""" + +# Meta-model knows how to parse and instantiate models. +model = mm.model_from_str(model_str) + +# At this point model is a plain Python object graph with instances of +# dynamically created classes and attributes following the grammar. + +def cname(o): + return o.__class__.__name__ + +# Let's interpret the model +position = Point(None, 0, 0) +for command in model.commands: + if cname(command) == 'MoveTo': + print('Moving to position', command.position) + position = command.position + elif cname(command) == 'MoveBy': + position = position + command.vector + print('Moving by', command.vector, 'to a new position', position) + elif cname(command) == 'Circle': + print('Drawing circle at', position, 'with radius', command.radius) + else: + print('Drawing line from', position, 'to', command.point) + position = command.point +print('End position is', position) + +# Output: +# Moving to position 5,10 +# Drawing line from 5,10 to 10,10 +# Drawing line from 10,10 to 20,20 +# Moving by 5,-7 to a new position 25,13 +# Drawing circle at 25,13 with radius 10 +# Drawing line from 25,13 to 10,10 + +# Collect all points starting from the root of the model +points = get_children_of_type("Point", model) +for point in points: + print('Point: {}'.format(point)) + +# Output: +# Point: 5,10 +# Point: 10,10 +# Point: 20,20 +# Point: 5,-7 +# Point: 10,10 +``` + + +## Video tutorials + + +### Introduction to textX + + +[](https://www.youtube.com/watch?v=CN2IVtInapo) + + +### Implementing Martin Fowler's State Machine DSL in textX + +[](https://www.youtube.com/watch?v=HI14jk0JIR0) + + +## Docs and tutorials + +The full documentation with tutorials is available at +http://textx.github.io/textX/stable/ + + +# Support in IDE/editors + +Projects that are currently in progress are: + +- [textX-LS](https://github.com/textX/textX-LS) - support for Language Server + Protocol and VS Code for any textX based language. This project is about to + supersede the following projects: + - [textX-languageserver](https://github.com/textX/textX-languageserver) - + Language Server Protocol support for textX languages + - [textX-extensions](https://github.com/textX/textX-extensions) - syntax + highlighting, code outline +- [viewX](https://github.com/danielkupco/viewX-vscode) - creating visualizers + for textX languages + +If you are a vim editor user check +out [support for vim](https://github.com/textX/textx.vim/). + +For emacs there is [textx-mode](https://github.com/textX/textx-mode) which is +also available in [MELPA](https://melpa.org/#/textx-mode). + +You can also check +out [textX-ninja project](https://github.com/textX/textX-ninja). It is +currently unmaintained. + + +## Discussion and help + +For general questions, suggestions, and feature requests please use [GitHub +Discussions](https://github.com/textX/textX/discussions). + + +For issues please use [GitHub issue +tracker](https://github.com/textX/textX/issues). + + +## Citing textX + +If you are using textX in your research project we would be very grateful if you +cite our paper: + +Dejanović I., Vaderna R., Milosavljević G., Vuković Ž. (2017). [TextX: A Python +tool for Domain-Specific Languages +implementation](https://www.doi.org/10.1016/j.knosys.2016.10.023). +Knowledge-Based Systems, 115, 1-4. + + +## License + +MIT + +## Python versions + +Tested for 3.6+ + + +[Arpeggio]: https://github.com/textX/Arpeggio +[Xtext]: http://www.eclipse.org/Xtext/ + + +%package -n python3-textX +Summary: Meta-language for DSL implementation inspired by Xtext +Provides: python-textX +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-textX + + +[](https://pypi.python.org/pypi/textX) + +[](https://github.com/textx/textx/actions) +[](https://coveralls.io/github/textX/textX?branch=master) +[](http://textx.github.io/textX/latest/) + + +textX is a meta-language for building Domain-Specific Languages (DSLs) in +Python. It is inspired by [Xtext]. + +In a nutshell, textX will help you build your textual language in an easy way. +You can invent your own language or build a support for already existing textual +language or file format. + +From a single language description (grammar), textX will build a parser and a +meta-model (a.k.a. abstract syntax) for the language. See the docs for the +details. + +textX follows the syntax and semantics of Xtext but [differs in some +places](http://textx.github.io/textX/latest/about/comparison/) and is +implemented 100% in Python using [Arpeggio] PEG parser - no grammar ambiguities, +unlimited lookahead, interpreter style of work. + + +## Quick intro + +Here is a complete example that shows the definition of a simple DSL for +drawing. We also show how to define a custom class, interpret models and search +for instances of a particular type. + +```python +from textx import metamodel_from_str, get_children_of_type + +grammar = """ +Model: commands*=DrawCommand; +DrawCommand: MoveCommand | ShapeCommand; +ShapeCommand: LineTo | Circle; +MoveCommand: MoveTo | MoveBy; +MoveTo: 'move' 'to' position=Point; +MoveBy: 'move' 'by' vector=Point; +Circle: 'circle' radius=INT; +LineTo: 'line' 'to' point=Point; +Point: x=INT ',' y=INT; +""" + +# We will provide our class for Point. +# Classes for other rules will be dynamically generated. +class Point(object): + def __init__(self, parent, x, y): + self.parent = parent + self.x = x + self.y = y + + def __str__(self): + return "{},{}".format(self.x, self.y) + + def __add__(self, other): + return Point(self.parent, self.x + other.x, self.y + other.y) + +# Create meta-model from the grammar. Provide `Point` class to be used for +# the rule `Point` from the grammar. +mm = metamodel_from_str(grammar, classes=[Point]) + +model_str = """ + move to 5, 10 + line to 10, 10 + line to 20, 20 + move by 5, -7 + circle 10 + line to 10, 10 +""" + +# Meta-model knows how to parse and instantiate models. +model = mm.model_from_str(model_str) + +# At this point model is a plain Python object graph with instances of +# dynamically created classes and attributes following the grammar. + +def cname(o): + return o.__class__.__name__ + +# Let's interpret the model +position = Point(None, 0, 0) +for command in model.commands: + if cname(command) == 'MoveTo': + print('Moving to position', command.position) + position = command.position + elif cname(command) == 'MoveBy': + position = position + command.vector + print('Moving by', command.vector, 'to a new position', position) + elif cname(command) == 'Circle': + print('Drawing circle at', position, 'with radius', command.radius) + else: + print('Drawing line from', position, 'to', command.point) + position = command.point +print('End position is', position) + +# Output: +# Moving to position 5,10 +# Drawing line from 5,10 to 10,10 +# Drawing line from 10,10 to 20,20 +# Moving by 5,-7 to a new position 25,13 +# Drawing circle at 25,13 with radius 10 +# Drawing line from 25,13 to 10,10 + +# Collect all points starting from the root of the model +points = get_children_of_type("Point", model) +for point in points: + print('Point: {}'.format(point)) + +# Output: +# Point: 5,10 +# Point: 10,10 +# Point: 20,20 +# Point: 5,-7 +# Point: 10,10 +``` + + +## Video tutorials + + +### Introduction to textX + + +[](https://www.youtube.com/watch?v=CN2IVtInapo) + + +### Implementing Martin Fowler's State Machine DSL in textX + +[](https://www.youtube.com/watch?v=HI14jk0JIR0) + + +## Docs and tutorials + +The full documentation with tutorials is available at +http://textx.github.io/textX/stable/ + + +# Support in IDE/editors + +Projects that are currently in progress are: + +- [textX-LS](https://github.com/textX/textX-LS) - support for Language Server + Protocol and VS Code for any textX based language. This project is about to + supersede the following projects: + - [textX-languageserver](https://github.com/textX/textX-languageserver) - + Language Server Protocol support for textX languages + - [textX-extensions](https://github.com/textX/textX-extensions) - syntax + highlighting, code outline +- [viewX](https://github.com/danielkupco/viewX-vscode) - creating visualizers + for textX languages + +If you are a vim editor user check +out [support for vim](https://github.com/textX/textx.vim/). + +For emacs there is [textx-mode](https://github.com/textX/textx-mode) which is +also available in [MELPA](https://melpa.org/#/textx-mode). + +You can also check +out [textX-ninja project](https://github.com/textX/textX-ninja). It is +currently unmaintained. + + +## Discussion and help + +For general questions, suggestions, and feature requests please use [GitHub +Discussions](https://github.com/textX/textX/discussions). + + +For issues please use [GitHub issue +tracker](https://github.com/textX/textX/issues). + + +## Citing textX + +If you are using textX in your research project we would be very grateful if you +cite our paper: + +Dejanović I., Vaderna R., Milosavljević G., Vuković Ž. (2017). [TextX: A Python +tool for Domain-Specific Languages +implementation](https://www.doi.org/10.1016/j.knosys.2016.10.023). +Knowledge-Based Systems, 115, 1-4. + + +## License + +MIT + +## Python versions + +Tested for 3.6+ + + +[Arpeggio]: https://github.com/textX/Arpeggio +[Xtext]: http://www.eclipse.org/Xtext/ + + +%package help +Summary: Development documents and examples for textX +Provides: python3-textX-doc +%description help + + +[](https://pypi.python.org/pypi/textX) + +[](https://github.com/textx/textx/actions) +[](https://coveralls.io/github/textX/textX?branch=master) +[](http://textx.github.io/textX/latest/) + + +textX is a meta-language for building Domain-Specific Languages (DSLs) in +Python. It is inspired by [Xtext]. + +In a nutshell, textX will help you build your textual language in an easy way. +You can invent your own language or build a support for already existing textual +language or file format. + +From a single language description (grammar), textX will build a parser and a +meta-model (a.k.a. abstract syntax) for the language. See the docs for the +details. + +textX follows the syntax and semantics of Xtext but [differs in some +places](http://textx.github.io/textX/latest/about/comparison/) and is +implemented 100% in Python using [Arpeggio] PEG parser - no grammar ambiguities, +unlimited lookahead, interpreter style of work. + + +## Quick intro + +Here is a complete example that shows the definition of a simple DSL for +drawing. We also show how to define a custom class, interpret models and search +for instances of a particular type. + +```python +from textx import metamodel_from_str, get_children_of_type + +grammar = """ +Model: commands*=DrawCommand; +DrawCommand: MoveCommand | ShapeCommand; +ShapeCommand: LineTo | Circle; +MoveCommand: MoveTo | MoveBy; +MoveTo: 'move' 'to' position=Point; +MoveBy: 'move' 'by' vector=Point; +Circle: 'circle' radius=INT; +LineTo: 'line' 'to' point=Point; +Point: x=INT ',' y=INT; +""" + +# We will provide our class for Point. +# Classes for other rules will be dynamically generated. +class Point(object): + def __init__(self, parent, x, y): + self.parent = parent + self.x = x + self.y = y + + def __str__(self): + return "{},{}".format(self.x, self.y) + + def __add__(self, other): + return Point(self.parent, self.x + other.x, self.y + other.y) + +# Create meta-model from the grammar. Provide `Point` class to be used for +# the rule `Point` from the grammar. +mm = metamodel_from_str(grammar, classes=[Point]) + +model_str = """ + move to 5, 10 + line to 10, 10 + line to 20, 20 + move by 5, -7 + circle 10 + line to 10, 10 +""" + +# Meta-model knows how to parse and instantiate models. +model = mm.model_from_str(model_str) + +# At this point model is a plain Python object graph with instances of +# dynamically created classes and attributes following the grammar. + +def cname(o): + return o.__class__.__name__ + +# Let's interpret the model +position = Point(None, 0, 0) +for command in model.commands: + if cname(command) == 'MoveTo': + print('Moving to position', command.position) + position = command.position + elif cname(command) == 'MoveBy': + position = position + command.vector + print('Moving by', command.vector, 'to a new position', position) + elif cname(command) == 'Circle': + print('Drawing circle at', position, 'with radius', command.radius) + else: + print('Drawing line from', position, 'to', command.point) + position = command.point +print('End position is', position) + +# Output: +# Moving to position 5,10 +# Drawing line from 5,10 to 10,10 +# Drawing line from 10,10 to 20,20 +# Moving by 5,-7 to a new position 25,13 +# Drawing circle at 25,13 with radius 10 +# Drawing line from 25,13 to 10,10 + +# Collect all points starting from the root of the model +points = get_children_of_type("Point", model) +for point in points: + print('Point: {}'.format(point)) + +# Output: +# Point: 5,10 +# Point: 10,10 +# Point: 20,20 +# Point: 5,-7 +# Point: 10,10 +``` + + +## Video tutorials + + +### Introduction to textX + + +[](https://www.youtube.com/watch?v=CN2IVtInapo) + + +### Implementing Martin Fowler's State Machine DSL in textX + +[](https://www.youtube.com/watch?v=HI14jk0JIR0) + + +## Docs and tutorials + +The full documentation with tutorials is available at +http://textx.github.io/textX/stable/ + + +# Support in IDE/editors + +Projects that are currently in progress are: + +- [textX-LS](https://github.com/textX/textX-LS) - support for Language Server + Protocol and VS Code for any textX based language. This project is about to + supersede the following projects: + - [textX-languageserver](https://github.com/textX/textX-languageserver) - + Language Server Protocol support for textX languages + - [textX-extensions](https://github.com/textX/textX-extensions) - syntax + highlighting, code outline +- [viewX](https://github.com/danielkupco/viewX-vscode) - creating visualizers + for textX languages + +If you are a vim editor user check +out [support for vim](https://github.com/textX/textx.vim/). + +For emacs there is [textx-mode](https://github.com/textX/textx-mode) which is +also available in [MELPA](https://melpa.org/#/textx-mode). + +You can also check +out [textX-ninja project](https://github.com/textX/textX-ninja). It is +currently unmaintained. + + +## Discussion and help + +For general questions, suggestions, and feature requests please use [GitHub +Discussions](https://github.com/textX/textX/discussions). + + +For issues please use [GitHub issue +tracker](https://github.com/textX/textX/issues). + + +## Citing textX + +If you are using textX in your research project we would be very grateful if you +cite our paper: + +Dejanović I., Vaderna R., Milosavljević G., Vuković Ž. (2017). [TextX: A Python +tool for Domain-Specific Languages +implementation](https://www.doi.org/10.1016/j.knosys.2016.10.023). +Knowledge-Based Systems, 115, 1-4. + + +## License + +MIT + +## Python versions + +Tested for 3.6+ + + +[Arpeggio]: https://github.com/textX/Arpeggio +[Xtext]: http://www.eclipse.org/Xtext/ + + +%prep +%autosetup -n textX-3.1.1 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-textX -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Tue Apr 11 2023 Python_Bot <Python_Bot@openeuler.org> - 3.1.1-1 +- Package Spec generated |
