Git Product home page Git Product logo

omnidan / simple-code-generator Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 176 KB

generates code automatically from models designed in a very simple language (or from C/C++ structs/classes, whichever syntax you prefer). This is based entirely on the approach of model-based-programming and saves a lot of time while keeping the code cleaner.

Home Page: http://omnidan.github.io/simple-code-generator/

License: Other

Python 100.00%

simple-code-generator's Introduction

Build Status

Basic syntax

Simple Model File (SMF) - Structure

(model|class|struct) <modelname>:
    <type> <parameter>

Syntax types

model sets the syntax type to the default model.

struct sets the syntax type to C-like-struct-model, which requires usage of semicolons and { }.

class is basically an alias for struct, but used in C++-like-class-models.

Later, there will be a library to use these C++ and C models in actual C/C++ code.

Optional parts of the style

Spacing, indentation, semicolon after parameter

Examples

Model (Simple)

model School:
    string location
    int teacher_count
    int pupils_count

Struct (C)

struct School {
    string location;
    int teacher_count;
    int pupils_count;
};

(should work in C when you define string)

Class (C++)

class School {
    string location;
    int teacher_count;
    int pupils_count;
};

(should work in C++ when you specify using namespace std;)

Advanced syntax

Arrays

Structure

<type> (array|list) <parameter>
or
(array|list) <type> <parameter>
or
[]

Optional parts of the style

Spacing

[] can be suffix/prefix of type or parameter

array must be prefix/suffix of the type

Instead of using the array or list, you can also append an "s" to the type. For example: Teachers loads an array of the model Teacher.

Examples

Model (Simple)

model School:
    string location
    string array teacher_names
    int pupils_count

Struct (C)

struct School {
    string location;
    string teachers[];
    int pupils_count;
};

Class (C++)

struct School {
    string location;
    string teachers[];
    int pupils_count;
};

Imports

Syntax

import <modelname>

Optional parts of the style

Semicolon after parameter, C/C++-like function

Examples

Model (Simple)

import Teacher
model School:
    string location
    Teachers teachers
    int pupils_count

Struct (C)

import("Teacher");
struct School {
    string location;
    Teacher teachers[];
    int pupils_count;
};

Class (C++)

import("Teacher");
struct School {
    string location;
    Teacher teachers[];
    int pupils_count;
};

simple-code-generator's People

Contributors

omnidan avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.