Examples of LList


Examples of de.tuhrig.thofu.types.LList

 
  private LList parse(List<Object> tokens) {

    //System.out.println("parse " + tokens);
   
    LList list = new LList();

    while(tokens.size() > 0) {
     
      Object token = tokens.remove(0);
     
      /*
       * THOFU LANGUAGE
       */
     
      if(token.equals(";")) {

        return strip(list);
      }
      else if(token.equals("[")) {
       
        return list(tokens);
      }
      else if(token.equals("var")) {
       
        return defination(tokens);
      }
      else if(token.equals("=")) {
        
        return assignment(list, tokens);
      }
      else if(token.equals("for")) {

        return forLoop(tokens);
      }
      else if(token.equals("while")) {
       
        return whileLoop(tokens);
      }
      else if(token.equals("do")) {
       
        return doLoop(tokens);
      }
      else if(token.toString().startsWith("++")) {
       
        return crementBefore(list, token.toString(), "++", "+");
      }
      else if(token.toString().endsWith("++")) {
 
        return crementAfter(list, token.toString(), "++", "+");
      }
      else if(token.toString().startsWith("--")) {
       
        return crementBefore(list, token.toString(), "--", "-");
      }
      else if(token.toString().endsWith("--")) {
         
        return crementAfter(list, token.toString(), "--", "-");
      }
      else if(token.equals(".")) {

        return chain(list, tokens);
      }
      else if(token.equals("if")) {
       
        return ifBlock(list, tokens, token);
      }
      else if(token.equals("function")) {

        return function(tokens);
      }
      else if(token.equals("{")) {    // create new let
     
        return block(tokens);
      }     
      else if(token.equals("}")) {    // close let

        return strip(list);
      }
      else if(isBinaryOperator(token)) {    // any look up for binary operators?
                          // maybe dynamically editable?
        return binary(list, tokens, token);
      }
      else if(token.equals("(")) {

        List<LList> instructions = parenthesis(tokens);
       
        for(LList tmp : instructions) {
         
          if(tmp.size() == 1)
            list.add(tmp.get(0));
          else
            list.add(tmp);
        }
      }
     
      /*
       * JAVA API
       */
     
      else if(token.equals("new")) { 

        return constructor(list, tokens, token);
      }
      else if(token.toString().contains(".") && !token.toString().startsWith("\"")) { 

        // look ahead
        Object next = tokens.get(0);
       
        if(next.toString().equals("(")) {
         
          return method(list, tokens, token);
        }
        else {
       
          return field(list, tokens, token);
        }
      }
     
      /*
       * REST
       */
     
      else {

        list.add(type(token));
      }
     
      // close working list
      if(list.size() == 3) {
       
        tokens.add(0, list);

        list = new LList();
      }
    }

    // should never be reached!
    throw new RuntimeException("No ; found at end of statement");
View Full Code Here

Examples of de.tuhrig.thofu.types.LList

   
    Object object = tokens.remove(0);

    list.add(type(object + "."));

    LList parameters = parse(tokens);
   
    if(parameters.size() == 1) {
     
      list.add(parameters.get(0));
    }
    else {
     
      for(int i = 0; i < parameters.size(); i++)
        list.add(parameters.get(i));
    }
     
    return list;
  }
View Full Code Here

Examples of de.tuhrig.thofu.types.LList

//    System.out.println(list);
//    System.out.println(tokens);
//    System.out.println(token);

    LList parameters = parse(tokens);
   
    //System.out.println(parameters);
   
    String[] parts = token.toString().split("\\.");

    list.add(type("." + parts[1]));
    list.add(type(parts[0]));
   
    if(parameters.size() == 1) {
     
      list.add(parameters.get(0));
    }
    else {
     
      for(int i = 0; i < parameters.size(); i++)
        list.add(parameters.get(i));
    }

    return list;
  }
View Full Code Here

Examples of de.tuhrig.thofu.types.LList

        List<Object> tmp = new ArrayList<>();
        tmp.add(obj);
        tmp.add(";");
       
        LList element = parse(tmp);
       
        list.add(element.get(0));
      }
    }
   
    tokens.add(0, list);
View Full Code Here

Examples of de.tuhrig.thofu.types.LList

  private LList defination(List<Object> tokens) {

    Object name = tokens.remove(0);
            tokens.remove(0);    // =

    LList defination = new LList();
   
    defination.add(type("define"));
    defination.add(type(name));
   
    if(tokens.size() > 0)
      defination.add(parse(tokens));
    else
      defination.add(type("null"));
   
    return defination;
  }
View Full Code Here

Examples of de.tuhrig.thofu.types.LList

   
    tokens.remove(0);    // remove ) after (i; i <...
   
    increment.add(new Token(";"));    // add a ; to the final increment instruction

    LList loop = new LList();
   
    loop.add(type("for"));
    loop.add(parse(define));
    loop.add(parse(condition));
    loop.add(parse(increment));
   
   
    LList begin = new LList(type("begin"));
   
    getSubListAndClear(tokens, 0, tokens.indexOf(new Token("{")));
   
    tokens = tokens.subList(1, tokens.size() - 1);
   
    for(List<Object> list: split(tokens)) {

      begin.add(parse(list));
    }
   
    loop.add(begin);
   
   
View Full Code Here

Examples of de.tuhrig.thofu.types.LList

   
    tokens.remove(0);    // remove ) after (i; i <...
   
    condition.add(";");    // add a ; to the final increment instruction

    LList loop = new LList();
   
    loop.add(type("while"));
    loop.add(parse(condition));
    loop.add(parse(tokens));
   
    return loop;
  }
View Full Code Here

Examples of de.tuhrig.thofu.types.LList

   
    tokens.remove(0);    // remove ) after (i; i <...
   
    condition.add(";");    // add a ; to the final increment instruction

    LList loop = new LList();
   
    loop.add(type("do"));
    loop.add(parse(condition));
    loop.add(parse(tokens));
   
    return loop;
  }
View Full Code Here

Examples of de.tuhrig.thofu.types.LList

        instructions.add(current);
        current = new ArrayList<Object>();
      }
    }

    LList let = new LList();
   
    let.add(type("begin"));        // let and begin!!!!! TODO

    for(List<Object> instruction: instructions) {

      let.add(parse(instruction));
    }

    return let;
  }
View Full Code Here

Examples of de.tuhrig.thofu.types.LList

   
    int position = getParenthesisBalance(tokens, 0, "(", ")");
   
    List<Object> parameterTokens = getSubListAndClear(tokens, 1, position);

    LList paras = new LList();

    for(Object t: parameterTokens) {
     
      if(!t.equals(",")) {
       
        List<Object> current = new ArrayList<Object>();
        current.add(t);
        current.add(";");
        LList inner = parse(current);
        paras.add(inner.get(0));
      }
    }

    LList lambda = new LList();
    lambda.add(type("lambda"));
    lambda.add(paras);
   
    LList begin = new LList(type("begin"));
   
    getSubListAndClear(tokens, 0, tokens.indexOf(new Token("{")));
   
    tokens = tokens.subList(1, tokens.size() - 1);
   
    for(List<Object> list: split(tokens)) {

      begin.add(parse(list));
    }
   
    lambda.add(begin);

    return lambda;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.