protected void parseOperationsLR ( Symbol ops [ ] , TokenList tokens , Sequence sequence ) { if ( tokens . size == 0 ) return ; TokenList . Token token = tokens . first ; if ( token . getType ( ) != Type . VARIABLE ) throw new ParseError ( "The first token in an equation needs to be a variable and not " + token ) ; boolean hasLeft = false ; while ( token != null ) { if ( token . getType ( ) == Type . FUNCTION ) { throw new ParseError ( "Function encountered with no parentheses" ) ; } else if ( token . getType ( ) == Type . VARIABLE ) { if ( hasLeft ) { if ( isTargetOp ( token . previous , ops ) ) { token = createOp ( token . previous . previous , token . previous , token , tokens , sequence ) ; } } else { hasLeft = true ; } } else { if ( token . previous . getType ( ) == Type . SYMBOL ) { throw new ParseError ( "Two symbols next to each other. " + token . previous + " and " + token ) ; } } token = token . next ; } }
Parses operations where the input comes from variables to its left and right