File: //proc/1526/task/1529/cwd/tana/frontend/node_modules/css-tree/lib/syntax/node/MediaFeature.js
var TYPE = require('../../tokenizer').TYPE;
var IDENTIFIER = TYPE.Identifier;
var NUMBER = TYPE.Number;
var LEFTPARENTHESIS = TYPE.LeftParenthesis;
var RIGHTPARENTHESIS = TYPE.RightParenthesis;
var COLON = TYPE.Colon;
var SOLIDUS = TYPE.Solidus;
module.exports = {
    name: 'MediaFeature',
    structure: {
        name: String,
        value: ['Identifier', 'Number', 'Dimension', 'Ratio', null]
    },
    parse: function() {
        var start = this.scanner.tokenStart;
        var name;
        var value = null;
        this.scanner.eat(LEFTPARENTHESIS);
        this.scanner.skipSC();
        name = this.scanner.consume(IDENTIFIER);
        this.scanner.skipSC();
        if (this.scanner.tokenType !== RIGHTPARENTHESIS) {
            this.scanner.eat(COLON);
            this.scanner.skipSC();
            switch (this.scanner.tokenType) {
                case NUMBER:
                    if (this.scanner.lookupType(1) === IDENTIFIER) {
                        value = this.Dimension();
                    } else if (this.scanner.lookupNonWSType(1) === SOLIDUS) {
                        value = this.Ratio();
                    } else {
                        value = this.Number();
                    }
                    break;
                case IDENTIFIER:
                    value = this.Identifier();
                    break;
                default:
                    this.scanner.error('Number, dimension, ratio or identifier is expected');
            }
            this.scanner.skipSC();
        }
        this.scanner.eat(RIGHTPARENTHESIS);
        return {
            type: 'MediaFeature',
            loc: this.getLocation(start, this.scanner.tokenStart),
            name: name,
            value: value
        };
    },
    generate: function(processChunk, node) {
        processChunk('(');
        processChunk(node.name);
        if (node.value !== null) {
            processChunk(':');
            this.generate(processChunk, node.value);
        }
        processChunk(')');
    }
};