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: 871 / 1830
Referenced in: #1002234 - Code generator (LIVE)
#1002299 - Some dialog
#3000169 - Answer for stefanreich
#3000174 - Answer for stefanreich
#3000175 - Answer for stefanreich
#3000176 - Answer for stefanreich
#3000177 - Answer for stefanreich
#3000179 - Answer for stefanreich
#3000180 - Answer for stefanreich
#3000181 - Answer for stefanreich
#3000182 - Answer for stefanreich
#3000184 - Answer for stefanreich
#3000185 - Answer for stefanreich
#3000202 - Answer for stefanreich (>> T conversion bot)
#3000203 - Answer for stefanreich (>> timing hello bot)
#3000208 - Answer for bgrgndz (>> list sub bots)
#3000209 - Answer for bgrgndz (>> list sub bots)
#3000238 - Answer for stefanreich (>> t power bot)
#3000369 - Answer for Stefan (>> list sub bots)
#3000376 - Answer for stefanreich (>> list sub bots)
#3000377 - Answer for stefanreich (>> timing eleu?)
#3000380 - Answer for stefanreich (>> list sub bots)
#3000381 - Answer for speedforce (>> list sub bots)
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)