textx
Domain-Specific Languages and parsers in Python made easy http://textx.github.io/textX/
Science Score: 36.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
✓DOI references
Found 2 DOI reference(s) in README -
○Academic publication links
-
✓Committers with academic emails
1 of 24 committers (4.2%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.9%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
Domain-Specific Languages and parsers in Python made easy http://textx.github.io/textX/
Basic Info
Statistics
- Stars: 814
- Watchers: 26
- Forks: 78
- Open Issues: 58
- Releases: 7
Topics
Metadata Files
README.md

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 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 metamodelfromstr, getchildrenof_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: 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 = metamodelfromstr(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.modelfromstr(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 = getchildrenof_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
Implementing Martin Fowler's State Machine DSL in textX
Docs and tutorials
The full documentation with tutorials is available at http://textx.github.io/textX/stable/
You can also try textX in our playground. There is a dropdown with several examples to get you started.
Support in IDE/editors
Projects that are currently in progress are:
- 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 - Language Server Protocol support for textX languages
- textX-extensions - syntax highlighting, code outline
- viewX - creating visualizers for textX languages
If you are a vim editor user check out support for vim.
For emacs there is textx-mode which is also available in MELPA.
You can also check out textX-ninja project. It is currently unmaintained.
Discussion and help
For general questions, suggestions, and feature requests please use GitHub Discussions.
For issues please use GitHub issue tracker.
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. Knowledge-Based Systems, 115, 1-4.
License
MIT
Python versions
Tested for 3.8+
Owner
- Name: textX
- Login: textX
- Kind: organization
- Repositories: 21
- Profile: https://github.com/textX
Domain-Specific Languages and parsers in Python made easy
GitHub Events
Total
- Create event: 9
- Release event: 4
- Issues event: 5
- Watch event: 37
- Issue comment event: 10
- Push event: 9
- Pull request event: 2
- Fork event: 2
Last Year
- Create event: 9
- Release event: 4
- Issues event: 5
- Watch event: 37
- Issue comment event: 10
- Push event: 9
- Pull request event: 2
- Fork event: 2
Committers
Last synced: almost 3 years ago
All Time
- Total Commits: 1,225
- Total Committers: 24
- Avg Commits per committer: 51.042
- Development Distribution Score (DDS): 0.211
Top Committers
| Name | Commits | |
|---|---|---|
| Igor Dejanovic | i****c@g****m | 967 |
| goto40 | p****l@g****m | 149 |
| goto40 | u****m | 55 |
| Elero Daniel | d****e@g****m | 7 |
| borismarin | b****n@g****m | 7 |
| Markus Schmaus | m****s@w****e | 5 |
| hlouzada | h****2@g****m | 5 |
| Renata | v****8@g****m | 4 |
| Daniel Krikun | k****l@g****m | 3 |
| Mathias Lüdtke | m****e@i****e | 3 |
| Vincent Aranega | v****a@a****m | 3 |
| Lucas Bourneuf | l****f@l****t | 2 |
| Daniel | e****l@g****m | 2 |
| Michał Górny | m****y@g****g | 2 |
| simkimsia | k****a@o****m | 2 |
| Bernhard M. Wiedemann | b****n@s****e | 1 |
| CedArctic | k****8@g****m | 1 |
| cr0hn | c****n@c****m | 1 |
| Sebastian Wagner | s****x@s****t | 1 |
| Alen Suljkanovic | a****1@g****m | 1 |
| goto40 | g****0@u****m | 1 |
| Felix Yan | f****s@a****g | 1 |
| KimSia Sim | k****y@g****m | 1 |
| Gröger Florian, v040226 | f****r@v****e | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 79
- Total pull requests: 40
- Average time to close issues: about 1 year
- Average time to close pull requests: 3 days
- Total issue authors: 45
- Total pull request authors: 11
- Average comments per issue: 3.48
- Average comments per pull request: 2.55
- Merged pull requests: 37
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 4
- Pull requests: 1
- Average time to close issues: 6 days
- Average time to close pull requests: 1 day
- Issue authors: 4
- Pull request authors: 1
- Average comments per issue: 2.0
- Average comments per pull request: 3.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- igordejanovic (13)
- goto40 (11)
- stanislaw (6)
- pvmm (2)
- mgorny (2)
- mnaderhirn (2)
- Aluriak (2)
- dkrikun (2)
- yurivict (2)
- argenos (1)
- fgro93 (1)
- meena-abdelmaseeh (1)
- paulocoutinhox (1)
- cedric05 (1)
- davidchall (1)
Pull Request Authors
- igordejanovic (21)
- goto40 (6)
- stanislaw (4)
- mgorny (2)
- NevenaAl (2)
- felixonmars (1)
- CedArctic (1)
- davidchall (1)
- furkanakkurt1335 (1)
- danyeaw (1)
- hlouzada (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 3
-
Total downloads:
- pypi 74,869 last-month
-
Total dependent packages: 18
(may contain duplicates) -
Total dependent repositories: 57
(may contain duplicates) - Total versions: 71
- Total maintainers: 1
pypi.org: textx
Meta-language for DSL implementation inspired by Xtext
- Homepage: https://textx.github.io/textX/
- Documentation: https://textx.readthedocs.io/
- License: MIT License
-
Latest release: 4.2.2
published 10 months ago
Rankings
Maintainers (1)
proxy.golang.org: github.com/textx/textx
- Documentation: https://pkg.go.dev/github.com/textx/textx#section-documentation
- License: mit
-
Latest release: v2.2.0+incompatible
published over 5 years ago
Rankings
proxy.golang.org: github.com/textX/textX
- Documentation: https://pkg.go.dev/github.com/textX/textX#section-documentation
- License: mit
-
Latest release: v2.2.0+incompatible
published over 5 years ago
Rankings
Dependencies
- actions/checkout v2 composite
- actions/setup-python v2 composite
- gprof2dot * test
- memory_profiler * test
- psutil * test

