Examples of WeaselToken


Examples of weasel.compiler.WeaselToken

  private WeaselToken token;
  private List<Object> indexes = new ArrayList<Object>();
 
  public WeaselArrayInit(ListIterator<WeaselToken> iterator, int arrays) throws WeaselCompilerException {
    boolean canComeArray = arrays>1;
    WeaselToken token = iterator.next();
    this.token = token;
    if(token.tokenType!=WeaselTokenType.CLOSEBLOCK){
      iterator.previous();
      while(true){
        token = iterator.next();
View Full Code Here

Examples of weasel.compiler.WeaselToken

  private String classByteName;
  private WeaselTreeGeneric generic;
  public boolean close;
 
  public WeaselTreeGenericElement(ListIterator<WeaselToken> iterator) throws WeaselCompilerException {
    WeaselToken token = iterator.next();
    if(token.tokenType!=WeaselTokenType.IDENT){
      throw new WeaselCompilerException(token.line, "Expect Ident but got %s", token);
    }
    this.token = token;
    realClassName = (String) token.param;
View Full Code Here

Examples of weasel.compiler.WeaselToken

  private WeaselArrayInit arrayInit;
 
  public WeaselTreeTop(WeaselTree tree, ListIterator<WeaselToken> iterator) throws WeaselCompilerException {
    this.tree = tree;
    if(iterator.hasNext()){
      WeaselToken token = iterator.next();
      if(token.tokenType==WeaselTokenType.OPENBRACKET){
        isFunc = true;
        System.out.println("Func");
        func = WeaselTree.parse(iterator, WeaselTokenType.CLOSEBRACKET);
      }else if(token.tokenType==WeaselTokenType.OPENINDEX){
View Full Code Here

Examples of weasel.compiler.WeaselToken

    if(tree2==null){
      throw new WeaselCompilerException(token.line, "Expect boolean value in secound part of for");
    }
    WeaselTree tree3 = WeaselTree.parse(iterator, WeaselTokenType.CLOSEBRACKET);
   
    WeaselToken t = iterator.next();
    WeaselCompilerReturn wcr;
    if(instructions == null){
      instructions = new WeaselInstructionList();
      instructions.add(token.line, new WeaselInstructionJumperDummy());
    }
View Full Code Here

Examples of weasel.compiler.WeaselToken

public class WeaselKeyWordCompilerBreak extends WeaselKeyWordCompiler {

  @Override
  public WeaselCompilerReturn compile(WeaselToken token, WeaselCompiler compiler, WeaselKeyWordCompilerHelper compilerHelpher, ListIterator<WeaselToken> iterator) throws WeaselCompilerException {
    WeaselToken t = iterator.next();
    int s = 1;
    if(t.tokenType==WeaselTokenType.INTEGER){
      s = (Integer)t.param;
      if(s<=0)
        throw new WeaselCompilerException(t.line, "Negatives and 0 are not permitted");
View Full Code Here

Examples of weasel.compiler.WeaselToken

        instructions.add(0, new WeaselInstructionInvoke(method.getParentClass().getSuperClass().getRealName()+".<preInit>()"));
      }
    }else if(method.getName().equals("<init>")){
      boolean auto = true;
      if(iterator.hasNext()){
        WeaselToken token = iterator.next();
        if(token!=null && token.tokenType==WeaselTokenType.KEYWORD){
          if(iterator.next().tokenType==WeaselTokenType.OPENBRACKET){
            try{
              if(token.param==WeaselKeyWord.THIS){
                superCaller = false;
                auto = false;
                WeaselTree tree = WeaselTree.parse(iterator, WeaselTokenType.CLOSEBRACKET);
                List<WeaselGenericMethod2> methods = classCompiler.genericClass.getGenericMethodsOfThis("<init>", true);
                WeaselParameterCompileReturn wpcr = WeaselTree.compileParamList(token.line, "<init>", compiler, this, tree, methods);
                instructions.addAll(wpcr.instructions);
                instructions.add(token.line, new WeaselInstructionInvoke(wpcr.method.getMethod().getMethod().getClassNameAndDesk()));
                token = iterator.next();
                if(token.tokenType!=WeaselTokenType.SEMICOLON)
                  throw new WeaselCompilerException(token.line, "Expect ; but got %s", token);
              }else if(token.param==WeaselKeyWord.SUPER){
                superCaller = true;
                auto = false;
                WeaselTree tree = WeaselTree.parse(iterator, WeaselTokenType.CLOSEBRACKET);
                List<WeaselGenericMethod2> methods = classCompiler.genericClass.getGenericSuperClass().getGenericMethodsOfThis("<init>", true);
                WeaselParameterCompileReturn wpcr = WeaselTree.compileParamList(token.line, "<init>", compiler, this, tree, methods);
                instructions.addAll(wpcr.instructions);
                instructions.add(token.line, new WeaselInstructionInvoke(wpcr.method.getMethod().getMethod().getClassNameAndDesk()));
                token = iterator.next();
                if(token.tokenType!=WeaselTokenType.SEMICOLON)
                  throw new WeaselCompilerException(token.line, "Expect ; but got %s", token);
              }else{
                iterator.previous();
                iterator.previous();
              }
            }catch(WeaselCompilerException e){
              compiler.addWeaselCompilerMessage(new WeaselCompilerMessage(MessageType.ERROR, e.getLine(), parentClass.getFileName(), e.getMessage()));
              iterator.previous();
              token = iterator.next();
              while(token.tokenType!=WeaselTokenType.SEMICOLON && iterator.hasNext()){
                token = iterator.next();
              }
            }
          }else{
            iterator.previous();
            iterator.previous();
          }
        }else{
          iterator.previous();
        }
      }
      if(auto){
        superCaller = true;
        if(classCompiler.genericClass.getGenericSuperClass()!=null){
          WeaselGenericMethod2 method = classCompiler.genericClass.getGenericSuperClass().getGenericMethodOfThis("<init>()", new WeaselGenericClass[0]);
          if(method==null){
            compiler.addWeaselCompilerMessage(
                new WeaselCompilerMessage(MessageType.ERROR, 0, parentClass.getFileName(),
                    String.format("No default constructor in %s found", classCompiler.genericClass.getGenericSuperClass())));
          }else{
            instructions.add(0, new WeaselInstructionInvoke(method.getMethod().getMethod().getClassNameAndDesk()));
          }
        }
      }
    }
    while(iterator.hasNext()){
      try{
        instructions.addAll(WeaselTree.parseAndCompile(compiler, this, iterator));
      }catch(WeaselCompilerException e){
        compiler.addWeaselCompilerMessage(new WeaselCompilerMessage(MessageType.ERROR, e.getLine(), parentClass.getFileName(), e.getMessage()));
        iterator.previous();
        WeaselToken token = iterator.next();
        while(token.tokenType!=WeaselTokenType.SEMICOLON && iterator.hasNext()){
          token = iterator.next();
        }
      }
    }
View Full Code Here

Examples of weasel.compiler.WeaselToken

public class WeaselKeyWordCompilerContinue extends WeaselKeyWordCompiler {

  @Override
  public WeaselCompilerReturn compile(WeaselToken token, WeaselCompiler compiler, WeaselKeyWordCompilerHelper compilerHelpher, ListIterator<WeaselToken> iterator) throws WeaselCompilerException {
    WeaselToken t = iterator.next();
    int s = 1;
    if(t.tokenType==WeaselTokenType.INTEGER){
      s = (Integer)t.param;
      if(s<=0)
        throw new WeaselCompilerException(t.line, "Negatives and 0 are not permitted");
View Full Code Here

Examples of weasel.compiler.WeaselToken

    compilerHelpher.openBlock(true);
    WeaselTree tree1 = WeaselTree.parse(iterator, WeaselTokenType.CLOSEBRACKET);
    if(tree1==null){
      throw new WeaselCompilerException(token.line, "Expect boolean value in while");
    }
    WeaselToken t = iterator.next();
    WeaselCompilerReturn wcr;
    WeaselInstructionList instructions = new WeaselInstructionList();
    WeaselInstruction continueJump = new WeaselInstructionJumperDummy();
    instructions.add(token.line, continueJump);
    wcr = tree1.compile(compiler, compilerHelpher, null, new WeaselGenericClass(compiler.baseTypes.booleanClass), null, false);
View Full Code Here

Examples of weasel.compiler.WeaselToken

public class WeaselKeyWordCompilerDo extends WeaselKeyWordCompiler {

  @Override
  public WeaselCompilerReturn compile(WeaselToken token, WeaselCompiler compiler, WeaselKeyWordCompilerHelper compilerHelpher, ListIterator<WeaselToken> iterator) throws WeaselCompilerException {
    compilerHelpher.openBlock(true);
    WeaselToken t = iterator.next();
    WeaselInstructionList instructions = new WeaselInstructionList();
    WeaselInstructionJumperDummy startJump = new WeaselInstructionJumperDummy();
    instructions.add(token.line, startJump);
    if(t.tokenType==WeaselTokenType.OPENBLOCK){
      t = iterator.next();
View Full Code Here

Examples of weasel.compiler.WeaselToken

    WeaselInstructionList instructions = wcr.getInstructions();
    WeaselTree.autoCast(compiler, wcr.getReturnType(), new WeaselGenericClass(compiler.baseTypes.booleanClass), token.line, instructions, true);
    WeaselInstructionJump j1;
    instructions.add(token.line, j1 = new WeaselInstructionIf());
    instructions.addAll(compileBlock(compiler, compilerHelpher, iterator));
    WeaselToken t = iterator.next();
    if(t.tokenType==WeaselTokenType.KEYWORD && t.param == WeaselKeyWord.ELSE){
      WeaselInstructionJump j2;
      instructions.add(t.line, j2 = new WeaselInstructionJump());
      j1.setTarget(j2);
      instructions.addAll(compileBlock(compiler, compilerHelpher, iterator));
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.