Package de.maramuse.soundcomp.parser

Examples of de.maramuse.soundcomp.parser.Number


  @Override
  public ParserVal eliminateConst() {
  if(inner.size()==1){
    if(inner.get(0).isConstant())
    return new Number(Math.asin(inner.get(0).asDouble()));
    return this;
  }
  throw new IllegalArgumentException("arcus sine needs one argument "+getLocationText());
  }
View Full Code Here


  @Override
  public ParserVal eliminateConst() {
  if(inner.size()==1){
    if(inner.get(0).isConstant())
    return new Number(Math.round(inner.get(0).asDouble()));
    return this;
  }
  throw new IllegalArgumentException("int needs one argument "+getLocationText());
  }
View Full Code Here

  if(inner.size()!=2)
    throw new InternalError("\"*\" requires two arguments");
  if(inner.get(0).isConstant()&&inner.get(1).isConstant()){
    if(inner.get(0).getType()==SCParser.NUMBER&&inner.get(1).getType()==SCParser.NUMBER){
    try{
      ParserVal ret=new Number(inner.get(0).asDouble()*inner.get(1).asDouble());
      ret.setFilename(filename);
      ret.setLine(line);
      return ret;
    }catch(NumberFormatException ex){
      throw new IllegalArgumentException("should not happen: number format error", ex);
    }
    }
View Full Code Here

  @Override
  public ParserVal eliminateConst() {
  if(inner.size()==1){
    if(inner.get(0).isConstant())
    return new Number(Math.log(Double.parseDouble(inner.get(0).getText())));
    return this;
  }
  if(inner.size()==2){
    if(inner.get(0).isConstant()&&inner.get(1).isConstant())
    return new Number(Math.log(inner.get(0).asDouble())/Math.log(inner.get(1).asDouble()));
    return this;
  }
  throw new IllegalArgumentException("log needs one or two arguments "+getLocationText());
  }
View Full Code Here

  if(inner.size()!=2)
    throw new InternalError("\""+getText()+"^\" requires two arguments");
  if(inner.get(0).isConstant()&&inner.get(1).isConstant()){
    if(inner.get(0).getType()==SCParser.NUMBER&&inner.get(1).getType()==SCParser.NUMBER){
    try{
      ParserVal ret=new Number(Math.pow(inner.get(0).asDouble(),
        Math.log(inner.get(1).asDouble())));
      ret.setFilename(filename);
      ret.setLine(line);
      return ret;
    }catch(NumberFormatException ex){
      throw new IllegalArgumentException("should not happen: number format error", ex);
    }
    }
View Full Code Here

  @Override
  public ParserVal eliminateConst() {
  if(inner.size()==1){
    if(inner.get(0).isConstant())
    return new Number(Math.cos(inner.get(0).asDouble()));
    return this;
  }
  throw new IllegalArgumentException("cosine needs one argument "+getLocationText());
  }
View Full Code Here

  @Override
  public ParserVal eliminateConst() {
  if(inner.size()==1){
    if(inner.get(0).isConstant())
    return new Number(-Double.parseDouble(inner.get(0).getText()));
    // make unary minus a binary minus if not constant - makes evaluation simpler
    inner.add(inner.get(0));
    inner.set(0, new Number("0"));
    return this;
  }
  if(inner.size()<1||inner.size()>2)
    throw new InternalError("\"-\" requires at least one and at most two arguments");
  if(inner.get(0).isConstant()&&inner.get(1).isConstant()){
    if(inner.get(0).getType()==SCParser.NUMBER&&inner.get(1).getType()==SCParser.NUMBER){
    try{
      ParserVal ret=new Number(inner.get(0).asDouble()-inner.get(1).asDouble());
      ret.setFilename(filename);
      ret.setLine(line);
      return ret;
    }catch(NumberFormatException ex){
      throw new IllegalArgumentException("should not happen: number format error", ex);
    }
    }
View Full Code Here

  @Override
  public ParserVal eliminateConst() {
  if(inner.size()==1){
    if(inner.get(0).isConstant())
    return new Number(Math.log10(inner.get(0).asDouble()));
    return this;
  }
  throw new IllegalArgumentException("decadic logarithm needs one argument "+getLocationText());
  }
View Full Code Here

  @Override
  public ParserVal eliminateConst() {
  if(inner.size()==1){
    if(inner.get(0).isConstant())
    return new Number(Math.sinh(inner.get(0).asDouble()));
    return this;
  }
  throw new IllegalArgumentException("hyperbolic sine needs one argument "+getLocationText());
  }
View Full Code Here

  @Override
  public ParserVal eliminateConst() {
  if(inner.size()==1){
    if(inner.get(0).isConstant())
    return new Number(Math.rint(inner.get(0).asDouble()));
    return this;
  }
  throw new IllegalArgumentException("int needs one argument "+getLocationText());
  }
View Full Code Here

TOP

Related Classes of de.maramuse.soundcomp.parser.Number

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.