public _parseForward()

in src/parser/scssParser.ts [852:918]


	public _parseForward(): nodes.Node | null {
		if (!this.peekKeyword('@forward')) {
			return null;
		}

		const node = <nodes.Forward>this.create(nodes.Forward);
		this.consumeToken();

		if (!node.addChild(this._parseStringLiteral())) {
			return this.finish(node, ParseError.StringLiteralExpected);
		}

		if (this.acceptIdent('with')) {
			if (!this.accept(TokenType.ParenthesisL)) {
				return this.finish(node, ParseError.LeftParenthesisExpected, [TokenType.ParenthesisR]);
			}

			// First variable statement, no comma.
			if (!node.getParameters().addChild(this._parseModuleConfigDeclaration())) {
				return this.finish(node, ParseError.VariableNameExpected);
			}

			while (this.accept(TokenType.Comma)) {
				if (this.peek(TokenType.ParenthesisR)) {
					break;
				}
				if (!node.getParameters().addChild(this._parseModuleConfigDeclaration())) {
					return this.finish(node, ParseError.VariableNameExpected);
				}
			}

			if (!this.accept(TokenType.ParenthesisR)) {
				return this.finish(node, ParseError.RightParenthesisExpected);
			}

		}

		if (!this.peek(TokenType.SemiColon) && !this.peek(TokenType.EOF)) {
			if (!this.peekRegExp(TokenType.Ident, /as|hide|show/)) {
				return this.finish(node, ParseError.UnknownKeyword);
			}

			if (this.acceptIdent('as')) {
				const identifier = this._parseIdent([nodes.ReferenceType.Forward]);
				if (!node.setIdentifier(identifier)) {
					return this.finish(node, ParseError.IdentifierExpected);
				}

				// Wildcard must be the next character after the identifier string.
				if (this.hasWhitespace() || !this.acceptDelim('*')) {
					return this.finish(node, ParseError.WildcardExpected);
				}
			}

			if (this.peekIdent('hide') || this.peekIdent('show')) {
				if (!node.addChild(this._parseForwardVisibility())) {
					return this.finish(node, ParseError.IdentifierOrVariableExpected);
				}
			}
		}

		if (!this.accept(TokenType.SemiColon) && !this.accept(TokenType.EOF)) {
			return this.finish(node, ParseError.SemiColonExpected);
		}

		return this.finish(node);
	}