Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maelswarm/nymph
🧚 A slightly different version of C.
https://github.com/maelswarm/nymph
c language nymph preprocessor programming-language
Last synced: about 1 month ago
JSON representation
🧚 A slightly different version of C.
- Host: GitHub
- URL: https://github.com/maelswarm/nymph
- Owner: maelswarm
- License: mit
- Created: 2017-07-19T13:48:41.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-07-17T16:19:22.000Z (over 1 year ago)
- Last Synced: 2024-08-05T10:15:25.824Z (5 months ago)
- Topics: c, language, nymph, preprocessor, programming-language
- Language: C
- Homepage:
- Size: 2.74 MB
- Stars: 181
- Watchers: 8
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Nymph
Let's see what we can achieve by reworking C syntax.
## Overview
Nymph is a simple C like programming language.
Nymph acts as a preprocessor, converting Nymph files (extension \*.n) into C files.
This project is very much in development... It is not production ready.
## What's New
Nothing right now
## Goals
### Completed
* Class-Based OOP
* Subtyping
### In Progress
* TBD
### Pending
* Destructors?
* Type Inference?
* Reflection?
* Default function arguments?
* Lambdas?
## Example
mammal.n
```
#include
#includeclass Mammal {
+ int population = 0; // Class Variable (+)
- int height = 0, weight = 100; // Object Variable (-)+ Mammal *init(int height, int weight) { // Class Method (+) Constructor
this->height = height;
this->weight = weight;
Mammal->population++;
return this;
}- void print() { // Object Method (-)
printf("print instance properties...\n");
}
}
```human.n
```
#include "mammal.n"
#include
#includeclass Human : Mammal {
- char *name = NULL; // Object Variable (-)
+ Human *init(char *name, int height, int weight) { // Class Method (+) Constructor
this = super->init(height, weight);
this->name = name;
return this;
}- void died() { // Object Method (-) Constructor
free(this->name);
free(this);
Mammal->population--;
}
}int main(void) {
char *name = malloc(5);
memset(name, 0, sizeof(name));
strcpy(name, "Fred");
Human *person1 = Human->init(name, 76, 146); // Class Method Constructor Call
person1->print(); // Object Method Call
person1->died(); // Object Method Callreturn 0;
}
``````
nymph -r human.n
```