/// <summary> /// Initializes a new instance of the <see cref="Parser"/> class. /// </summary> /// <param name="lexer">The lexer.</param> /// <param name="options">The options.</param> /// <exception cref="System.ArgumentNullException"></exception> public Parser(Lexer lexer, ParserOptions?options = null) { _lexer = lexer ?? throw new ArgumentNullException(nameof(lexer)); _tokensPreview = new LinkedList <Token>(); Messages = new List <LogMessage>(); Options = options ?? new ParserOptions(); CurrentParsingMode = lexer.Options.Mode; Blocks = new Stack <ScriptNode>(); // Initialize the iterator _tokenIt = lexer.GetEnumerator(); NextToken(); }
/// <summary> /// Initializes a new instance of the <see cref="Parser"/> class. /// </summary> /// <param name="lexer">The lexer.</param> /// <param name="options">The options.</param> /// <exception cref="System.ArgumentNullException"></exception> public Parser(Lexer lexer, ParserOptions?options = null) { _lexer = lexer ?? throw new ArgumentNullException(nameof(lexer)); _isLiquid = _lexer.Options.Mode == ScriptMode.Liquid; _tokensPreview = new List <Token>(4); Messages = new List <LogMessage>(); _trivias = new List <ScriptTrivia>(); Options = options ?? new ParserOptions(); CurrentParsingMode = lexer.Options.Mode; _isKeepTrivia = lexer.Options.KeepTrivia; _pendingStatements = new Queue <ScriptStatement>(2); Blocks = new Stack <ScriptNode>(); // Initialize the iterator _tokenIt = lexer.GetEnumerator(); NextToken(); }