Package weasel.compiler

Examples of weasel.compiler.WeaselCompilerException


      instructions = new WeaselInstructionList();
      instructions.add(token.line, new WeaselInstructionReturnNull(compilerHelpher.getVarCount()));
    }else{
      WeaselTree tree = WeaselTree.parse(iterator, WeaselTokenType.SEMICOLON);
      if(tree==null){
        throw new WeaselCompilerException(token.line, "return need to return %s", retClass);
      }
      WeaselCompilerReturn wcr = tree.compile(compiler, compilerHelpher, null, retClass, null, false);
      instructions = wcr.getInstructions();
      WeaselTree.autoCast(compiler, wcr.getReturnType(), retClass, token.line, instructions, true);
      instructions.add(token.line, new WeaselInstructionReturn(compilerHelpher.getVarCount()));
View Full Code Here


                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){
View Full Code Here

    for(int i=0; i<tokenTypes.length; i++){
      if(token.tokenType == tokenTypes[i]){
        return;
      }
    }
    throw new WeaselCompilerException(token.line, "Unexpected token %s expected %s", token, Arrays.toString(tokenTypes));
  }
View Full Code Here

    throw new WeaselCompilerException(token.line, "Unexpected token %s expected %s", token, Arrays.toString(tokenTypes));
  }
 
  protected void expectFirst(WeaselToken token, boolean isFirst) throws WeaselCompilerException{
    if(!isFirst){
      throw new WeaselCompilerException(token.line, "Token %s has to be first", token);
    }
  }
View Full Code Here

    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");
      t = iterator.next();
    }
    WeaselInstructionList instructionList = new WeaselInstructionList();
    compilerHelpher.addClosingsAndFrees(s, instructionList, false);
    WeaselInstructionJump continueJump;
View Full Code Here

  public WeaselCompilerReturn compile(WeaselToken token, WeaselCompiler compiler, WeaselKeyWordCompilerHelper compilerHelpher, ListIterator<WeaselToken> iterator) throws WeaselCompilerException {
    expect(iterator.next(), WeaselTokenType.OPENBRACKET);
    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();
View Full Code Here

      iterator.previous();
      instructions.addAll(WeaselTree.parseAndCompile(compiler, compilerHelpher, iterator));
    }
    t = iterator.next();
    if(t.tokenType!=WeaselTokenType.KEYWORD || t.param!=WeaselKeyWord.WHILE){
      throw new WeaselCompilerException(t.line, "expect while but got %s", t);
    }
    WeaselInstruction continueJump = instructions.getLast();
    expect(t = iterator.next(), WeaselTokenType.OPENBRACKET);
    WeaselTree tree1 = WeaselTree.parse(iterator, WeaselTokenType.CLOSEBRACKET);
    if(tree1==null){
      throw new WeaselCompilerException(t.line, "Expect boolean value in while");
    }
    WeaselCompilerReturn wcr;
    wcr = tree1.compile(compiler, compilerHelpher, null, new WeaselGenericClass(compiler.baseTypes.booleanClass), null, false);
    instructions.addAll(wcr.getInstructions());
    WeaselTree.autoCast(compiler, wcr.getReturnType(), new WeaselGenericClass(compiler.baseTypes.booleanClass), t.line, instructions, true);
View Full Code Here

public class WeaselKeyWordCompilerError extends WeaselKeyWordCompiler {

  @Override
  public WeaselCompilerReturn compile(WeaselToken token, WeaselCompiler compiler, WeaselKeyWordCompilerHelper compilerHelpher, ListIterator<WeaselToken> iterator) throws WeaselCompilerException {
    throw new WeaselCompilerException(token.line, "Unexpected Keyword %s", token);
  }
View Full Code Here

  @Override
  public WeaselCompilerReturn compile(WeaselToken token, WeaselCompiler compiler, WeaselKeyWordCompilerHelper compilerHelpher, ListIterator<WeaselToken> iterator) throws WeaselCompilerException {
    expect(iterator.next(), WeaselTokenType.OPENBRACKET);
    WeaselTree tree = WeaselTree.parse(iterator, WeaselTokenType.CLOSEBRACKET);
    if(tree==null)
      throw new WeaselCompilerException(token.line, "Condition need to be a boolean value");
    WeaselCompilerReturn wcr = tree.compile(compiler, compilerHelpher, null, new WeaselGenericClass(compiler.baseTypes.booleanClass), null, false);
    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());
View Full Code Here

      }
    }
    try{
      return interpreter.getWeaselClass(className);
    }catch(WeaselNativeException e){
      throw new WeaselCompilerException(line, e.getMessage());
    }
  }
View Full Code Here

TOP

Related Classes of weasel.compiler.WeaselCompilerException

Copyright © 2018 www.massapicom. 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.