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

📄 parser.cpp

📁 ACE自适配通信环境(ADAPTIVE Communication Environment)是可以自由使用、开放源码的面向对象(OO)框架(Framework)
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    {      // We have atleast one whitespace. So just skip any more whitespaces      // and return the count      this->skip_whitespace_count();      return count;    }  return this->skip_whitespace_count();}ACEXML_Char*ACEXML_Parser::parse_attname (ACEXML_ENV_SINGLE_ARG_DECL)  ACE_THROW_SPEC ((ACEXML_SAXException)){  // Parse attribute name  ACEXML_Char *att_name = this->parse_name ();  if (att_name == 0)    {      this->fatal_error(ACE_TEXT ("Invalid AttName")                        ACEXML_ENV_ARG_PARAMETER);      ACEXML_CHECK_RETURN (0);    }  return att_name;}intACEXML_Parser::parse_defaultdecl (ACEXML_ENV_SINGLE_ARG_DECL)  ACE_THROW_SPEC ((ACEXML_SAXException)){  // DefaultDecl ::=  '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue)  ACEXML_Char nextch = this->peek ();  ACEXML_Char *fixed_attr = 0;  switch (nextch)    {      case '#':        this->get ();         // consume the '#'        switch (this->get ())          {            case 'R':              if (this->parse_token (ACE_TEXT ("EQUIRED")) < 0)                {                  this->fatal_error(ACE_TEXT ("Expecting keyword REQUIRED")                                    ACEXML_ENV_ARG_PARAMETER);                  ACEXML_CHECK_RETURN (-1);                }              // We now know this attribute is required              // @@ Set up the validator as such.              break;            case 'I':              if (this->parse_token (ACE_TEXT ("MPLIED")) < 0)                {                  this->fatal_error(ACE_TEXT ("Expecting keyword IMPLIED")                                    ACEXML_ENV_ARG_PARAMETER);                  ACEXML_CHECK_RETURN (-1);                }              // We now know this attribute is implied.              // @@ Set up the validator as such.              break;            case 'F':              if (this->parse_token (ACE_TEXT ("IXED")) < 0 ||                  this->skip_whitespace_count () == 0)                {                  this->fatal_error(ACE_TEXT ("Expecting keyword FIXED")                                    ACEXML_ENV_ARG_PARAMETER);                  ACEXML_CHECK_RETURN (-1);                }              // We now know this attribute is fixed.              if (this->parse_attvalue (fixed_attr                                        ACEXML_ENV_ARG_PARAMETER) != 0)                {                  this->fatal_error(ACE_TEXT ("Invalid Default AttValue")                                    ACEXML_ENV_ARG_PARAMETER);                  ACEXML_CHECK_RETURN (-1);                }              // @@ set up validator              break;            default:              this->fatal_error (ACE_TEXT ("Invalid DefaultDecl")                                 ACEXML_ENV_ARG_PARAMETER);              ACEXML_CHECK_RETURN (-1);          }        break;      case '\'':      case '"':        if (this->parse_attvalue (fixed_attr ACEXML_ENV_ARG_PARAMETER) != 0)          {            this->fatal_error(ACE_TEXT ("Invalid AttValue")                              ACEXML_ENV_ARG_PARAMETER);            ACEXML_CHECK_RETURN (-1);          }        // @@ set up validator        break;      default:        this->fatal_error (ACE_TEXT ("Invalid DefaultDecl")                           ACEXML_ENV_ARG_PARAMETER);        ACEXML_CHECK_RETURN (-1);        break;    }  return 0;}intACEXML_Parser::parse_tokenized_type (ACEXML_ENV_SINGLE_ARG_DECL)  ACE_THROW_SPEC ((ACEXML_SAXException)){  ACEXML_Char ch = this->get();  switch (ch)    {      case 'I':        if (this->get () == 'D')          {            if (this->peek() != 'R' && this->is_whitespace (this->peek()))              {                // We have successfully identified the type of the                // attribute as ID                // @@ Set up validator as such.                break;              }            if (this->parse_token (ACE_TEXT ("REF")) == 0)              {                if (this->peek() != 'S' && this->is_whitespace (this->peek()))                  {                    // We have successfully identified the type of                    // the attribute as IDREF                    // @@ Set up validator as such.                    break;                  }                else if (this->peek() == 'S'                         && this->get() // consume the 'S'                         && this->is_whitespace (this->peek()))                  {                    // We have successfully identified the type of                    // the attribute as IDREFS                    // @@ Set up validator as such.                    break;                  }              }          }        // Admittedly, this error message is not precise enough        this->fatal_error(ACE_TEXT ("Expecting keyword `ID', `IDREF', or")                          ACE_TEXT ("`IDREFS'") ACEXML_ENV_ARG_PARAMETER);        ACEXML_CHECK_RETURN (-1);      case 'E':               // ENTITY or ENTITIES        if (this->parse_token (ACE_TEXT ("NTIT")) == 0)          {            ACEXML_Char nextch = this->get ();            if (nextch == 'Y')              {                // We have successfully identified the type of                // the attribute as ENTITY                // @@ Set up validator as such.              }            else if (this->parse_token (ACE_TEXT ("IES")) == 0)              {                // We have successfully identified the type of                // the attribute as ENTITIES                // @@ Set up validator as such.              }            if (this->is_whitespace (this->peek()))              {                // success                break;              }          }        // Admittedly, this error message is not precise enough        this->fatal_error(ACE_TEXT ("Expecting keyword `ENTITY', or")                          ACE_TEXT ("`ENTITIES'") ACEXML_ENV_ARG_PARAMETER);        ACEXML_CHECK_RETURN (-1);      case 'M':        if (this->parse_token (ACE_TEXT ("TOKEN")) == 0)          {            if (this->is_whitespace (this->peek()))              {                // We have successfully identified the type of                // the attribute as NMTOKEN                // @@ Set up validator as such.                break;              }            else if (this->peek() == 'S'                     && this->get()                     && this->is_whitespace (this->peek()))              {                // We have successfully identified the type of                // the attribute as NMTOKENS                // @@ Set up validator as such.                break;              }          }        this->fatal_error(ACE_TEXT ("Expecting keyword `NMTOKEN' or `NMTO")                          ACE_TEXT ("KENS'") ACEXML_ENV_ARG_PARAMETER);        ACEXML_CHECK_RETURN (-1);        break;      default:        this->fatal_error (ACE_TEXT ("Internal Parser Error")                           ACEXML_ENV_ARG_PARAMETER);        ACEXML_CHECK_RETURN (-1);        break;    }  return 0;}/** * AttType    ::=    StringType | TokenizedType | EnumeratedType * StringType ::=    'CDATA' * TokenizedType    ::=    'ID'       [VC: ID] *                                    [VC: One ID per Element Type] *                                    [VC: ID Attribute Default] *                       | 'IDREF' [VC: IDREF] *                       | 'IDREFS' [VC: IDREF] *                       | 'ENTITY' [VC: Entity Name] *                       | 'ENTITIES' [VC: Entity Name] *                       | 'NMTOKEN' [VC: Name Token] *                       | 'NMTOKENS' * * EnumeratedType  ::=    NotationType | Enumeration * NotationType    ::=   'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')' *                                  [VC: Notation Attributes] *                                  [VC: One Notation Per Element Type] *                                  [VC: No Notation on Empty Element] * Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')' *                                  [VC: Enumeration] */intACEXML_Parser::parse_atttype (ACEXML_ENV_SINGLE_ARG_DECL)  ACE_THROW_SPEC ((ACEXML_SAXException)){  ACEXML_Char nextch = this->peek();  switch (nextch)    {      case 'C':               // CDATA        if (this->parse_token (ACE_TEXT ("CDATA")) < 0)          {            this->fatal_error(ACE_TEXT ("Expecting keyword 'CDATA'")                              ACEXML_ENV_ARG_PARAMETER);            ACEXML_CHECK_RETURN (-1);          }        // Else, we have successfully identified the type of the        // attribute as CDATA        // @@ Set up validator appropriately here.        break;      case 'I': case 'E':      // ID, IDREF, IDREFS, ENTITY or ENTITIES        this->parse_tokenized_type (ACEXML_ENV_SINGLE_ARG_PARAMETER);        ACEXML_CHECK_RETURN (-1);        break;      case 'N':             // NMTOKEN, NMTOKENS, or NOTATION        this->get();        nextch = this->peek();        if (nextch != 'M' && nextch != 'O')          {            this->fatal_error (ACE_TEXT ("Expecting keyword 'NMTOKEN', ")                               ACE_TEXT ("'NMTOKENS' or 'NOTATION'")                               ACEXML_ENV_ARG_PARAMETER);            ACEXML_CHECK_RETURN (-1);          }        if (nextch == 'M')          {            this->parse_tokenized_type (ACEXML_ENV_SINGLE_ARG_PARAMETER);            ACEXML_CHECK_RETURN (-1);            break;          }        else                   // NOTATION          {            if (this->parse_token (ACE_TEXT ("OTATION")) < 0)              {                this->fatal_error(ACE_TEXT ("Expecting keyword `NOTATION'")                                  ACEXML_ENV_ARG_PARAMETER);                ACEXML_CHECK_RETURN (-1);              }            int count = this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);            ACEXML_CHECK_RETURN (-1);            if (!count)              {                this->fatal_error (ACE_TEXT ("Expecting space between keyword ")                                   ACE_TEXT ("NOTATION and '('")                                   ACEXML_ENV_ARG_PARAMETER);                ACEXML_CHECK_RETURN (-1);              }            if (this->get () != '(')              {                this->fatal_error(ACE_TEXT ("Expecting '(' in NotationType")                                  ACEXML_ENV_ARG_PARAMETER);                ACEXML_CHECK_RETURN (-1);              }            this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);            ACEXML_CHECK_RETURN (-1);            do {              this->skip_whitespace_count();              ACEXML_Char *notation_name = this->parse_name ();              if (notation_name == 0)                {                  this->fatal_error(ACE_TEXT ("Invalid notation name")                                    ACEXML_ENV_ARG_PARAMETER);                  ACEXML_CHECK_RETURN (-1);                }              // @@ get another notation name, set up validator as such              this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);              ACEXML_CHECK_RETURN (-1);              nextch = this->get();            } while (nextch == '|');            if (nextch != ')')              {                this->fatal_error (ACE_TEXT ("Expecting a ')' after a ")                                   ACE_TEXT ("NotationType declaration")                                   ACEXML_ENV_ARG_PARAMETER);                ACEXML_CHECK_RETURN (-1);              }          }        break;      case '(':               // EnumeratedType - Enumeration        this->get();        this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);        ACEXML_CHECK_RETURN (-1);        do {          this->skip_whitespace_count();          ACEXML_Char *token_name = this->parse_nmtoken ();          if (token_name == 0)            {              this->fatal_error(ACE_TEXT ("Invalid enumeration name")                                ACEXML_ENV_ARG_PARAMETER);              ACEXML_CHECK_RETURN (-1);            }          // @@ get another nmtoken, set up validator as such          this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);          ACEXML_CHECK_RETURN (-1);          nextch = this->get();        } while (nextch == '|');        if (nextch != ')')          {            this->fatal_error (ACE_TEXT ("Expecting a ')' after a ")                               ACE_TEXT ("Enumeration declaration")                               ACEXML_ENV_ARG_PARAMETER);            ACEXML_CHECK_RETURN (-1);          }        break;      default:        {          this->fatal_error(ACE_TEXT ("Invalid AttType")                            ACEXML_ENV_ARG_PARAMETER);          ACEXML_CHECK_RETURN (-1);        }        ACE_NOTREACHED (break);    }  return 0;}intACEXML_Parser::parse_notation_decl (ACEXML_ENV_SINGLE_ARG_DECL)  ACE_THROW_SPEC ((ACEXML_SAXException)){  if (this->parse_token (ACE_TEXT ("NOTATION")) < 0)    {      this->fatal_error(ACE_TEXT ("Expecting Keyword 'NOTATION'")                        ACEXML_ENV_ARG_PARAMETER);      ACEXML_CHECK_RETURN (-1);    }  int count = this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);  ACEXML_CHECK_RETURN (-1);  if (!count)    {      this->fatal_error (ACE_TEXT ("Expecting a space between keyword NOTATION")                         ACE_TEXT (" and notation name")                         ACEXML_ENV_ARG_PARAMETER);      ACEXML_CHECK_RETURN (-1);    }  ACEXML_Char *notation = this->parse_name ();  if (notation == 0)    {      this->fatal_error(ACE_TEXT ("Invalid Notation name")                        ACEXML_ENV_ARG_PARAMETER);      ACEXML_CHECK_RETURN (-1);    }  count = this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);

⌨️ 快捷键说明

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