LangTrans is a syntactic preprocessor that lets you customize any programming language's syntax.
It translates your custom syntax into the original language, allowing personalized coding while adhering to language specifications.
Using regular expressions, it extracts tokens from your custom language to generate the original syntax.
There are two ways you can install LangTrans:
Use the following command to clone the repository:
git clone https://github.com/LangTrans/LangTrans.git
After cloning, navigate into the LangTrans directory.
Go to Releases and download the latest executable or a installer.
You can use LangTrans from the command line using the following structure:
py langtrans.py <SoureFileName> <OutputFileName> <SyntaxRepr> <PatternRepr>
- SoureFileName: Name of the source code file written with your new syntax
- OutputFileName: Name of the source code file you want to generate with the original syntax
- SyntaxRepr: Name of the YAML file for your syntax representation (without .yaml extension)
- PatternRepr: Name of the YAML file for the pattern representation of the original language (without .yaml extension)
You can also use the following options with the langtrans.py command:
-h
: Displays help information-v
: Activates verbose mode-y
: Executes the 'after' command automatically-n
: Exits without executing the 'after' command
Here is our take on custom Python:
#Print
p"Hello World"
# Anonymous function
inc = (x) => x+1
# Lambda function
twice(x) = 2*x
# Single Line try-except
try inc("1") Exception print("Error:",err)
# Print Done if x is defined other wise Failed
print((x||True)?"Done":"Failed")
# Single Line if and check x defined or not
print('x is not defined') if !x
# Pipe Syntax
1 -> inc
|> print
# Arithmetic operations with functions
print((inc+twice)(3))
#Scope syntax work like in javascript
#scope1#
print("Scope1")
print("Done")
#scope2#
print("scope2")
print("Done")
#PEP 359 - The "make" statement
make type name(arg):
x = 1
y = 3
Here is a sample of the customized Common Lisp:
func printhis(s):
format(t,s)
printhis("Customized!")
You can share your language here.
We welcome contributions from everyone. If you're interested in contributing, here's how you can help:
-
Creating versions for other languages: If you're proficient in a particular programming language and wish to help create a version of LangTrans for it, please feel free to start. We'd greatly appreciate your expertise.
-
Reporting Bugs: If you encounter any bugs or issues, please open a new issue describing the bug, how you came across it, and any potential causes or solutions you have in mind.
-
Feature Suggestions: If you have any ideas for new features or improvements, we'd love to hear them. Please open an issue describing your suggestion in as much detail as possible.
-
Code Contributions: If you'd like to contribute code to fix bugs or add features, please fork and open a pull request. Ensure your code follows any style guidelines and include as much information as possible about your changes.
Before contributing, please make sure to check the existing issues and pull requests to avoid duplicating efforts. If you're new to open-source contribution and need guidance, don't hesitate to reach out.
If you need support with LangTrans, there are several ways we can assist you:
-
GitHub Issues: If you're experiencing a problem with LangTrans or want to suggest improvements or new features, you can open a new issue on our GitHub repository.
-
Documentation: You can find a wealth of information about how to use LangTrans, including detailed guides and examples, in our Gitbook documentation.
-
Community: You can join our Discord community, where you can ask questions, share your ideas, and get help from other LangTrans users.