Esempio n. 1
0
        /// <summary>
        /// Returns a P# program.
        /// </summary>
        /// <param name="tokens">List of tokens</param>
        /// <returns>P# program</returns>
        public IPSharpProgram ParseTokens(List<Token> tokens)
        {
            this.OriginalTokens = tokens.ToList();
            this.TokenStream = new TokenStream(tokens);
            this.Program = this.CreateNewProgram();
            this.ExpectedTokenTypes = new List<TokenType>();

            try
            {
                this.ParseTokens();
            }
            catch (ParsingException ex)
            {
                this.ErrorLog = ex.Message;
                this.ReportParsingError();
                this.ExpectedTokenTypes = ex.ExpectedTokenTypes;
            }
            
            return this.Program;
        }
Esempio n. 2
0
        /// <summary>
        /// Returns a P# program.
        /// </summary>
        /// <param name="tokens">List of tokens</param>
        /// <returns>P# program</returns>
        public IPSharpProgram ParseTokens(List<Token> tokens)
        {
            this.OriginalTokens = tokens.ToList();
            this.TokenStream = new TokenStream(tokens);
            this.Program = this.CreateNewProgram();
            this.ExpectedTokenTypes = new List<TokenType>();

            try
            {
                this.ParseTokens();
            }
            catch (ParsingException ex)
            {
                this.ErrorLog.Append(ex.Message);
                this.ExpectedTokenTypes = ex.ExpectedTokenTypes;
                this.ReportParsingError();

                if (base.Options.ThrowParsingException &&
                    this.ErrorLog.Length > 0)
                {
                    throw new ParsingException(this.ErrorLog.ToString(), ex.ExpectedTokenTypes);
                }
            }

            return this.Program;
        }
Esempio n. 3
0
 internal TokenRange(TokenStream tokenStream) => this.TokenStream = tokenStream;