Logo Search packages:      
Sourcecode: wims version File versions  Download package

ExpressionProgram edu::hws::jcm::data::Parser::parse ( String  str  )  [inline]

Parse the string str and create the corresponding expression. The expression must be numeric-valued, not logical. There can't be any extra characters in str after the expression. If a syntax error is found, a ParseError will be thrown.

str String to parse.
the expression defined by the string.

Definition at line 232 of file Parser.java.

References BOOLEANS, edu::hws::jcm::data::ParserContext::look(), options, parseExpression(), parseLogicalExpression(), edu::hws::jcm::data::ParserContext::prog, edu::hws::jcm::data::ExpressionProgram::sourceString, symbols, and edu::hws::jcm::data::ExpressionProgram::trim().

Referenced by edu::hws::jcm::awt::ExpressionInput::checkInput(), edu::hws::jcm::awt::VariableInput::convertInput(), EpsilonDelta::doLoadExample(), edu::hws::jcm::functions::ExpressionFunction::redefine(), and EpsilonDelta::setUpCanvas().

      ParserContext context = new ParserContext(str,options,symbols);
              // The ParserContext holds all the information relevant to the
              // parsing of str, including str itself and the ExpressionProgram
              // that is being generated.  See the ParserContext class for more info.
      if (str == null)
         throw new ParseError("Can't parse a null string.", context);
      if (context.look() == ParserContext.END_OF_STRING)
         throw new ParseError("Can't parse an empty string.", context);
      boolean isBool;
      if ( (options & BOOLEANS) != 0 )
         isBool = parseLogicalExpression(context);
         isBool = parseExpression(context);
      if (context.look() != ParserContext.END_OF_STRING)
         throw new ParseError("Extra data found after the end of a complete legal expression.",context);
      if (isBool)
         throw new ParseError("Found a logical-valued expression instead of a numeric expression.",context);
      context.prog.sourceString = str;
      return context.prog;

Generated by  Doxygen 1.6.0   Back to index