{"size": 1086, "ext": "js", "max_stars_repo_path": "lib/syntax-extension/sass/SassNamespace.js", "max_stars_repo_name": "csstree/stylelint-css-validator", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lib/syntax-extension/sass/SassNamespace.js", "max_issues_repo_name": "csstree/stylelint-css-validator", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lib/syntax-extension/sass/SassNamespace.js", "max_forks_repo_name": "csstree/stylelint-css-validator", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.6086956522, "max_line_length": 65, "alphanum_fraction": 0.5902394107}
import { tokenTypes } from 'css-tree';

const FUNCTION = tokenTypes.Function;
const IDENT = tokenTypes.Ident;
const DOLLARSIGN = 0x0024; // U+0024 DOLLAR SIGN ($)
const FULLSTOP = 0x002E;   // U+002E FULL STOP (.)

function consumeRaw() {
    return this.createSingleNodeList(
        this.Raw(this.tokenIndex, null, false)
    );
}

export const name = 'SassNamespace';
export const structure = {
    name: 'Identifier',
    member: ['Function', 'Ident']
};
export function parse() {
    const start = this.tokenStart;
    const name = this.consume(IDENT);
    let member;

    this.eatDelim(FULLSTOP);

    switch (this.tokenType) {
        case FUNCTION:
            member = this.Function(consumeRaw, this.scope.Value);
            break;

        default:
            if (this.isDelim(DOLLARSIGN)) {
                member = this.SassVariable();
            } else {
                this.error('Function or ident expected');
            }
    }

    return {
        type: 'SassNamespace',
        loc: this.getLocation(start, this.tokenEnd),
        name,
        member
    };
}
