anchor.diff:  prog:   stat+ ;
   
   stat:   expr NEWLINE {System.out.println($expr.value);}
  -    |   LPAREN STRING LPAREN expr RPAREN RPAREN NEWLINE {System.out.println($STRING.text + ' ' + $expr.value);}
       |   NEWLINE
       ;
   
  
positive.code:     |   LPAREN SIN {System.err.println("sin only takes 1 argument");}
          ( var )+
          RPAREN
      |   LPAREN SQRT {$value = 0;}
          ( m=expr {$value = Math.sqrt($m.value);})
          RPAREN
  
negative.code:             String removedCommas = ($NUMBER.text).replace(",", "");
              $value = Double.parseDouble(removedCommas);
          }
      |   SINGLEVAR
          {
          Double v = (Double)memory.get($SINGLEVAR.text);
          if ( v!=null ) $value = v.doubleValue();
          else System.err.println("undefined variable "+$SINGLEVAR.text);
          }
      ;
  
  letsinglevar 
      :   LET SINGLEVAR BE h = expr{
          memory.put($SINGLEVAR.text, new Double($h.value));
          }
              
      ;
  
  STRING
      :   '"' (~[\r\n"] | '""')* '"'
      ;
  
  
  LET: 'let';
  IN: 'in';
  BE: 'be';
  SIN: 'sin';
  COS: 'cos';
  SQRT: 'sqrt';
  SINGLEVAR: ('a'..'z'|'A'..'Z');
  ID  :   ('a'..'z'|'A'..'Z')+ ;
  NUMBER :  ('0'..'9'|',')+ ('.' ('0'..'9')+)?;
  NEWLINE:'\r'? '\n' ;
  