text:
goog.provide('adapt.csstok');

goog.require('adapt.base');

/**
 * @interface
 */
adapt.csstok.TokenizerHandler = function() {};

/**
 * @param {string} mnemonics
 * @param {adapt.csstok.Token} token
 * @return {void}
 */
adapt.csstok.TokenizerHandler.prototype.error = function(mnemonics, token) {};

/**
 * @param {string} str
 * @return {string}
 */
adapt.csstok.escapeParseSingle = function(str) {
    str = str.substr(1);
    if (str.match(/^[^0-9a-fA-F\n\r]$/))
        return str;
    var code = parseInt(str, 16);
    if (isNaN(code))
        return "";
    if (code <= 0xFFFF)
        return String.fromCharCode(code);
    if (code <= 0x10FFFF) {
        // non-BMP characters: convert to a surrogate pair
        return String.fromCharCode(0xD800 | ((code >> 10) & 0x3FF), 0xDC00 | (code & 0x3FF));
    }
    // not a valid Unicode value
    return "\uFFFD";
};

/**
 * @param {string} str
 * @return {string}
 */
adapt.csstok.escapeParse = function(str) {
    return str.replace( /\\([0-9a-fA-F]{0,6}(\r\n|[ \n\r\t\f])?|[^0-9a-fA-F\n\r])/g,
    		adapt.csstok.escapeParseSingle );
};

/**
 * @enum {number}
 */
adapt.csstok.TokenType = {
    EOF: 0,
    IDENT: 1,
    STR: 2,
    NUMERIC: 3,
    NUM: 4,
    INT: 5,
    FUNC: 6,
    HASH: 7,
    URL: 8,
    CLASS: 9,
    O_PAR: 10,
    C_PAR: 11,
    O_BRC: 12,
    C_BRC: 13,
    O_BRK: 14,
    C_BRK: 15,
    COMMA: 16,
    SEMICOL: 17,
    COLON: 18,
    SLASH: 19,
    AT: 20,
    PERCENT: 21,
    QMARK: 22,
    PLUS: 23,
    MINUS: 24,
    BAR_BAR: 25,
    AMP_AMP: 26,
    // those can have "=" at the end
    BANG: 31,
    DOLLAR: 32,
    HAT: 33,
    BAR: 34,
    TILDE: 35,
    STAR: 36,
    GT: 37,
    LT: 38,
    EQ: 39,
    // tokens above plus "=" at the end, order must be the same
    BANG_EQ: 41,
    DOLLAR_EQ: 42,
    HAT_EQ: 43,
    BAR_EQ: 44,
    TILDE_EQ: 45,
    STAR_EQ: 46,
    GT_EQ: 47,
    LT_EQ: 48,
    EQ_EQ: 49,
    COL_COL: 50,
    INVALID: 51,
    LAST: 51
};

/**
 * @constructor
 */
adapt.csstok.Token = function() {
    /** @type {adapt.csstok.TokenType} */ this.type = adapt.csstok.TokenType.EOF;
    /** @type {boolean} */ this.precededBySpace = false;
    /** @type {number} */ this.num = 0;
    /** @type {string} */ this.text = "";
    /** @type {number} */ this.position = 0;
};

/**
 * @enum {number}
 */
adapt.csstok.Action = {
    SPACE: 1,
    INT: 2,
    IDENT: 3,
    BANG: 4,
    HASH: 6,
    DOLLAR: 7,
    PERCENT: 8,
    AMP: 9,
    O_PAR: 10,
    C_PAR: 11,
    STAR: 12,
    PLUS: 13,
    COMMA: 14,
    MINUS: 15,
    DOT: 16,
    SLASH: 17,
    COLON: 18,
    SEMICOL: 19,
    LT: 20,
    EQ: 21,
    GT: 22,
    QMARK: 23,
    AT: 24,
    O_BRK: 25,
    C_BRK: 26,
    O_BRC: 27,
    C_BRC: 28,
    BSLASH: 29,
    HAT: 30,
    BAR: 31,
    TILDE: 32,
    STR1: 33,
    STR2: 34,
    END: 35,
    EQTAIL: 36,
    ENDINT: 37,
    ENDNUM: 38,
    CONT: 39,
    UNIT: 40,
    PCUNIT: 41,
    NUMBER: 42,
    ENDIDNT: 43,
    IDNTESC: 44,
    ENDIDES: 45, // end of identifier with escapes
    ENDSTR: 46,
    ENDESTR: 47, // end of string with escapes
    STR1ESC: 48,
    STR2ESC: 49,
    BAR_BAR: 50,
    AMP_AMP: 51,
    FUNC: 52,
    FUNCES: 53,
    COMMENT: 54,
    COMMST: 55,
    ENDNOTK: 56,
    MINMIN: 57,
    TOINT: 58,
    TONUM: 59,
    TOIDENT: 60,
    TOIDES: 61,
    KILL1: 62,
    KILL2: 63,
    URL: 64,
    URL1: 65,
    URL2: 66,
    ENDURL: 67,
    TERMURL: 68,
    FINURL: 69,
    LT_BG: 70,
    LT_BG_M: 71,
    INVALID: 72,
    CHKPOSS: 73,
    CHKPOSN: 74,
    URLESC: 75,
    IDESCH: 76,
    COL_COL: 77,
    TOCLASS: 78,
    CHKSP: 79,
    EOF: 80
};

/**
 * @param {adapt.csstok.Action} def
 * @param {Array.<adapt.csstok.Action>} spec
 * @return {Array.<adapt.csstok.Action>}
 */
adapt.csstok.makeActions = function(def, spec) {
    /** @type {Array.<number>} */ var a = Array(128);
    /** @type {number} */ var i;
    for (i = 0 ; i < 128 ; i++) {
        a[i] = def;
    }
    a[NaN] = def == adapt.csstok.Action.END ?
    		adapt.csstok.Action.END : adapt.csstok.Action.INVALID;
    for (i = 0 ; i < spec.length ; i += 2) {
        a[spec[i]] = spec[i + 1];
    }
    return a;
};

/**
 * Start of the token.
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsNormal = [
    adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, // 0x00-0x07
    adapt.csstok.Action.INVALID, adapt.csstok.Action.SPACE,   adapt.csstok.Action.SPACE,   adapt.csstok.Action.INVALID, adapt.csstok.Action.SPACE,   adapt.csstok.Action.SPACE,   adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, // 0x08-0x0F
    adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, // 0x10-0x17
    adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, // 0x18-0x1F
    adapt.csstok.Action.SPACE,   adapt.csstok.Action.BANG,    adapt.csstok.Action.STR2,    adapt.csstok.Action.HASH,    adapt.csstok.Action.DOLLAR,  adapt.csstok.Action.PERCENT, adapt.csstok.Action.AMP,     adapt.csstok.Action.STR1,    // 0x20-0x27
    adapt.csstok.Action.O_PAR,   adapt.csstok.Action.C_PAR,   adapt.csstok.Action.STAR,    adapt.csstok.Action.PLUS,    adapt.csstok.Action.COMMA,   adapt.csstok.Action.MINUS,   adapt.csstok.Action.DOT,     adapt.csstok.Action.SLASH,   // 0x28-0x2F
    adapt.csstok.Action.INT,     adapt.csstok.Action.INT,     adapt.csstok.Action.INT,     adapt.csstok.Action.INT,     adapt.csstok.Action.INT,     adapt.csstok.Action.INT,     adapt.csstok.Action.INT,     adapt.csstok.Action.INT,     // 0x30-0x37
    adapt.csstok.Action.INT,     adapt.csstok.Action.INT,     adapt.csstok.Action.COLON,   adapt.csstok.Action.SEMICOL, adapt.csstok.Action.LT,      adapt.csstok.Action.EQ,      adapt.csstok.Action.GT,      adapt.csstok.Action.QMARK,   // 0x38-0x3F
    adapt.csstok.Action.AT,      adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   // 0x40-0x47
    adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   // 0x48-0x4F
    adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   // 0x50-0x57
    adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.O_BRK,   adapt.csstok.Action.BSLASH,  adapt.csstok.Action.C_BRK,   adapt.csstok.Action.HAT,     adapt.csstok.Action.IDENT,   // 0x58-0x5F
    adapt.csstok.Action.INVALID, adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   // 0x60-0x67
    adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   // 0x68-0x6F
    adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   // 0x70-0x77
    adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.IDENT,   adapt.csstok.Action.O_BRC,   adapt.csstok.Action.BAR,     adapt.csstok.Action.C_BRC,   adapt.csstok.Action.TILDE,   adapt.csstok.Action.INVALID  // 0x78-0x7F
];
adapt.csstok.actionsNormal[NaN] = adapt.csstok.Action.EOF;

/**
 * Inside identifier.
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsIdent = [
    adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, // 0x00-0x07
    adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, // 0x08-0x0F
    adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, // 0x10-0x17
    adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, // 0x18-0x1F
    adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, // 0x20-0x27
    adapt.csstok.Action.FUNC,    adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.CONT,    adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, // 0x28-0x2F
    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    // 0x30-0x37
    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, // 0x38-0x3F
    adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    // 0x40-0x47
    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    // 0x48-0x4F
    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    // 0x50-0x57
    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.IDNTESC, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.CONT,    // 0x58-0x5F
    adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    // 0x60-0x67
    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    // 0x68-0x6F
    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    // 0x70-0x77
    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT, adapt.csstok.Action.ENDIDNT  // 0x78-0x7F
];
adapt.csstok.actionsIdent[NaN] = adapt.csstok.Action.ENDIDNT;

/**
 * After dot (either .class or .123)
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsNumOrClass = [
    adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, // 0x00-0x07
    adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, // 0x08-0x0F
    adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, // 0x10-0x17
    adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, // 0x18-0x1F
    adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, // 0x20-0x27
    adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TONUM,   adapt.csstok.Action.INVALID, // 0x28-0x2F
    adapt.csstok.Action.TONUM,   adapt.csstok.Action.TONUM,   adapt.csstok.Action.TONUM,   adapt.csstok.Action.TONUM,   adapt.csstok.Action.TONUM,   adapt.csstok.Action.TONUM,   adapt.csstok.Action.TONUM,   adapt.csstok.Action.TONUM,   // 0x30-0x37
    adapt.csstok.Action.TONUM,   adapt.csstok.Action.TONUM,   adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, // 0x38-0x3F
    adapt.csstok.Action.INVALID, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, // 0x40-0x47
    adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, // 0x48-0x4F
    adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, // 0x50-0x57
    adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.INVALID, adapt.csstok.Action.TOIDES,  adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.TOCLASS, // 0x58-0x5F
    adapt.csstok.Action.INVALID, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, // 0x60-0x67
    adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, // 0x68-0x6F
    adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, // 0x70-0x77
    adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.TOCLASS, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID, adapt.csstok.Action.INVALID  // 0x78-0x7F
];
adapt.csstok.actionsIdent[NaN] = adapt.csstok.Action.ENDIDNT;

/**
 * after '-'
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsMinus = [
    adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     // 0x00-0x07
    adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     // 0x08-0x0F
    adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     // 0x10-0x17
    adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     // 0x18-0x1F
    adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     // 0x20-0x27
    adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.MINMIN,  adapt.csstok.Action.TONUM,   adapt.csstok.Action.END,     // 0x28-0x2F
    adapt.csstok.Action.TOINT,   adapt.csstok.Action.TOINT,   adapt.csstok.Action.TOINT,   adapt.csstok.Action.TOINT,   adapt.csstok.Action.TOINT,   adapt.csstok.Action.TOINT,   adapt.csstok.Action.TOINT,   adapt.csstok.Action.TOINT,   // 0x30-0x37
    adapt.csstok.Action.TOINT,   adapt.csstok.Action.TOINT,   adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     // 0x38-0x3F
    adapt.csstok.Action.END,     adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, // 0x40-0x47
    adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, // 0x48-0x4F
    adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, // 0x50-0x57
    adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.END,     adapt.csstok.Action.TOIDES,  adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.TOIDENT, // 0x58-0x5F
    adapt.csstok.Action.END,     adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, // 0x60-0x67
    adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, // 0x68-0x6F
    adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, // 0x70-0x77
    adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.TOIDENT, adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END,     adapt.csstok.Action.END      // 0x78-0x7F
];
adapt.csstok.actionsMinus[NaN] = adapt.csstok.Action.END;

/**
 * Inside identifier with escape sequence
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsIdentEsc = [
    adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, // 0x00-0x07
    adapt.csstok.Action.ENDIDES, adapt.csstok.Action.CHKPOSS, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, // 0x08-0x0F
    adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, // 0x10-0x17
    adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, // 0x18-0x1F
    adapt.csstok.Action.CHKPOSS, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, // 0x20-0x27
    adapt.csstok.Action.FUNCES,  adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, // 0x28-0x2F
    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    // 0x30-0x37
    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, // 0x38-0x3F
    adapt.csstok.Action.ENDIDES, adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    // 0x40-0x47
    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    // 0x48-0x4F
    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    // 0x50-0x57
    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.ENDIDES, adapt.csstok.Action.IDNTESC, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.CONT,    // 0x58-0x5F
    adapt.csstok.Action.ENDIDES, adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    // 0x60-0x67
    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    // 0x68-0x6F
    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    // 0x70-0x77
    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES, adapt.csstok.Action.ENDIDES  // 0x78-0x7F
];
adapt.csstok.actionsIdentEsc[NaN] = adapt.csstok.Action.ENDIDES;

/**
 * Inside integer
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsInt = [
    adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  // 0x00-0x07
    adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  // 0x08-0x0F
    adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  // 0x10-0x17
    adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  // 0x18-0x1F
    adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.PCUNIT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  // 0x20-0x27
    adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.NUMBER,  adapt.csstok.Action.ENDINT,  // 0x28-0x2F
    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    // 0x30-0x37
    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  // 0x38-0x3F
    adapt.csstok.Action.ENDINT,  adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    // 0x40-0x47
    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    // 0x48-0x4F
    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    // 0x50-0x57
    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.UNIT,    // 0x58-0x5F
    adapt.csstok.Action.ENDINT,  adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    // 0x60-0x67
    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    // 0x68-0x6F
    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    // 0x70-0x77
    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT,  adapt.csstok.Action.ENDINT   // 0x78-0x7F
];
adapt.csstok.actionsInt[NaN] = adapt.csstok.Action.ENDINT;

/**
 * inside real, after dot
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsNumber = [
    adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  // 0x00-0x07
    adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  // 0x08-0x0F
    adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  // 0x10-0x17
    adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  // 0x18-0x1F
    adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.PCUNIT,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  // 0x20-0x27
    adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  // 0x28-0x2F
    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    // 0x30-0x37
    adapt.csstok.Action.CONT,    adapt.csstok.Action.CONT,    adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  // 0x38-0x3F
    adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    // 0x40-0x47
    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    // 0x48-0x4F
    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    // 0x50-0x57
    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.UNIT,    // 0x58-0x5F
    adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    // 0x60-0x67
    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    // 0x68-0x6F
    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    // 0x70-0x77
    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.UNIT,    adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM,  adapt.csstok.Action.ENDNUM   // 0x78-0x7F
];
adapt.csstok.actionsNumber[NaN] = adapt.csstok.Action.ENDNUM;

/**
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsCheckEq = adapt.csstok.makeActions( adapt.csstok.Action.END, [61/*=*/, adapt.csstok.Action.EQTAIL]);

/**
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsColon = adapt.csstok.makeActions( adapt.csstok.Action.END, [58/*:*/, adapt.csstok.Action.COL_COL]);

/**
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsBar = adapt.csstok.makeActions( adapt.csstok.Action.END, [61/*=*/, adapt.csstok.Action.EQTAIL, 124 /*|*/, adapt.csstok.Action.BAR_BAR]);

/**
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsAmp = adapt.csstok.makeActions( adapt.csstok.Action.END, [38 /*&*/, adapt.csstok.Action.AMP_AMP]);

/**
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsSlash = adapt.csstok.makeActions( adapt.csstok.Action.END, [42/* * */, adapt.csstok.Action.COMMENT]);

/**
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsComment = adapt.csstok.makeActions(adapt.csstok.Action.CONT, [42 /* * */, adapt.csstok.Action.COMMST]);

/**
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsCommentStar = adapt.csstok.makeActions(adapt.csstok.Action.COMMENT, [42 /* * */, adapt.csstok.Action.COMMST, 47 /* / */, adapt.csstok.Action.ENDNOTK]);

/**
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsMinusMinus = adapt.csstok.makeActions(adapt.csstok.Action.KILL1, [62 /* > */, adapt.csstok.Action.ENDNOTK]);

/**
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsLt = adapt.csstok.makeActions( adapt.csstok.Action.END, [61/*=*/, adapt.csstok.Action.EQTAIL, 33 /*!*/, adapt.csstok.Action.LT_BG]);

/**
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsLtBang = adapt.csstok.makeActions( adapt.csstok.Action.KILL1, [45 /*-*/, adapt.csstok.Action.LT_BG_M]);

/**
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsLtBangMinus = adapt.csstok.makeActions( adapt.csstok.Action.KILL2, [45 /*-*/, adapt.csstok.Action.ENDNOTK]);

/**
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsIdentEscChr = adapt.csstok.makeActions( adapt.csstok.Action.IDESCH, [9/*tab*/, adapt.csstok.Action.INVALID, 10/*LF*/, adapt.csstok.Action.INVALID, 13/*CR*/, adapt.csstok.Action.INVALID, 32/*sp*/, adapt.csstok.Action.INVALID] );

/**
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsStr1 = adapt.csstok.makeActions( adapt.csstok.Action.CONT, [39/*'*/, adapt.csstok.Action.ENDSTR, 10/*LF*/, adapt.csstok.Action.INVALID, 13/*CR*/, adapt.csstok.Action.INVALID, 92/*\*/, adapt.csstok.Action.STR1ESC]);

/**
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsStr2 = adapt.csstok.makeActions( adapt.csstok.Action.CONT, [34/*"*/, adapt.csstok.Action.ENDSTR, 10/*LF*/, adapt.csstok.Action.INVALID, 13/*CR*/, adapt.csstok.Action.INVALID, 92/*\*/, adapt.csstok.Action.STR2ESC]);

/**
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsStr1Esc = adapt.csstok.makeActions( adapt.csstok.Action.CONT, [39/*'*/, adapt.csstok.Action.ENDESTR, 10/*LF*/, adapt.csstok.Action.CHKPOSN, 13/*CR*/, adapt.csstok.Action.CHKPOSN, 92/*\*/, adapt.csstok.Action.STR1ESC]);

/**
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsStr2Esc = adapt.csstok.makeActions( adapt.csstok.Action.CONT, [34/*"*/, adapt.csstok.Action.ENDESTR, 10/*LF*/, adapt.csstok.Action.CHKPOSN, 13/*CR*/, adapt.csstok.Action.CHKPOSN, 92/*\*/, adapt.csstok.Action.STR2ESC]);

/**
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsURL = adapt.csstok.makeActions(adapt.csstok.Action.URL, [9/*tab*/, adapt.csstok.Action.CONT, 32/*sp*/, adapt.csstok.Action.CONT, 34/*"*/, adapt.csstok.Action.URL2, 39/*'*/, adapt.csstok.Action.URL1, 41/*)*/, adapt.csstok.Action.INVALID, 10/*LF*/, adapt.csstok.Action.CONT, 13/*CR*/, adapt.csstok.Action.CONT]);

/**
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsURLInside = adapt.csstok.makeActions(adapt.csstok.Action.CONT, [41/*)*/, adapt.csstok.Action.ENDURL, 9/*TAB*/, adapt.csstok.Action.CHKSP, 10/*LF*/, adapt.csstok.Action.CHKSP, 13/*CR*/, adapt.csstok.Action.CHKSP, 32/*sp*/, adapt.csstok.Action.CHKSP, 92/*\*/, adapt.csstok.Action.URLESC,
                                                                                40/*(*/, adapt.csstok.Action.INVALID, 91/*[*/, adapt.csstok.Action.INVALID,  93/*]*/, adapt.csstok.Action.INVALID, 123/*{*/, adapt.csstok.Action.INVALID, 125/*}*/, adapt.csstok.Action.INVALID,
                                                                                NaN, adapt.csstok.Action.ENDURL]);

/**
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsURLInside1 = adapt.csstok.makeActions(adapt.csstok.Action.CONT, [39/*'*/, adapt.csstok.Action.TERMURL, 10/*LF*/, adapt.csstok.Action.CHKPOSN, 13/*CR*/, adapt.csstok.Action.CHKPOSN, 92/*\*/, adapt.csstok.Action.URLESC, NaN, adapt.csstok.Action.ENDURL]);

/**
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsURLInside2 = adapt.csstok.makeActions(adapt.csstok.Action.CONT, [34/*"*/, adapt.csstok.Action.TERMURL, 10/*LF*/, adapt.csstok.Action.CHKPOSN, 13/*CR*/, adapt.csstok.Action.CHKPOSN, 92/*\*/, adapt.csstok.Action.URLESC, NaN, adapt.csstok.Action.ENDURL]);

/**
 * @type {Array.<adapt.csstok.Action>}
 * @const
 */
adapt.csstok.actionsURLTail = adapt.csstok.makeActions(adapt.csstok.Action.INVALID, [9/*tab*/, adapt.csstok.Action.CONT, 10/*LF*/, adapt.csstok.Action.CONT, 13/*CR*/, adapt.csstok.Action.CONT, 32/*sp*/, adapt.csstok.Action.CONT, 41/*)*/, adapt.csstok.Action.FINURL]);

/**
 * @const
 */
adapt.csstok.INITIAL_INDEX_MASK = 0xF;

/**
 * @constructor
 * @param {string} input
 * @param {adapt.csstok.TokenizerHandler} handler
 */
adapt.csstok.Tokenizer = function(input, handler) {
	/** @const */ this.handler = handler;
    /** @type {number} */ this.indexMask = adapt.csstok.INITIAL_INDEX_MASK;
	/** @type {string} */ this.input = input;
    /** @type {Array.<adapt.csstok.Token>} */ this.buffer = Array(this.indexMask + 1);
    /** @type {number} */ this.head = -1; // saved, occupied if >= 0
    /** @type {number} */ this.tail = 0; // available, ready to write
    /** @type {number} */ this.curr = 0; // ready to read
    /** @type {number} */ this.position = 0;
    for (var i = 0 ; i <= this.indexMask ; i++)
        this.buffer[i] = new adapt.csstok.Token();
};

/**
 * @return {adapt.csstok.Token}
 */
adapt.csstok.Tokenizer.prototype.token = function() {
    if (this.tail == this.curr)
        this.fillBuffer();
    return this.buffer[this.curr];
};

/**
 * @param {number} n
 * @return {adapt.csstok.Token}
 */
adapt.csstok.Tokenizer.prototype.nthToken = function(n) {
    if (((this.tail - this.curr) & this.indexMask) <= n)
        this.fillBuffer();
    return this.buffer[(this.curr + n) & this.indexMask];
};

/**
 * @return {void}
 */
adapt.csstok.Tokenizer.prototype.consume = function() {
    this.curr = (this.curr + 1) & this.indexMask;
};

/**
 * @return {void}
 */
adapt.csstok.Tokenizer.prototype.mark = function() {
    if (this.head >= 0)
        throw new Error("F_CSSTOK_BAD_CALL mark");
    this.head = this.curr;
};

/**
 * @return {void}
 */
adapt.csstok.Tokenizer.prototype.reset = function() {
    if (this.head < 0)
        throw new Error("F_CSSTOK_BAD_CALL reset");
    this.curr = this.head;
    this.head = -1;
};

/**
 * @return {void}
 */
adapt.csstok.Tokenizer.prototype.unmark = function() {
    this.head = -1;
};

/**
 * @return {boolean}
 */
adapt.csstok.Tokenizer.prototype.hasMark = function() {
    return this.head >= 0;
};

/**
 * @private
 * @return {void}
 */
adapt.csstok.Tokenizer.prototype.reallocate = function() {
    var newIndexMask = 2 * (this.indexMask + 1) - 1;
    /** @type {Array.<adapt.csstok.Token>} */ var newBuffer = Array(newIndexMask + 1);
    var oldIndex = this.head;
    var newIndex = 0;
    while (oldIndex != this.tail) {
        newBuffer[newIndex] = this.buffer[oldIndex];
        if (oldIndex == this.curr)
            this.curr = newIndex;
        oldIndex = (oldIndex + 1) & this.indexMask;
        newIndex++;
    }
    this.head = 0;
    this.tail = newIndex;
    this.indexMask = newIndexMask;
    this.buffer = newBuffer;
    while (newIndex <= newIndexMask) {
        newBuffer[newIndex++] = new adapt.csstok.Token();
    }
};

/**
 * @private
 */
adapt.csstok.Tokenizer.prototype.error = function(position, token, mnemonics) {
	if (this.handler) {
		this.handler.error(mnemonics, token);
	}
};

/**
 * @private
 * @return {void}
 */
adapt.csstok.Tokenizer.prototype.fillBuffer = function() {
    var tail = this.tail;
    var head = this.head >= 0 ? this.head : this.curr;
    var indexMask = this.indexMask;
    if (tail >= head)
        head += indexMask;
    else
        head--;
    if (head == tail) {
        // only expect to get here when mark is in effect
        if (this.head < 0)
            throw new Error("F_CSSTOK_INTERNAL");
        this.reallocate();
        tail = this.tail;
        indexMask = this.indexMask;
        head = indexMask; // this.head is zero
    }
    var actions = adapt.csstok.actionsNormal;
    var input = this.input;
    var position = this.position;
    var buffer = this.buffer;
    /** @type {adapt.csstok.TokenType} */ var tokenType = adapt.csstok.TokenType.EOF;
    /** @type {number} */ var tokenPosition = 0;
    /** @type {string} */ var tokenText = "";
    /** @type {number} */ var tokenNum = 0;
    var seenSpace = false;
    /** @type {adapt.csstok.Token} */ var token = buffer[tail];
    var backslashPos = -9; // far enough before the start of the string
    while (true) {
        var charCode = input.charCodeAt(position);
        switch (actions[charCode] || actions[65/*A*/]) {
            case adapt.csstok.Action.INVALID:
        		tokenType = adapt.csstok.TokenType.INVALID;
        		if (isNaN(charCode)) {
        			tokenText = "E_CSS_UNEXPECTED_EOF";
        		} else {
        			tokenText = "E_CSS_UNEXPECTED_CHAR";
        		}
                actions = adapt.csstok.actionsNormal;
                position++;
                break;
            case adapt.csstok.Action.SPACE:
                position++;
                seenSpace = true;
                continue;
            case adapt.csstok.Action.INT:
                tokenPosition = position++;
                actions = adapt.csstok.actionsInt;
                continue;
            case adapt.csstok.Action.IDENT:
                tokenType = adapt.csstok.TokenType.IDENT;
                tokenPosition = position++;
                actions = adapt.csstok.actionsIdent;
                continue;
            case adapt.csstok.Action.BANG:
                tokenPosition = position++;
                tokenType = adapt.csstok.TokenType.BANG;
                actions = adapt.csstok.actionsCheckEq;
                continue;
            case adapt.csstok.Action.STR1:
                tokenType = adapt.csstok.TokenType.STR;
                tokenPosition = ++position; // after quote
                actions = adapt.csstok.actionsStr1;
                continue;
            case adapt.csstok.Action.STR2:
                tokenType = adapt.csstok.TokenType.STR;
                tokenPosition = ++position; // after quote
                actions = adapt.csstok.actionsStr2;
                continue;
            case adapt.csstok.Action.HASH:
                tokenPosition = ++position; // after hash
	            tokenType = adapt.csstok.TokenType.HASH;
                actions = adapt.csstok.actionsIdent;
                continue;
            case adapt.csstok.Action.DOLLAR:
                tokenPosition = position++;
                tokenType = adapt.csstok.TokenType.DOLLAR;
                actions = adapt.csstok.actionsCheckEq;
                continue;
            case adapt.csstok.Action.PERCENT:
                tokenPosition = position++;
                tokenType = adapt.csstok.TokenType.PERCENT;
                break;
            case adapt.csstok.Action.AMP:
                tokenPosition = position++;
                tokenType = adapt.csstok.TokenType.DOLLAR;
                actions = adapt.csstok.actionsAmp;
                continue;
            case adapt.csstok.Action.O_PAR:
                tokenPosition = position++;
                tokenType = adapt.csstok.TokenType.O_PAR;
                break;
            case adapt.csstok.Action.C_PAR:
                tokenPosition = position++;
                tokenType = adapt.csstok.TokenType.C_PAR;
                break;
            case adapt.csstok.Action.STAR:
                tokenPosition = position++;
                tokenType = adapt.csstok.TokenType.STAR;
                actions = adapt.csstok.actionsCheckEq;
                continue;
            case adapt.csstok.Action.PLUS:
                tokenPosition = position++;
                tokenType = adapt.csstok.TokenType.PLUS;
                break;
            case adapt.csstok.Action.COMMA:
                tokenPosition = position++;
                tokenType = adapt.csstok.TokenType.COMMA;
                break;
            case adapt.csstok.Action.MINUS:
                tokenType = adapt.csstok.TokenType.MINUS;
                tokenPosition = position++;
                actions = adapt.csstok.actionsMinus;
                continue;
            case adapt.csstok.Action.DOT:
                tokenPosition = position++;
                actions = adapt.csstok.actionsNumOrClass;
                continue;
            case adapt.csstok.Action.TOCLASS:
                tokenPosition = position++;
                tokenType = adapt.csstok.TokenType.CLASS;
                actions = adapt.csstok.actionsIdent;
                continue;
            case adapt.csstok.Action.SLASH:
                tokenPosition = position++;
                tokenType = adapt.csstok.TokenType.SLASH;
                actions = adapt.csstok.actionsSlash;
                continue;
            case adapt.csstok.Action.COLON:
                tokenPosition = position++;
                tokenType = adapt.csstok.TokenType.COLON;
                actions = adapt.csstok.actionsColon;
                continue;
            case adapt.csstok.Action.COL_COL:
                position++;
                tokenType = adapt.csstok.TokenType.COL_COL;
                break;
            case adapt.csstok.Action.SEMICOL:
                tokenPosition = position++;
                tokenType = adapt.csstok.TokenType.SEMICOL;
                break;
            case adapt.csstok.Action.LT:
                tokenPosition = position++;
                tokenType = adapt.csstok.TokenType.LT;
                actions = adapt.csstok.actionsLt;
                continue;
            case adapt.csstok.Action.EQ:
                tokenPosition = position++;
                tokenType = adapt.csstok.TokenType.EQ;
                actions = adapt.csstok.actionsCheckEq;
                continue;
            case adapt.csstok.Action.GT:
                tokenPosition = position++;
                tokenType = adapt.csstok.TokenType.GT;
                actions = adapt.csstok.actionsCheckEq;
                continue;
            case adapt.csstok.Action.QMARK:
                tokenPosition = position++;
                tokenType = adapt.csstok.TokenType.QMARK;
                break;
            case adapt.csstok.Action.AT:
                tokenPosition = ++position; // after "at" sign
                tokenType = adapt.csstok.TokenType.AT;
                actions = adapt.csstok.actionsIdent;
                continue;
            case adapt.csstok.Action.O_BRK:
                tokenPosition = position++;
                tokenType = adapt.csstok.TokenType.O_BRK;
                break;
            case adapt.csstok.Action.C_BRK:
                tokenPosition = position++;
                tokenType = adapt.csstok.TokenType.C_BRK;
                break;
            case adapt.csstok.Action.O_BRC:
                tokenPosition = position++;
                tokenType = adapt.csstok.TokenType.O_BRC;
                break;
            case adapt.csstok.Action.C_BRC:
                tokenPosition = position++;
                tokenType = adapt.csstok.TokenType.C_BRC;
                break;
            case adapt.csstok.Action.BSLASH:
                tokenPosition = position++;
                backslashPos = tokenPosition;
                tokenType = adapt.csstok.TokenType.IDENT;
                actions = adapt.csstok.actionsIdentEscChr;
                continue;
            case adapt.csstok.Action.HAT:
                tokenPosition = position++;
                tokenType = adapt.csstok.TokenType.HAT;
                actions = adapt.csstok.actionsCheckEq;
                continue;
            case adapt.csstok.Action.BAR:
                tokenPosition = position++;
                tokenType = adapt.csstok.TokenType.BAR;
                actions = adapt.csstok.actionsBar;
                continue;
            case adapt.csstok.Action.TILDE:
                tokenPosition = position++;
                tokenType = adapt.csstok.TokenType.TILDE;
                actions = adapt.csstok.actionsCheckEq;
                continue;
            case adapt.csstok.Action.END:
                // don't consume current char
                break;
            case adapt.csstok.Action.EQTAIL:
                position++;
                tokenType = /** @type {adapt.csstok.TokenType} */ (tokenType + adapt.csstok.TokenType.BANG_EQ - adapt.csstok.TokenType.BANG);
                break;
            case adapt.csstok.Action.ENDINT:
                // don't consume current char
                tokenType = adapt.csstok.TokenType.INT;
                tokenNum = parseInt(input.substring(tokenPosition, position), 10);
                break;
            case adapt.csstok.Action.ENDNUM:
                // don't consume current char
                tokenType = adapt.csstok.TokenType.NUM;
                tokenNum = parseFloat(input.substring(tokenPosition, position));
                break;
            case adapt.csstok.Action.CONT:
                // just consume current char
                position++;
                continue;
            case adapt.csstok.Action.UNIT:
                tokenType = adapt.csstok.TokenType.NUMERIC;
                tokenNum = parseFloat(input.substring(tokenPosition, position));
                tokenPosition = position++;
                actions = adapt.csstok.actionsIdent;
                continue;
            case adapt.csstok.Action.PCUNIT:
                tokenType = adapt.csstok.TokenType.NUMERIC;
                tokenNum = parseFloat(input.substring(tokenPosition, position));
                tokenText = "%";
                tokenPosition = position++; // for consistency with alphabetic units
                break;
            case adapt.csstok.Action.NUMBER:
                position++;
                actions = adapt.csstok.actionsNumber;
                continue;
            case adapt.csstok.Action.ENDIDNT:
                // don't consume current char
                // tokenType should be set already
                tokenText = input.substring(tokenPosition, position);
                break;
            case adapt.csstok.Action.IDNTESC:
                backslashPos = position++;
                actions = adapt.csstok.actionsIdentEscChr;
                continue;
            case adapt.csstok.Action.ENDIDES: // end of identifier with escapes
                // don't consume current char
                // tokenType should be set already
                tokenText = adapt.csstok.escapeParse(input.substring(tokenPosition, position));
                break;
            case adapt.csstok.Action.ENDSTR:
                tokenText = input.substring(tokenPosition, position);
                // consume closing quote
                position++;
                break;
            case adapt.csstok.Action.ENDESTR:
                tokenText = adapt.csstok.escapeParse(input.substring(tokenPosition, position));
                // consume closing quote
                position++;
                break;
            case adapt.csstok.Action.STR1ESC:
                backslashPos = position;
                position += 2; // consume character after backslash in any case
                actions = adapt.csstok.actionsStr1Esc;
                continue;
            case adapt.csstok.Action.STR2ESC:
                backslashPos = position;
                position += 2; // consume character after backslash in any case
                actions = adapt.csstok.actionsStr2Esc;
                continue;
            case adapt.csstok.Action.BAR_BAR:
                position++;
                tokenType = adapt.csstok.TokenType.BAR_BAR;
                break;
            case adapt.csstok.Action.AMP_AMP:
                position++;
                tokenType = adapt.csstok.TokenType.AMP_AMP;
                break;
            case adapt.csstok.Action.FUNC:
                // tokenType can be adapt.csstok.TokenType.IDENT, adapt.csstok.TokenType.CLASS, adapt.csstok.TokenType.AT, adapt.csstok.TokenType.HASH, adapt.csstok.TokenType.NUMERIC
                tokenText = input.substring(tokenPosition, position);
                if (tokenType == adapt.csstok.TokenType.IDENT) {
                    position++; // consume
                    if (tokenText.toLowerCase() == "url") {
                        actions = adapt.csstok.actionsURL;
                        continue;
                    }
                    tokenType = adapt.csstok.TokenType.FUNC;
                }
                break;
            case adapt.csstok.Action.FUNCES:
                // tokenType can be adapt.csstok.TokenType.IDENT, adapt.csstok.TokenType.CLASS, adapt.csstok.TokenType.AT, adapt.csstok.TokenType.HASH, T_NUMERIC
                tokenText = adapt.csstok.escapeParse(input.substring(tokenPosition, position));
                if (tokenType == adapt.csstok.TokenType.IDENT) {
                    position++; // consume
                    if (tokenText.toLowerCase() == "url") {
                        actions = adapt.csstok.actionsURL;
                        continue;
                    }
                    tokenType = adapt.csstok.TokenType.FUNC;
                }
                break;
            case adapt.csstok.Action.COMMENT:
                actions = adapt.csstok.actionsComment;
                position++;
                continue;
            case adapt.csstok.Action.COMMST:
                actions = adapt.csstok.actionsCommentStar;
                position++;
                continue;
            case adapt.csstok.Action.ENDNOTK:
                actions = adapt.csstok.actionsNormal;
                position++;
                continue;
            case adapt.csstok.Action.MINMIN:
                actions = adapt.csstok.actionsMinusMinus;
                position++;
                continue;
            case adapt.csstok.Action.TOINT:
                tokenType = adapt.csstok.TokenType.INT;
                actions = adapt.csstok.actionsInt;
                position++;
                continue;
            case adapt.csstok.Action.TONUM:
                tokenType = adapt.csstok.TokenType.NUM;
                actions = adapt.csstok.actionsNumber;
                position++;
                continue;
            case adapt.csstok.Action.TOIDENT:
                tokenType = adapt.csstok.TokenType.IDENT;
                actions = adapt.csstok.actionsIdent;
                position++;
                continue;
            case adapt.csstok.Action.TOIDES:
                tokenType = adapt.csstok.TokenType.IDENT;
                actions = adapt.csstok.actionsIdentEscChr;
                backslashPos = position++;
                continue;
            case adapt.csstok.Action.KILL1:
                position--;
                break;
            case adapt.csstok.Action.KILL2:
                position -= 2;
                break;
            case adapt.csstok.Action.URL:
                tokenPosition = position++;
                actions = adapt.csstok.actionsURLInside;
                continue;
            case adapt.csstok.Action.URL1:
                tokenPosition = ++position; // skip quote
                actions = adapt.csstok.actionsURLInside1;
                continue;
            case adapt.csstok.Action.URL2:
                tokenPosition = ++position; // skip quote
                actions = adapt.csstok.actionsURLInside2;
                continue;
            case adapt.csstok.Action.ENDURL:
                tokenType = adapt.csstok.TokenType.URL;
                tokenText = adapt.csstok.escapeParse(input.substring(tokenPosition, position));
                position++; // skip ')'
                break;
            case adapt.csstok.Action.FINURL:
                position++; // skip ')'
                break;
            case adapt.csstok.Action.LT_BG:
                actions = adapt.csstok.actionsLtBang;
                position++;
                continue;
            case adapt.csstok.Action.LT_BG_M:
                actions = adapt.csstok.actionsLtBangMinus;
                position++;
                continue;
            case adapt.csstok.Action.CHKSP:
                // newline in non-quoted URL - check if end of url
                if (position - backslashPos < 8) {
                    // close enough: may be valid
                    if (input.substring(backslashPos + 1, position + 1).match(/^[0-9a-fA-F]{0,6}(\r\n|[\n\r])|[ \t]$/)) {
                        // valid, keep going
                        position++;
                        continue;
                    }
                }
                // end of url
                // fall through
            case adapt.csstok.Action.TERMURL:
                tokenType = adapt.csstok.TokenType.URL;
                tokenText = adapt.csstok.escapeParse(input.substring(tokenPosition, position));
                position++; // skip quote (or newline)
                actions = adapt.csstok.actionsURLTail;
                continue;
            case adapt.csstok.Action.CHKPOSN:
                // newline in string or quoted URL - check validity
                position++;
                if (position - backslashPos < 9) {
                    // close enough: may be valid
                    if (input.substring(backslashPos + 1, position).match(/^[0-9a-fA-F]{0,6}(\r\n|[\n\r])$/)) {
                        // valid, keep going
                        continue;
                    }
                }
                // invalid token
        		tokenType = adapt.csstok.TokenType.INVALID;
        		tokenText = "E_CSS_UNEXPECTED_NEWLINE";
                actions = adapt.csstok.actionsNormal;
                break;
            case adapt.csstok.Action.CHKPOSS:
                // space in identifier - check validity
                if (position - backslashPos < 9) {
                    // close enough: may be valid
                    if (input.substring(backslashPos + 1, position + 1).match(/^[0-9a-fA-F]{0,6}[ \t]$/)) {
                        // valid, keep going
                        position++;
                        continue;
                    }
                }
                // end of identifier
                // don't consume current char
                // tokenType should be set already
                tokenText = adapt.csstok.escapeParse(input.substring(tokenPosition, position));
                break;
            case adapt.csstok.Action.URLESC:
                backslashPos = position++;
                continue;
            case adapt.csstok.Action.IDESCH:
                position++;
                actions = adapt.csstok.actionsIdentEsc;
                continue;
            default:
                // EOF
                if (actions !== adapt.csstok.actionsNormal) {
            		tokenType = adapt.csstok.TokenType.INVALID;
            		tokenText = "E_CSS_UNEXPECTED_STATE";
            		break;
                }
                tokenPosition = position;
                tokenType = adapt.csstok.TokenType.EOF;
        }
        token.type = tokenType;
        token.precededBySpace = seenSpace;
        token.num = tokenNum;
        token.text = tokenText;
        token.position = tokenPosition;
        tail++;
        if (tail >= head)
            break;
        actions = adapt.csstok.actionsNormal;
        seenSpace = false;
        token = buffer[tail & indexMask];
    }
    this.position = position;
    this.tail = tail & indexMask;
};


text:
namespace ash {

// A Shape is basically a Path with information on the stroke width and cap
// type. A Shape can consist of two Paths that can have different stroke widths.
// MicPartShape only has the |first_path|. LetterShape has two Paths.
class Shape {
 public:
  explicit Shape(float dot_size);

  Shape(const Shape&) = delete;
  Shape& operator=(const Shape&) = delete;

  virtual ~Shape();

  float dot_size() const { return dot_size_; }

  SkPath* first_path() { return &first_path_; }

  SkPath* second_path() { return &second_path_; }

  void set_first_stroke_width(float first_stroke_width) {
    first_stroke_width_ = first_stroke_width;
  }
  float first_stroke_width() const { return first_stroke_width_; }

  void set_second_stroke_width(float second_stroke_width) {
    second_stroke_width_ = second_stroke_width;
  }
  float second_stroke_width() const { return second_stroke_width_; }

  void set_cap(cc::PaintFlags::Cap cap) { cap_ = cap; }
  cc::PaintFlags::Cap cap() const { return cap_; }

  void Reset();

  void Transform(float x, float y, float scale);

 private:
  const float dot_size_;

  SkPath first_path_;
  SkPath second_path_;

  float first_stroke_width_ = 0.0f;
  float second_stroke_width_ = 0.0f;

  cc::PaintFlags::Cap cap_ = cc::PaintFlags::kRound_Cap;
};

}  // namespace ash

#endif  // ASH_ASSISTANT_UI_LOGO_VIEW_SHAPE_SHAPE_H_

redpajama_set_name: RedPajamaGithub


text:
import keystoneclient
from keystoneclient.tests.functional import base

class V3ClientVersionTestCase(base.V3ClientTestCase):

    def test_version(self):
        self.assertIsInstance(self.client,
                              keystoneclient.v3.client.Client)

class V2ClientVersionTestCase(base.V2ClientTestCase):

    def test_version(self):
        self.assertIsInstance(self.client,
                              keystoneclient.v2_0.client.Client)


text:
\documentclass[letterpaper]{article}
\usepackage[final]{pdfpages}
\begin{document}
\includepdf[pages={1,2,7,4,5,6,3,8}, booklet, landscape]{8up-zine}
\end{document}


text:
//******************************************************************************************************************************************************************************************//
// Copyright (c) 2021 abergs (https://github.com/abergs/fido2-net-lib)                                                                                //
//                                                                                //
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),                                       //
// to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,   //
// and to permit persons to whom the Software is furnished to do so, subject to the following conditions:                                                                                //
//                                                                                //
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.                                                           //
//                                                                                //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,                                      //
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,                            //
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               //
//                                                                                //
//******************************************************************************************************************************************************************************************//
using Newtonsoft.Json;

namespace Neos.IdentityServer.MultiFactor.WebAuthN
{
    /// <summary>
    /// The CodeAccuracyDescriptor describes the relevant accuracy/complexity aspects of passcode user verification methods.
    /// </summary>
    /// <remarks>
    /// <see href="https://fidoalliance.org/specs/fido-v2.0-rd-20180702/fido-metadata-statement-v2.0-rd-20180702.html#codeaccuracydescriptor-dictionary"/>
    /// </remarks>
    public class CodeAccuracyDescriptor
    {
        /// <summary>
        /// Gets or sets the numeric system base (radix) of the code, e.g.  10 in the case of decimal digits.
        /// </summary>
        [JsonProperty("base", Required = Required.Always)]
        public ushort Base { get; set; }
        /// <summary>
        /// Gets or sets the minimum number of digits of the given base required for that code, e.g. 4 in the case of 4 digits.
        /// </summary>
        [JsonProperty("minLength", Required = Required.Always)]
        public ushort MinLength { get; set; }
        /// <summary>
        /// Gets or sets the maximum number of false attempts before the authenticator will block this method (at least for some time).
        /// <para>Zero (0) means it will never block.</para>
        /// </summary>
        [JsonProperty("maxRetries")]
        public ushort MaxRetries { get; set; }
        /// <summary>
        /// Gets or sets the enforced minimum number of seconds wait time after blocking (e.g. due to forced reboot or similar).
        /// <para>Zero (0) means this user verification method will be blocked, either permanently or until an alternative user verification method method succeeded.</para>
        /// </summary>
        /// <remarks>
        /// All alternative user verification methods MUST be specified appropriately in the Metadata in <see cref="MetadataStatement.UserVerificationDetails"/>.
        /// </remarks>
        [JsonProperty("blockSlowdown")]
        public ushort BlockSlowdown { get; set; }
    }
}


text:
import UserStatus = require('./UserStatus');
import UserInterface = require('./UserInterface');

class User implements UserInterface {
    public id: string;
    public first_name: string;
    public last_name: string;
    public create_date: Date;
    public status_change_date: Date;
    public status: UserStatus;

    constructor(user?: any) {
        if (user) {
            this.id = user.id;
            this.first_name = user.first_name;
            this.last_name = user.last_name;
            this.create_date = user.create_date;
            this.status_change_date = user.status_change_date;
            this.status = user.status;
        }
    }

    public toDocument() {
        return {
            id: this.id,
            first_name: this.first_name,
            last_name: this.last_name,
            create_date: this.create_date,
            status_change_date: this.status_change_date,
            status: this.status
        };
    }
}

export = User;


text:
CREATE TABLE flow_deny_lists (
    id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    flow_id VARCHAR(100) NOT NULL,
    deny_mode VARCHAR(10) NOT NULL ,
    deny_version VARCHAR (100),
    rule_name VARCHAR (100) NOT NULL
);

CREATE INDEX idx_flow_id
    ON flow_deny_lists (flow_id);
CREATE INDEX idx_flow_deny_rule_name
    ON flow_deny_lists (rule_name);
CREATE INDEX idx_flow_id_deny_mode
    ON flow_deny_lists (flow_id, deny_mode);
CREATE INDEX idx_flow_id_deny_version
    ON flow_deny_lists (flow_id, deny_version);


text:
"""
Generate training images from the UIUC training dataset - we need to place the training samples on
some background because the crops themselves are not enough for training DNNs.

The annotations are generated in the BBTXT format:
filename label confidence xmin ymin xmax ymax
filename label confidence xmin ymin xmax ymax
filename label confidence xmin ymin xmax ymax
...

----------------------------------------------------------------------------------------------------
python uiuc_generator.py path_background path_uiuc path_out dataset_size width height
----------------------------------------------------------------------------------------------------
"""

__date__   = '02/21/2016'
__author__ = 'Libor Novak'
__email__  = 'novakli2@fel.cvut.cz'

import argparse
import os
import cv2
import numpy as np
import random

class UIUCGenerator(object):
	def __init__(self, width, height, path_background, path_uiuc):
		"""
		Input:
			width: width of each generated image
			height: height of each generated image
			path_background: path to the folder with background images
			path_uiuc: path to the folder with positive UIUC images
		"""
		self.width = int(width)
		self.height = int(height)
		self.path_background = path_background
		self.path_uiuc = path_uiuc

		self.image_counter = 0

	def create_dataset(self, path, size):
		"""
		Generates a dataset of images and saves them to the given folder.

		Input:
			path: path to the output folder
			size: number of images in the dataset
		"""
		if not os.path.exists(path):
			os.makedirs(path)

		# Load the contents of the folders
		images_background = [f for f in os.listdir(self.path_background) if f != '.DS_Store']
		images_uiuc = [f for f in os.listdir(self.path_uiuc) if f != '.DS_Store']

		path_bbtxt = os.path.join(path, 'annotations.bbtxt')
		with open(path_bbtxt, 'w') as outfile:
			# Generate the images
			for i in range(size):
				# Pick a random background image and a random training sample
				name_image_bg = images_background[int(round(random.uniform(0, len(images_background)-1)))]
				name_image_fg = images_uiuc[int(round(random.uniform(0, len(images_uiuc)-1)))]

				image, labels = self._generate_image(path, name_image_bg, name_image_fg)

				# Write image
				cv2.imwrite(labels['path'], image)

				# Write out labels
				for bb in labels['bbs']:
					outfile.write(labels['path'] + ' 1 1 ' + str(bb['x_min']) + ' ' + str(bb['y_min'])
						+ ' ' + str(bb['x_max']) + ' ' + str(bb['y_max']) + '\n')

	################################################################################################
	#                                          PRIVATE                                             #
	################################################################################################

	def _generate_image(self, path_out, name_image_bg, name_image_fg):
		"""
		Generates a random image with UIUC cars.

		Input:
			path_out: Path to the output folder
			name_image_bg: Image to be used as background
			name_image_fg: UIUC car image name
		Output:
			3 channel BGR image,
			dict with labels {bbs, path}
		"""
		path = os.path.join(path_out, str(self.image_counter) + '.png')

		# Load background and foreground image
		image_bg = cv2.imread(os.path.join(self.path_background, name_image_bg), cv2.IMREAD_GRAYSCALE)
		image_fg = cv2.imread(os.path.join(self.path_uiuc, name_image_fg), cv2.IMREAD_GRAYSCALE)

		# Crop the background image to the requested size
		if image_bg.shape[0] >= self.height and image_bg.shape[1] >= self.width:
			# We can just crop it
			image_bg = image_bg[-self.height:, 0:self.width]
		else:
			# Rescale the background image
			image_bg = cv2.resize(image_bg, (self.width, self.height))

		# Create blending mask - we want to smooth the edges
		mask = np.zeros(image_fg.shape, np.float32)
		cv2.rectangle(mask, (5, 5), (mask.shape[1]-5, mask.shape[0]-5), (1), -1)
		mask = cv2.GaussianBlur(mask, (15,15), 3)

		# Place the car on a random position in the image
		x = int(round(random.uniform(0, self.width-image_fg.shape[1])))
		y = int(round(random.uniform(0, self.height-image_fg.shape[0])))

		image_bg[y:y+image_fg.shape[0], x:x+image_fg.shape[1]] = (1-mask)*image_bg[y:y+image_fg.shape[0], x:x+image_fg.shape[1]] + mask*image_fg

		# Add some noise
		sigma = random.uniform(0, 30)
		image_bg = np.clip(image_bg + np.random.normal(0, sigma, (self.height, self.width)), 0, 255)

		labels = {
			'bbs': [],
			'path' : path,
		}
		labels['bbs'].append({
			'x_min': x,
			'y_min': y,
			'x_max': x + image_fg.shape[1],
			'y_max': y + image_fg.shape[0],
		})

		# Raise the image counter
		self.image_counter += 1

		image_rgb = cv2.cvtColor(image_bg.astype(np.uint8), cv2.COLOR_GRAY2BGR)

		return image_rgb, labels

####################################################################################################
#                                               MAIN                                               #
####################################################################################################

def check_path(path, is_folder=False):
	"""
	Checks if the given path exists.

	Input:
		path:      Path to be checked
		is_folder: True if the checked path is a folder
	Returns:
		True if the given path exists
	"""
	if not os.path.exists(path) or (not is_folder and not os.path.isfile(path)):
		print('ERROR: Path "%s" does not exist!'%(path))
		return False

	return True

def parse_arguments():
	"""
	Parse input options of the script
	"""
	parser = argparse.ArgumentParser(description='Generate artificial images with UIUC cars.')

	parser.add_argument('path_background', metavar='path_background', type=str,
	                    help='Path to the folder with background images')
	parser.add_argument('path_uiuc', metavar='path_uiuc', type=str,
	                    help='Path to the folder with positive UIUC samples')
	parser.add_argument('path_out', metavar='path_out', type=str,
	                    help='Path to the output folder')
	parser.add_argument('dataset_size', metavar='dataset_size', type=int,
						help='Size of the dataset (number of images)')
	parser.add_argument('width', metavar='width', type=int,
	                    help='Width of the generated images')
	parser.add_argument('height', metavar='height', type=int,
	                    help='Height of the generated images')

	args = parser.parse_args()

	if not check_path(args.path_background, True) or not check_path(args.path_uiuc, True):
		parser.print_help()
		exit(1)

	return args

def main():
	args = parse_arguments()

	cg = UIUCGenerator(args.width, args.height, args.path_background, args.path_uiuc)
	cg.create_dataset(args.path_out, int(args.dataset_size))

if __name__ == '__main__':
    main()


text:
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.

namespace Intel.RealSense
{
    ///
    /// Read-only strings that can be queried from the device.
    ///
    /// <remarks>
    /// Not all information attributes are available on all camera types.
    /// This information is mainly available for camera debug and troubleshooting and should not be used in applications. */
    /// </remarks>
    public enum CameraInfo
    {
        ///  Friendly name
        Name = 0,

        ///  Device serial number
        SerialNumber = 1,

        ///  Primary firmware version
        FirmwareVersion = 2,

        ///  Recommended firmware version
        RecommendedFirmwareVersion = 3,

        ///  Unique identifier of the port the device is connected to (platform specific)
        PhysicalPort = 4,

        ///  If device supports firmware logging, this is the command to send to get logs from firmware
        DebugOpCode = 5,

        ///  True iff the device is in advanced mode
        AdvancedMode = 6,

        ///  Product ID as reported in the USB descriptor
        ProductId = 7,

        ///  True iff EEPROM is locked
        CameraLocked = 8,

        ///  Designated USB specification: USB2/USB3
        UsbTypeDescriptor = 9,
    }
}


text:
[![Build Status](https://img.shields.io/travis/maZahaca/redparser.svg?style=flat)](https://travis-ci.org/maZahaca/redparser)

This Project Has Been Deprecated
================================
[![This Project Has Been Deprecated in favor of redco/goose-parser.](http://www.repostatus.org/badges/0.1.0/abandoned.svg)](http://www.repostatus.org/#abandoned)

in favor of https://github.com/redco/goose-parser.

## Tests

However mocha-phantomjs dependencies are mapped to the version 1.9.*
It's required to have installed version [PhantomJS 2.0](https://github.com/eugene1g/phantomjs/releases) and use it for test running

Run tests with command:

```
./node_modules/.bin/mocha-phantomjs -p /usr/local/bin/phantomjs tests/redparser.html
```


text:
package com.amazonaws.services.kendra.model.transform;

import java.util.List;
import javax.annotation.Generated;

import com.amazonaws.SdkClientException;
import com.amazonaws.services.kendra.model.*;

import com.amazonaws.util.IdempotentUtils;

import com.amazonaws.protocol.*;
import com.amazonaws.annotation.SdkInternalApi;

/**
 * CreateAccessControlConfigurationRequestMarshaller
 */
@Generated("com.amazonaws:aws-java-sdk-code-generator")
@SdkInternalApi
public class CreateAccessControlConfigurationRequestMarshaller {

    private static final MarshallingInfo<String> INDEXID_BINDING = MarshallingInfo.builder(MarshallingType.STRING).marshallLocation(MarshallLocation.PAYLOAD)
            .marshallLocationName("IndexId").build();
    private static final MarshallingInfo<String> NAME_BINDING = MarshallingInfo.builder(MarshallingType.STRING).marshallLocation(MarshallLocation.PAYLOAD)
            .marshallLocationName("Name").build();
    private static final MarshallingInfo<String> DESCRIPTION_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
            .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("Description").build();
    private static final MarshallingInfo<List> ACCESSCONTROLLIST_BINDING = MarshallingInfo.builder(MarshallingType.LIST)
            .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("AccessControlList").build();
    private static final MarshallingInfo<List> HIERARCHICALACCESSCONTROLLIST_BINDING = MarshallingInfo.builder(MarshallingType.LIST)
            .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("HierarchicalAccessControlList").build();
    private static final MarshallingInfo<String> CLIENTTOKEN_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
            .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("ClientToken")
            .defaultValueSupplier(com.amazonaws.util.IdempotentUtils.getGenerator()).build();

    private static final CreateAccessControlConfigurationRequestMarshaller instance = new CreateAccessControlConfigurationRequestMarshaller();

    public static CreateAccessControlConfigurationRequestMarshaller getInstance() {
        return instance;
    }

    /**
     * Marshall the given parameter object.
     */
    public void marshall(CreateAccessControlConfigurationRequest createAccessControlConfigurationRequest, ProtocolMarshaller protocolMarshaller) {

        if (createAccessControlConfigurationRequest == null) {
            throw new SdkClientException("Invalid argument passed to marshall(...)");
        }

        try {
            protocolMarshaller.marshall(createAccessControlConfigurationRequest.getIndexId(), INDEXID_BINDING);
            protocolMarshaller.marshall(createAccessControlConfigurationRequest.getName(), NAME_BINDING);
            protocolMarshaller.marshall(createAccessControlConfigurationRequest.getDescription(), DESCRIPTION_BINDING);
            protocolMarshaller.marshall(createAccessControlConfigurationRequest.getAccessControlList(), ACCESSCONTROLLIST_BINDING);
            protocolMarshaller.marshall(createAccessControlConfigurationRequest.getHierarchicalAccessControlList(), HIERARCHICALACCESSCONTROLLIST_BINDING);
            protocolMarshaller.marshall(createAccessControlConfigurationRequest.getClientToken(), CLIENTTOKEN_BINDING);
        } catch (Exception e) {
            throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
        }
    }

}


text:
package org.javers.core.examples.typeNames;

/**
 * @author bartosz.walacik
 */
public class AbstractValueObject {
    private int someValue;

    public AbstractValueObject(int someValue) {
        this.someValue = someValue;
    }
}


text:
<?php $this->load->view('includes/header');?>
<?php $this->load->view('includes/navbar');?>

                          Menu

			 	<a href="<?php echo base_url();?>admin/menu_summary" class="btn btn-success pull-right">Add Item

Coffee

Pasta

Sandwich

<img src="<?php echo base_url();?>images/caramel.jpg" width="150" height="150" alt="img">

							        	<button type="button" class="btn btn-default button-image-menu" data-toggle="tooltip" data-placement="top" title="Edit">Edit</button>
							        	<button type="button" class="btn btn-default button-image-menu" data-toggle="tooltip" data-placement="top" title="Delete">Delete</button>

Caramel Macchiato

140.00

<img src="<?php echo base_url();?>images/caramel-macchiato.jpg" width="150" height="150" alt="img">

							        	<button type="button" class="btn btn-default button-image-menu" data-toggle="tooltip" data-placement="top" title="Edit">Edit</button>
							        	<button type="button" class="btn btn-default button-image-menu" data-toggle="tooltip" data-placement="top" title="Delete">Delete</button>

Dark Chocolate

140.00

<img src="<?php echo base_url();?>images/coffee-caramel.jpg" width="150" height="150" alt="img">

							        	<button type="button" class="btn btn-default button-image-menu" data-toggle="tooltip" data-placement="top" title="Edit">Edit</button>
							        	<button type="button" class="btn btn-default button-image-menu" data-toggle="tooltip" data-placement="top" title="Delete">Delete</button>

Ice Cold Coffee

140.00

<img src="<?php echo base_url();?>images/caramel-3.jpg" width="150" height="150" alt="img">

							        	<button type="button" class="btn btn-default button-image-menu" data-toggle="tooltip" data-placement="top" title="Edit">Edit</button>
							        	<button type="button" class="btn btn-default button-image-menu" data-toggle="tooltip" data-placement="top" title="Delete">Delete</button>

Belgian Chocolate

140.00

			         					MC00013
		         						<img class="img-responsive img-rounded" src="<?php echo base_url();?>images/pasta-1.jpg">

			         					Caramel Macchiato

			         					₱ 140.00

			         					MC00014
		         						<img class="img-responsive img-rounded" src="<?php echo base_url();?>images/pasta-2.jpg">

			         					Dark Chocolate

			         					₱ 140.00

			         					MC00015
		         						<img class="img-responsive img-rounded" src="<?php echo base_url();?>images/pasta-3.jpg">

			         					Caramel Choco

			         					₱ 140.00

			         					MC00013
		         						<img class="img-responsive img-rounded" src="<?php echo base_url();?>images/pasta-4.jpg">

			         					Caramel Macchiato

			         					₱ 140.00

			         					MC00014
		         						<img class="img-responsive img-rounded" src="<?php echo base_url();?>images/pasta-5.jpg">

			         					Dark Chocolate

			         					₱ 140.00

			         					MC00015
		         						<img class="img-responsive img-rounded" src="<?php echo base_url();?>images/pasta-6.jpg">

			         					Caramel Choco

			         					₱ 140.00

			         					MC00013
		         						<img class="img-responsive img-rounded" src="<?php echo base_url();?>images/sandwich-1.jpg">

			         					Caramel Macchiato

			         					₱ 140.00

			         					MC00014
		         						<img class="img-responsive img-rounded" src="<?php echo base_url();?>images/sandwich-2.jpg">

			         					Dark Chocolate

			         					₱ 140.00

			         					MC00015
		         						<img class="img-responsive img-rounded" src="<?php echo base_url();?>images/sandwich-3.jpg">

			         					Caramel Choco

			         					₱ 140.00

			         					MC00013
		         						<img class="img-responsive img-rounded" src="<?php echo base_url();?>images/sandwich-4.jpg">

			         					Caramel Macchiato

			         					₱ 140.00

			         					MC00014
		         						<img class="img-responsive img-rounded" src="<?php echo base_url();?>images/sandwich-5.jpg">

			         					Dark Chocolate

			         					₱ 140.00

			         					MC00015
		         						<img class="img-responsive img-rounded" src="<?php echo base_url();?>images/sandwich-6.jpg">

			         					Caramel Choco

			         					₱ 140.00

<?php $this->load->view('includes/footer');?>


text:
package com.abusalimov.mrcalc.backend.impl.exprfunc;

import com.abusalimov.mrcalc.backend.SequenceMap;
import com.abusalimov.mrcalc.runtime.Sequence;

/**
 * Implements sequence mapping expressions factory.
 *
 * @param <T> the type of a sequence elements
 * @author Eldar Abusalimov
 */
public class FuncSequenceMap<T> implements SequenceMap<Func<Sequence<T>>, Func<Sequence<?>>, Func<T>> {
    public static final FuncSequenceMap INSTANCE = new FuncSequenceMap();

    @Override
    public Func<Sequence<T>> map(Func<Sequence<?>> sequenceExpr, Func<T> lambda) {
        return (runtime, args) -> {
            Sequence<?> sequence = sequenceExpr.eval(runtime, args);
            return runtime.mapToObject(sequence, x -> lambda.eval(runtime, new Object[]{x}));
        };
    }
}


text:
package junit.org.mandfer.mobile.automation.framework.commons.factory;

import com.google.inject.Guice;
import com.google.inject.Injector;
import junit.org.mandfer.mobile.automation.framework.commons.JunitTestConstants;
import static junit.org.mandfer.mobile.automation.framework.commons.JunitTestConstants.TEST_SAMPLE_PROPS_FILE;
import static org.hamcrest.core.StringContains.containsString;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mandfer.mobile.automation.framework.commons.config.ConfigLoader;
import org.mandfer.mobile.automation.framework.commons.device.Device;
import org.mandfer.mobile.automation.framework.commons.driver.Driver;
import org.mandfer.mobile.automation.framework.commons.exceptions.DeviceFactoryException;
import org.mandfer.mobile.automation.framework.commons.guice.DeviceFactory;
import org.mandfer.mobile.automation.framework.commons.guice.DeviceFactoryGuice;
import org.mandfer.mobile.automation.framework.commons.guice.DriverFactory;
import org.mandfer.mobile.automation.framework.commons.guice.MAF_Module;
import org.mandfer.mobile.automation.framework.ios.device.IosDevice;

import java.io.IOException;
import java.util.Properties;
import org.junit.Ignore;

/**
 * @author marcandreuf
 */
public class GuiceDeviceFactoryTest {

    private ConfigLoader mocked_configLoader;
    private Properties mocked_config;
    private DriverFactory mocked_driverFactory;
    private Driver mocked_driver;
    private String sampleDriverFileName;

    @Before
    public void setUp(){
        mocked_configLoader = mock(ConfigLoader.class);
        mocked_config = mock(Properties.class);
        mocked_driverFactory = mock(DriverFactory.class);
        mocked_driver = mock(Driver.class);
        sampleDriverFileName = "sampleDriverPropsFileName";
    }

    @Test
    @Ignore //Fix Driver factory
    public void createDeviceFromConfigFileNameWithGuice() throws Exception {
        Injector injector = Guice.createInjector(new MAF_Module());
        DeviceFactoryGuice deviceFactory = injector.getInstance(DeviceFactoryGuice.class);

        Device device = deviceFactory.create(
                JunitTestConstants.TEST_DEVICE_PROPS_FILE);

        assertTrue(device != null && device instanceof Device);
        assertTrue(device.getDriver() != null);
    }

    @Test
    @Ignore //Fix Driver factory
    public void testDeviceFactoryBehaviour() throws Exception {
        DeviceFactory deviceFactory =
                new DeviceFactoryGuice(mocked_configLoader, mocked_driverFactory);

        when(mocked_configLoader.loadConfig(TEST_SAMPLE_PROPS_FILE))
                .thenReturn(mocked_config);
        when(mocked_config.getProperty(DeviceFactory.DRIVER_CONFIG_FILENAME))
                .thenReturn(sampleDriverFileName);
        when(mocked_driverFactory.create(sampleDriverFileName))
                .thenReturn(mocked_driver);
        when(mocked_config.getProperty(DeviceFactory.DEVICE_PLATFORM))
                .thenReturn(Device.PLATFORM.IOS.toString());

        Device device = deviceFactory.create(JunitTestConstants.TEST_SAMPLE_PROPS_FILE);

        verify(mocked_configLoader).loadConfig(TEST_SAMPLE_PROPS_FILE);
        verify(mocked_config).getProperty(DeviceFactory.DRIVER_CONFIG_FILENAME);
        verify(mocked_config).getProperty(DeviceFactory.DEVICE_PLATFORM);
        assertTrue(device instanceof IosDevice);

    }

    @Rule
    public ExpectedException expectedException = ExpectedException.none();

    @Test
    @Ignore //Fix Driver factory
    public void testFailLoadingWrongConfigFile() throws Exception {
        DeviceFactory deviceFactory =
                new DeviceFactoryGuice(mocked_configLoader, mocked_driverFactory);

        when(mocked_configLoader.loadConfig(TEST_SAMPLE_PROPS_FILE))
                .thenThrow(IOException.class);

        expectedException.expect(DeviceFactoryException.class);
        expectedException.expectMessage(containsString("Unable to load " + TEST_SAMPLE_PROPS_FILE));

        deviceFactory.create(TEST_SAMPLE_PROPS_FILE);
    }

    @Test
    @Ignore //Fix Driver factory
    public void testFailLoadingWrongDriverClassName() throws Exception {
        DeviceFactory deviceFactory =
                new DeviceFactoryGuice(mocked_configLoader, mocked_driverFactory);

        when(mocked_configLoader.loadConfig(TEST_SAMPLE_PROPS_FILE))
                .thenReturn(mocked_config);
        when(mocked_config.getProperty(DeviceFactory.DRIVER_CONFIG_FILENAME))
                .thenReturn(sampleDriverFileName);
        when(mocked_driverFactory.create(sampleDriverFileName))
                .thenThrow(Exception.class);

        expectedException.expect(DeviceFactoryException.class);
        expectedException.expectMessage(containsString("Unable create a driver "));

        deviceFactory.create(TEST_SAMPLE_PROPS_FILE);
    }

    //TODO: Test WRong platform
    @Test
    @Ignore //Fix Driver factory
    public void testFailLoadingWrongPlatformName() throws Exception {
        DeviceFactory deviceFactory =
                new DeviceFactoryGuice(mocked_configLoader, mocked_driverFactory);

        when(mocked_configLoader.loadConfig(TEST_SAMPLE_PROPS_FILE))
                .thenReturn(mocked_config);
        when(mocked_config.getProperty(DeviceFactory.DRIVER_CONFIG_FILENAME))
                .thenReturn(sampleDriverFileName);
        when(mocked_driverFactory.create(sampleDriverFileName))
                .thenReturn(mocked_driver);
        when(mocked_config.getProperty(DeviceFactory.DEVICE_PLATFORM))
                .thenReturn(null);

        expectedException.expect(DeviceFactoryException.class);
        expectedException.expectMessage(
                containsString("Platform name not recognised in the device config file. "));

        deviceFactory.create(TEST_SAMPLE_PROPS_FILE);
    }

}


text:
{% extends "layout.html" %}
{% load crispy_forms_tags %}

{% block title %}Missing Redirect URI{% endblock %}

{% block content %}

Missing Redirect URI

The client requesting authorization did not specify a redirect URI so we are unable to complete this request.

{% endblock %}