/// <summary> /// Initializes a new instance of the Lexer class with the specified /// TextReader to lex. /// </summary> /// <param name="source">A TextReader to lex.</param> public Lexer(TextReader source) { // token queue tokens = new TokenList(); // read the file contents reader = new CharReader(source); }
/// <summary> /// Returns a parsed DPL instance. /// </summary> /// <param name="reader">The TextReader value to be parsed.</param> /// <returns>A parsed Program instance.</returns> private IExpr ParseExpr(TextReader reader) { IExpr result=null; Lexer lexer = new Lexer(reader); tokens = lexer.Lex(); if (tokens.Peek().Type == TokenTypes.EQUAL) { tokens.Extract(); // skip over the equal curToken = tokens.Extract(); // set up the first token MatchExprAndOr(out result); // start with lowest precedence and work up } if (curToken.Type != TokenTypes.EOF) throw new ParserException("End of expression expected." + " At column " + Convert.ToString(curToken.StartCol)); return result; }