Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

99
LINES

< > BotCompany Repo | #1002233 // Code generator

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (1692L/12K/40K).

//TODO:
//
//Add more features.
//Add + and > signs
//
!752

p{
  makeBot("Code generator.");
}

answer{
  if (matchStart("make code *",s ,m)) {
    S command = m.unq(0);
    S encodedcmmnd = "";
      command = command.replace("make code", "");
      if(command == null){
        ret null;
      }
      if(command.indexOf("newbot") != -1){
        encodedcmmnd += [[ 
        ``` !752
        
        p{
          makeBot('BOT NAME HERE');
        }
        answer{
          ret "hello";
        }``` ]];
      }
      if(command.indexOf("ifelifelse") != -1){
        encodedcmmnd += " ```if() {\n\n}else if() {\n\n}else{\n\n}``` ";
      }else if(command.indexOf("ifelse") != -1){
        encodedcmmnd += " ```if{\n\n}else{\n\n}``` ";
      }else if(command.indexOf("if") != -1){
        encodedcmmnd += " ```if() {\n\n}``` ";
      }
      if(command.indexOf("for") != -1){
        encodedcmmnd += " ```for(INIT;TERMINATE;INC;){ //you know what to do,right? RIGHT??\n\n}``` ";
      }
      if(command.indexOf("calculator") != -1){
        encodedcmmnd += [[
        ```
        import java.util.Scanner;
        
        double n1, n2;
        String operation;
        Scanner scannerObject = new Scanner(System.in);

        System.out.println("Enter first number");
        n1 = scannerObject. nextDouble();

        System.out.println("Enter second number");
        n2 = scannerObject. nextDouble();

        Scanner op = new Scanner(System.in);
        System.out.println("Enter your operation");
        operation = op.next();

        switch (operation)  {
        case "+":
            System.out.println("Your answer is " + (n1 + n2));
            break;

        case "-":
            System.out.println("Your answer is " + (n1 - n2));
            break;

        case "/":
            System.out.println("Your answer is " + (n1 / n2));
            break;

        case "*":
            System.out.println("Your asnwer is " + (n1 * n2));
            break;

        default:
            System.out.println("Dunno");

        }```]];
      }
      if(command.indexOf("fibonacci") != -1){
        encodedcmmnd += [[```
        int febCount = 15; //You can change this.
         int[] feb = new int[febCount];
         feb[0] = 0;
         feb[1] = 1;
         for(int i=2; i < febCount; i++){
            feb[i] = feb[i-1] + feb[i-2];
         }
         for(int i=0; i< febCount; i++){
            System.out.print(feb[i] + " ");
         }
        ```]];
      }
    //ntUpload(programID(), programID() + " generated code", encodedcmmnd);     Uncomment this later
    ret encodedcmmnd;
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, jlatgrcjtklg, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1002233
Snippet name: Code generator
Eternal ID of this version: #1002233/1
Text MD5: 207e26f745fe00194938485e3595534e
Transpilation MD5: 8538860ab1e6af4201f72ec8dde5ceca
Author: bgrgndz
Category:
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-02-28 16:13:53
Source code size: 2707 bytes / 99 lines
Pitched / IR pitched: No / No
Views / Downloads: 794 / 1735
Referenced in: [show references]