⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aslcompiler.l

📁 acpi tools for linux include acpiexec and acpixtract
💻 L
📖 第 1 页 / 共 3 页
字号:
/******************************************************************************* * * FUNCTION:    comment * * PARAMETERS:  none * * RETURN:      none * * DESCRIPTION: Process a standard comment. * ******************************************************************************/charcomment (void){    char                c;    char                c1 = 0;    InsertLineBuffer ('/');    InsertLineBuffer ('*');loop:    /* Eat chars until end-of-comment */    while ((c = (char) input()) != '*' && c != EOF)    {        InsertLineBuffer (c);        c1 = c;    }    if (c == EOF)    {        goto EarlyEOF;    }    /*     * Check for nested comment -- can help catch cases where a previous     * comment was accidently left unterminated     */    if ((c1 == '/') && (c == '*'))    {        AslCommonError (ASL_WARNING, ASL_MSG_NESTED_COMMENT,                        Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,                        Gbl_InputByteCount, Gbl_CurrentColumn,                        Gbl_Files[ASL_FILE_INPUT].Filename, NULL);    }    /* Comment is closed only if the NEXT character is a slash */    InsertLineBuffer (c);    if ((c1 = (char) input()) != '/' && c1 != EOF)    {        unput(c1);        goto loop;    }    if (c1 == EOF)    {        goto EarlyEOF;    }    InsertLineBuffer (c1);    return TRUE;EarlyEOF:    /*     * Premature End-Of-File     */    AslCommonError (ASL_ERROR, ASL_MSG_EARLY_EOF,                    Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,                    Gbl_CurrentLineOffset, Gbl_CurrentColumn,                    Gbl_Files[ASL_FILE_INPUT].Filename, NULL);    return (FALSE);}/******************************************************************************* * * FUNCTION:    comment * * PARAMETERS:  none * * RETURN:      none * * DESCRIPTION: Process a new "//" comment. * ******************************************************************************/charcomment2 (void){    char                c;    InsertLineBuffer ('/');    InsertLineBuffer ('/');    while ((c = (char) input()) != '\n' && c != EOF)    {        InsertLineBuffer (c);    }    if (c == EOF)    {        /* End of file is OK, change to newline. Let parser detect EOF later */        c = '\n';    }    InsertLineBuffer (c);    return (TRUE);}/******************************************************************************* * * FUNCTION:    literal * * PARAMETERS:  none * * RETURN:      none * * DESCRIPTION: Process a string literal (surrounded by quotes) * ******************************************************************************/#define ASL_NORMAL_CHAR         0#define ASL_ESCAPE_SEQUENCE     1#define ASL_OCTAL_CONSTANT      2#define ASL_HEX_CONSTANT        3charliteral (void){    char                *StringBuffer = MsgBuffer;    char                *EndBuffer = MsgBuffer + ASL_MSG_BUFFER_SIZE;    char                *CleanString;    char                StringChar;    UINT32              State = ASL_NORMAL_CHAR;    UINT32              i = 0;    UINT8               Digit;    char                ConvertBuffer[4];    /*     * Eat chars until end-of-literal.     * NOTE:  Put back the original surrounding quotes into the     * source line buffer.     */    InsertLineBuffer ('\"');    while ((StringChar = (char) input()) != EOF)    {        InsertLineBuffer (StringChar);DoCharacter:        switch (State)        {        case ASL_NORMAL_CHAR:            switch (StringChar)            {            case '\\':                /*                 * Special handling for backslash-escape sequence.  We will                 * toss the backslash and translate the escape char(s).                 */                State = ASL_ESCAPE_SEQUENCE;                continue;            case '\"':                /* String terminator */                goto CompletedString;            }            break;        case ASL_ESCAPE_SEQUENCE:            State = ASL_NORMAL_CHAR;            switch (StringChar)            {            case 'a':                StringChar = 0x07;      /* BELL */                break;            case 'b':                StringChar = 0x08;      /* BACKSPACE */                break;            case 'f':                StringChar = 0x0C;      /* FORMFEED */                break;            case 'n':                StringChar = 0x0A;      /* LINEFEED */                break;            case 'r':                StringChar = 0x0D;      /* CARRIAGE RETURN*/                break;            case 't':                StringChar = 0x09;      /* HORIZONTAL TAB */                break;            case 'v':                StringChar = 0x0B;      /* VERTICAL TAB */                break;            case 'x':                State = ASL_HEX_CONSTANT;                i = 0;                continue;            case '\'':                  /* Single Quote */            case '\"':                  /* Double Quote */            case '\\':                  /* Backslash */                break;            default:                /* Check for an octal digit (0-7) */                if (ACPI_IS_OCTAL_DIGIT (StringChar))                {                    State = ASL_OCTAL_CONSTANT;                    ConvertBuffer[0] = StringChar;                    i = 1;                    continue;                }                /* Unknown escape sequence issue warning, but use the character */                AslCommonError (ASL_WARNING, ASL_MSG_INVALID_ESCAPE,                                Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,                                Gbl_CurrentLineOffset, Gbl_CurrentColumn,                                Gbl_Files[ASL_FILE_INPUT].Filename, NULL);				break;            }            break;        case ASL_OCTAL_CONSTANT:            /* Up to three octal digits allowed */            if (!ACPI_IS_OCTAL_DIGIT (StringChar) ||                (i > 2))            {                /*                 * Reached end of the constant.  Convert the assembled ASCII                 * string and resume processing of the next character                 */                ConvertBuffer[i] = 0;                Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 8);                /* Check for NULL or non-ascii character (ignore if so) */                if ((Digit == 0) || (Digit > ACPI_ASCII_MAX))                {                    AslCommonError (ASL_WARNING, ASL_MSG_INVALID_STRING,                                    Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,                                    Gbl_CurrentLineOffset, Gbl_CurrentColumn,                                    Gbl_Files[ASL_FILE_INPUT].Filename, NULL);                }                else                {                    *StringBuffer = (char) Digit;                    StringBuffer++;                    if (StringBuffer >= EndBuffer)                    {                        goto BufferOverflow;                    }                }                State = ASL_NORMAL_CHAR;                goto DoCharacter;                break;            }            /* Append another digit of the constant */            ConvertBuffer[i] = StringChar;            i++;            continue;        case ASL_HEX_CONSTANT:            /* Up to two hex digits allowed */            if (!ACPI_IS_XDIGIT (StringChar) ||                (i > 1))            {                /*                 * Reached end of the constant.  Convert the assembled ASCII                 * string and resume processing of the next character                 */                ConvertBuffer[i] = 0;                Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 16);                /* Check for NULL or non-ascii character (ignore if so) */                if ((Digit == 0) || (Digit > ACPI_ASCII_MAX))                {                    AslCommonError (ASL_WARNING, ASL_MSG_INVALID_STRING,                                    Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,                                    Gbl_CurrentLineOffset, Gbl_CurrentColumn,                                    Gbl_Files[ASL_FILE_INPUT].Filename, NULL);                }                else                {                    *StringBuffer = (char) Digit;                    StringBuffer++;                    if (StringBuffer >= EndBuffer)                    {                        goto BufferOverflow;                    }                }                State = ASL_NORMAL_CHAR;                goto DoCharacter;                break;            }            /* Append another digit of the constant */            ConvertBuffer[i] = StringChar;            i++;            continue;        }        /* Save the finished character */        *StringBuffer = StringChar;        StringBuffer++;        if (StringBuffer >= EndBuffer)        {            goto BufferOverflow;        }    }    /*     * Premature End-Of-File     */    AslCommonError (ASL_ERROR, ASL_MSG_EARLY_EOF,                    Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,                    Gbl_CurrentLineOffset, Gbl_CurrentColumn,                    Gbl_Files[ASL_FILE_INPUT].Filename, NULL);    return (FALSE);CompletedString:    /*     * Null terminate the input string and copy string to a new buffer     */    *StringBuffer = 0;    CleanString = UtGetStringBuffer (strlen (MsgBuffer) + 1);    if (!CleanString)    {        AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION,                        Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,                        Gbl_CurrentLineOffset, Gbl_CurrentColumn,                        Gbl_Files[ASL_FILE_INPUT].Filename, NULL);        return (FALSE);    }    ACPI_STRCPY (CleanString, MsgBuffer);    AslCompilerlval.s = CleanString;    return (TRUE);BufferOverflow:    /* Literal was too long */    AslCommonError (ASL_ERROR, ASL_MSG_STRING_LENGTH,                    Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,                    Gbl_CurrentLineOffset, Gbl_CurrentColumn,                    Gbl_Files[ASL_FILE_INPUT].Filename, "Max length 4096");    return (FALSE);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -