protected void parseNegOp ( TokenList tokens , Sequence sequence ) { if ( tokens . size == 0 ) return ; TokenList . Token token = tokens . first ; while ( token != null ) { TokenList . Token next = token . next ; escape : if ( token . getSymbol ( ) == Symbol . MINUS ) { if ( token . previous != null && token . previous . getType ( ) != Type . SYMBOL ) break escape ; if ( token . previous != null && token . previous . getType ( ) == Type . SYMBOL && ( token . previous . symbol == Symbol . TRANSPOSE ) ) break escape ; if ( token . next == null || token . next . getType ( ) == Type . SYMBOL ) break escape ; if ( token . next . getType ( ) != Type . VARIABLE ) throw new RuntimeException ( "Crap bug rethink this function" ) ; // create the operation Operation . Info info = Operation . neg ( token . next . getVariable ( ) , functions . getManagerTemp ( ) ) ; // add the operation to the sequence sequence . addOperation ( info . op ) ; // update the token list TokenList . Token t = new TokenList . Token ( info . output ) ; tokens . insert ( token . next , t ) ; tokens . remove ( token . next ) ; tokens . remove ( token ) ; next = t ; } token = next ; } }
Searches for cases where a minus sign means negative operator . That happens when there is a minus sign with a variable to its right and no variable to its left