2017 © Pedro Peláez
 

package dorm

This is a compiler package for compiling and running c and cpp files this package is designed to can add any other compilers later.

image

aa-ahmed-aa/dorm

This is a compiler package for compiling and running c and cpp files this package is designed to can add any other compilers later.

  • Saturday, July 21, 2018
  • by aa-ahmed-aa
  • Repository
  • 1 Watchers
  • 1 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 5 Versions
  • 17 % Grown

The README.md

Dorm

This is a package for running and compiling your c and c++ files add the compiler to the configurations file and you are ready to go :boom: ., (*1)

Run TestCases & Coverage

  • Test cases composer run-script test.
  • Code Cvoverage composer run-script coverage.

:honey_pot: Install

You can install the package using composer require aa-ahmed-aa/dorm, (*2)

:hammer: Configuration

First you need to install compilers and configure their paths in src/Core/Config.php
, (*3)

C++

  • you can find the MinGW compiler Here
  • after you download the compiler files copy the MinGW folder to your C:// drive

Java

  • install jdk and configure the path in your environment variables you can find the judk Here

Python

  • install python from Here
  • if you want this package to handle both versions of python2.x and python3.x the package already do this and you can look at This Question to cnfigure both of them on the command line

:flashlight: Usage

First you need to setCompilationPath in this path the package will create files of the code and compile and run your code
so let's compile and run your first cpp code, (*4)

require ('vendor/autoload.php');
use Ahmedkhd\Dorm\Dorm;

$obj = new Executor('cpp');

//set compilation path
$obj->setCompilationPath( __DIR__ );
echo $obj->getCompilationPath();

Now lets compile and run some real code, (*5)

C++

here we compile and run c++ code and print the result, (*6)

$cpp_code = <<<'EOT'
    #include<iostream>
    using namespace std;

    int main()
    {
        cout<<"hello, c plus plus";
        return 0;
                }
EOT;

$comp = $obj->compile($cpp_code);
echo "Compilation : " . ( ! is_array($comp) ? "Success" : "Fail" )  . "\n";
echo "Running is : " . ( ! is_array($comp) ? $obj->run() : "Fail" ) . "\n";

Java

//java
$java_code = <<<'EOT'
    public class Main {
    public static void main(String[] args) {
        // Prints "Hello, World" to the terminal window.
        System.out.println("Hello, Java");
    }

}
EOT;

$obj = new Executor('java');
$comp = $obj->compile($java_code);
echo "Compilation : " . ( ! is_array($comp) ? "Success" : "Fail" )  . "\n";
echo "Running is : " . ( ! is_array($comp) ? $obj->run() : "Fail" ) . "\n";

Python

$python_code = <<<'EOT'
print "Hello, Python3.4"
EOT;

$obj = new Executor('python2');
$comp = $obj->compile( $python_code);
echo "Running : " . implode( $comp )  . "\n";

:electric_plug: Add your compiler

You can check this blog post for more information.

This package is designed to handle compile/run of any other compilers in your project
, (*7)

    $compilers = [
        "__COMPILER_NAME__"=>[
            "path" => "__COMPILER_PATH__",
            "file_extension" =>'__CODE_FILE_EXTENSION_',
            "compile_func" => __NAME_FOR_YOUR_COMPILER_FUNCTION__,
            "run_func" => __NAME_FOR_YOUR_RUN_FUNCTION__
        ]
    ];
Steps
  • Add your customized key for your configuration to use it later in your compile and run function see src/Core/Config.php.
  • Add your new StrategyTrait in src/Strategy/ folder with your run and compile funcion you can see examples like the JavaTrait and CAndCPPStrategy then add a use of your StrategyTrait in the src/Core/Core.php class
  • Test and Bom your compiler is there.

License

The MIT License (MIT). Please see License File for more information., (*8)

The Versions

21/07 2018

dev-master

9999999-dev

This is a compiler package for compiling and running c and cpp files this package is designed to can add any other compilers later.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Ahmed Khaled

command-line java python c compilers cpp compiler-manager javac python2 python3

05/05 2018

v1.3

1.3.0.0

This is a compiler package for compiling and running c and cpp files this package is designed to can add any other compilers later.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Ahmed Khaled

command-line java python c compilers cpp compiler-manager javac python2 python3

03/05 2018

dev-update-style

dev-update-style

This is a compiler package for compiling and running c and cpp files this package is designed to can add any other compilers later.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Ahmed Khaled

command-line c compilers cpp compiler-manager

29/04 2018

v1.1.0

1.1.0.0

This is a compiler package for compiling and running c and cpp files this package is designed to can add any other compilers later.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Ahmed Khaled

command-line c compilers cpp compiler-manager

29/04 2018

v1.0.0

1.0.0.0

this is a compiler package for compiling and running c and cpp files this package is designed to can add any other compilers later.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Ahmed Khaled

command-line c compilers cpp compiler-manager