Code Monkey home page Code Monkey logo

cpy's Introduction

CPY

To create the executable simply execute make on the source folder To compile cpy files use the created executable targeting the main file of the required project: cpy main.cpy -flags

CPY is a (Pre)Compiler of .cpy files, those are basically C++ without redundancy.
	Curly brackets are implied from indentation
	Semicolons are implied from line breaks (lines must be marked to continue, not to break)
	Headers are interpreted from the sources and includes
	Can return multiple values from functions
	While still being statically typed (and just as fast as C++, for it is just a pre-compiler)
		variable types can be implied from equity or manually specified.
	Sequenced style declarations have also been generalised to functions:
		"int a, b" works inside function declarations
Simply execute the compiler followed by your source folder and it will create the executable

In any of the given examples, "cpy mainFile.cpy" will create a working executable

Features:

Generates all the necessary headers and compiles resulting project. If you include a header "#include "somecode.h"" of a "somecode.cpy", the header will be generated (as well as the cpp file)

Default compilation is optimized in makefile style, only recompiling modified files, increasing overall compilation speed With the use of a flag (-ex) generates a c++ project folder, makefile included, ready for sharing

Implies semicolons from endlines, Implies {} using identation,

Can imply variable types from assignment:

a = 10
b = a
//Declares a and b as integers

Sometimes you don't want to declare a new instance of a not directly visible variable, this the known tag was created

void Rectangle::set_values (int w, h)
	known width = w
	known height = h
//This will tell the compiler width and height are inside the Rectangle namespace, thus not implying variable declaration

Can return multiple values from functions:

operations(int a, b)
	sum = a + b
	subtract = a - b
	multiply = a * b
	divide = a / b
	return sum, subtract, multiply, divide
	
main()
	sum, _, mult = operations(20, 10)
	! sum mult

//Produces the output:
30 10

//_ variables mean ignore this return value
//The last variables can be omitted if not necessary

Implies function argument types based on previous:

int somefunction(string a, b)
	code...
//Declares a and b as strings

Can imply parenthesis on if, switch, for and while:

	if x > 0
		...
	else if x < 0
		...
	for int i = 0; i < 100; i++
		...
	while x--
		...
	switch x
		case 1:
			...
			break
		...

Can imply ">>" and "<<" on cin, cout and cerr

	cin a b
	cout a b endl
	cerr a b endl

Four new print functions:

	! arg1 arg2 arg3
	//! prints a new line, with each argument separated by spaces
	
	!! arg1 arg2 arg3
	//!! prints each argument separated by spaces
	
	? "prompt" variable variable "prompt" variable 
	//? Reads input given inside variables using cin and prints given strings using cout
	
	?? arg1 arg2 arg3
	//?? is meant for debugging, prints a new debug line in the format:
	//arg1 = ContentOfArg1 | arg2 = ContentOfArg2 | arg3 = ContentOfArg3

Simplified for sintax:

	for i a
		...
	//Iterates i from 0 up to a, 1 at a time
	
	for i a b
		...
	//Iterates i from a up to b-1, 1 at a time
	
	rof i a
		...
	//Iterates i from a down to a, 1 at a time
	
	rof i a b
		...
	//Iterates i from a down to b, 1 at a time
	
	for i a b c
		...
	//Iterates i from a up to b-1, c at a time
	
	for i a b -c
		...
	//Iterates i from a down to b, c at a time
	
	//The standard sintax still works normally
	for i = (float)a; i <= b; i += 0.5
		...
	//Iterates i from a up to b 0.5 at a time

New precompilation tag: #raw "file" Includes file's content directly in code before exporting, usefull if you can only send one file instead of a project - intended for templates at competitive coding.

Can be compiled alongside normal cpp files, so hybrid projects are possible
CPY can also compile pure cpp projects, it will automatically link files and compile them intelligently

Only edits clones of the source files in a separate folder

USAGE: cpy SourceCode Flags
Flags:
        -h: Shows this help page
        -b: Use line breaks on itermediate code
        -s: Silent compilation, only prints errors
        -ex: Exports project to a directory containing only c++ source and a Makefile
        -r: Automatically runs compiled code
        -nc: Doesn't compile resulting code
        -o target: Specifies target executable name, when not specified target = a
        -OtherFlags: Redirects flag to underlying compiler (g++)

cpy's People

Contributors

shovon avatar turnipjs avatar vrsperanza avatar

Watchers

 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.