protected Expression functionCall ( ) { FunctionCall call = new FunctionCall ( ) ; Token funToken = tokenizer . consume ( ) ; Function fun = functionTable . get ( funToken . getContents ( ) ) ; if ( fun == null ) { errors . add ( ParseError . error ( funToken , String . format ( "Unknown function: '%s'" , funToken . getContents ( ) ) ) ) ; } call . setFunction ( fun ) ; tokenizer . consume ( ) ; while ( ! tokenizer . current ( ) . isSymbol ( ")" ) && tokenizer . current ( ) . isNotEnd ( ) ) { if ( ! call . getParameters ( ) . isEmpty ( ) ) { expect ( Token . TokenType . SYMBOL , "," ) ; } call . addParameter ( expression ( ) ) ; } expect ( Token . TokenType . SYMBOL , ")" ) ; if ( fun == null ) { return Constant . EMPTY ; } if ( call . getParameters ( ) . size ( ) != fun . getNumberOfArguments ( ) && fun . getNumberOfArguments ( ) >= 0 ) { errors . add ( ParseError . error ( funToken , String . format ( "Number of arguments for function '%s' do not match. Expected: %d, Found: %d" , funToken . getContents ( ) , fun . getNumberOfArguments ( ) , call . getParameters ( ) . size ( ) ) ) ) ; return Constant . EMPTY ; } return call ; }
Parses a function call .