srcgen: The semantic source code generation framework
Project description
srcgen
Srcgen is a semantic code generation framework. Being semantic means that the code generator and the generated code bear similar structure, as well ; for instance, the body of an if statement is indented both in the generating and generated code. Here’s a short example:
>>> from srcgen.python import PythonModule >>> >>> m = PythonModule("foo") >>> m.import_("sys") >>> m.import_("os") >>> m.sep() >>> m.stmt("x = 5") >>> with m.if_("x > 8"): ... m.stmt("print 'oh no'") ... >>> with m.else_(): ... m.stmt("print 'oh yes'") ... >>> print m import sys import os x = 5 if x > 8: print 'oh no' else: print 'oh yes'
You can nest deeper, of course, as well as extract common pieces of code into functions:
m = PythonModule("foo") with m.class_("MyClass"): with m.method("__init__", "
Languages
At the moment Srcgen supports:
C
Python
Cython
HTML/XML
More languages will be added per public demand (you’re welcome to join the effort!)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file srcgen-1.1.0.zip
.
File metadata
- Download URL: srcgen-1.1.0.zip
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4137c1b5c63df186c08774a08549c7658dea43e50457c32869c5de03e91b688 |
|
MD5 | 61319f331033282643e76458acf2f708 |
|
BLAKE2b-256 | c16dcbb58f9c01b7b01b6a5745a433120efbe8a9cb111dc3db3be898477d419d |
File details
Details for the file srcgen-1.1.0.tar.gz
.
File metadata
- Download URL: srcgen-1.1.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bccf614dbcbbd735e15cf189bee519a3219350a955b10ca2f2e5383d6a33918c |
|
MD5 | 470596d12f7d297e3687b1adaa35d08e |
|
BLAKE2b-256 | da6ec17bee1caeeaf32bb6ee0f148de1f379b50a165e5314bbf8a7e26c2c9b41 |
File details
Details for the file srcgen-1.1.0.win32.exe
.
File metadata
- Download URL: srcgen-1.1.0.win32.exe
- Upload date:
- Size: 208.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d7fd88058145fd0f0fd4fd4e53f0537ec28d142dd4b132d6531f39c1923ada7 |
|
MD5 | 57f31eac77ec774a78b7868c51684c60 |
|
BLAKE2b-256 | 68b5e4d565e57d2ae4616939fd8582907959acb6472e81d814b4f43fc9bb330c |