summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkitty <kitty@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2002-11-15 20:38:11 +0000
committerkitty <kitty@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2002-11-15 20:38:11 +0000
commitcaefcf03edab490c99228104501f99d04efdc36e (patch)
treeda75dea506757a38b639694ed9fef1e3a48bfa9e
parentaa7790e112469bd6560c249454c58b283cc05fdc (diff)
downloadATCD-caefcf03edab490c99228104501f99d04efdc36e.tar.gz
Removed ParserErrors.h
-rw-r--r--ACEXML/parser/parser/Parser.cpp133
-rw-r--r--ACEXML/parser/parser/Parser.h6
-rw-r--r--ACEXML/parser/parser/Parser.i10
-rw-r--r--ACEXML/parser/parser/ParserErrors.h93
4 files changed, 96 insertions, 146 deletions
diff --git a/ACEXML/parser/parser/Parser.cpp b/ACEXML/parser/parser/Parser.cpp
index c4da35f3260..655589ee2f9 100644
--- a/ACEXML/parser/parser/Parser.cpp
+++ b/ACEXML/parser/parser/Parser.cpp
@@ -30,6 +30,7 @@ ACEXML_Parser::ACEXML_Parser (void)
content_handler_ (0),
error_handler_ (0),
doctype_ (0),
+ current_ (0),
alt_stack_ (MAXPATHLEN),
nested_namespace_ (0),
ref_state_ (ACEXML_ParserInt::INVALID),
@@ -85,7 +86,7 @@ ACEXML_Parser::parse (ACEXML_InputSource *input ACEXML_ENV_ARG_DECL)
}
// Set up Locator.
if (this->content_handler_)
- this->content_handler_->setDocumentLocator (this->current_.getLocator());
+ this->content_handler_->setDocumentLocator (this->current_->getLocator());
int xmldecl_defined = 0;
ACEXML_Char fwd = this->get(); // Consume '<'
@@ -322,6 +323,8 @@ ACEXML_Parser::parse_internal_dtd (ACEXML_ENV_SINGLE_ARG_DECL)
{
this->ref_state_ = ACEXML_ParserInt::IN_INT_DTD;
ACEXML_Char nextch = this->skip_whitespace ();
+ int nrelems = 0;
+ ACEXML_String reference;
do {
switch (nextch)
{
@@ -354,9 +357,25 @@ ACEXML_Parser::parse_internal_dtd (ACEXML_ENV_SINGLE_ARG_DECL)
ACEXML_ENV_ARG_PARAMETER);
ACEXML_CHECK_RETURN (-1);
case 0:
- this->fatal_error (ACE_TEXT ("Unexpected end-of-file")
- ACEXML_ENV_ARG_PARAMETER);
- ACEXML_CHECK_RETURN (-1);
+ nrelems = this->pop_context();
+ if (this->PE_reference_.pop (reference) < 0)
+ {
+ this->fatal_error (ACE_TEXT ("Internal Parser Error")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ if (nrelems >= 1)
+ {
+ if (this->external_entity_)
+ this->external_entity_--;
+ break;
+ }
+ else
+ {
+ this->fatal_error(ACE_TEXT ("Unexpected end-of-file")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
default:
this->fatal_error (ACE_TEXT ("Invalid content in internal subset")
ACEXML_ENV_ARG_PARAMETER);
@@ -375,6 +394,7 @@ ACEXML_Parser::parse_external_subset (ACEXML_ENV_SINGLE_ARG_DECL)
this->ref_state_ = ACEXML_ParserInt::IN_EXT_DTD;
this->external_subset_ = 1;
int nrelems = 0;
+ ACEXML_String reference;
ACEXML_Char nextch = this->skip_whitespace();
do {
switch (nextch)
@@ -411,16 +431,28 @@ ACEXML_Parser::parse_external_subset (ACEXML_ENV_SINGLE_ARG_DECL)
break;
case 0:
nrelems = this->pop_context();
+ if (this->PE_reference_.pop (reference) < 0)
+ {
+ this->fatal_error (ACE_TEXT ("Internal Parser Error")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
if (nrelems > 1)
- break;
+ {
+ if (this->external_entity_)
+ this->external_entity_--;
+ break;
+ }
else if (nrelems == 1)
{
+ if (this->external_entity_)
+ this->external_entity_--;
this->external_subset_ = 0;
return 0;
}
else
{
- this->fatal_error(ACE_TEXT ("Internal Parser Error")
+ this->fatal_error(ACE_TEXT ("Unexpected end-of-file")
ACEXML_ENV_ARG_PARAMETER);
ACEXML_CHECK_RETURN (-1);
}
@@ -642,15 +674,7 @@ ACEXML_Parser::parse_markup_decl (ACEXML_ENV_SINGLE_ARG_DECL)
this->fatal_error (ACE_TEXT ("Unexpected end-of-file")
ACEXML_ENV_ARG_PARAMETER);
ACEXML_CHECK_RETURN (-1);
- case '%':
- if (this->external_subset_)
- {
- this->parse_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
- ACEXML_CHECK_RETURN (-1);
- break;
- }
- // Fall through
- default:
+ default:
this->fatal_error (ACE_TEXT ("Invalid markupDecl")
ACEXML_ENV_ARG_PARAMETER);
ACEXML_CHECK_RETURN (-1);
@@ -733,7 +757,7 @@ ACEXML_Parser::normalize_systemid (const char* systemId)
else
{
ACEXML_Char* normalized_uri = 0;
- const char* baseURI = this->current_.getLocator()->getSystemId();
+ const char* baseURI = this->current_->getLocator()->getSystemId();
if (!baseURI)
return 0;
if (ACE_OS::strstr (baseURI, ACE_TEXT ("http://")) != 0)
@@ -946,13 +970,21 @@ ACEXML_Parser::parse_content (const ACEXML_Char* startname,
case 0:
nrelems = this->pop_context();
if (nrelems >= 1)
- break;
+ {
+ if (this->external_entity_)
+ this->external_entity_--;
+ break;
+ }
else if (nrelems == 0)
- return 0;
+ {
+ if (this->external_entity_)
+ this->external_entity_--;
+ return 0;
+ }
else
{
- this->fatal_error(ACE_TEXT ("Internal Parser Error")
- ACEXML_ENV_ARG_PARAMETER);
+ this->fatal_error(ACE_TEXT ("Unexpected end-of-file")
+ ACEXML_ENV_ARG_PARAMETER);
ACEXML_CHECK_RETURN (-1);
}
case '<':
@@ -1396,6 +1428,7 @@ ACEXML_Parser::parse_attlist_decl (ACEXML_ENV_SINGLE_ARG_DECL)
ACEXML_Char fwd;
int count = this->skip_whitespace_count(&fwd);
int nrelems = 0;
+ ACEXML_String reference;
// Parse AttDef*
while (fwd != '>')
{
@@ -1408,6 +1441,7 @@ ACEXML_Parser::parse_attlist_decl (ACEXML_ENV_SINGLE_ARG_DECL)
switch (fwd)
{
case '%':
+ this->get();
if (this->external_subset_)
{
this->parse_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
@@ -1415,13 +1449,20 @@ ACEXML_Parser::parse_attlist_decl (ACEXML_ENV_SINGLE_ARG_DECL)
}
break;
case 0:
+ this->get();
nrelems = this->pop_context();
+ if (this->PE_reference_.pop (reference) < 0)
+ {
+ this->fatal_error (ACE_TEXT ("Internal Parser Error")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
if (nrelems >= 1)
break;
else
{
- this->fatal_error(ACE_TEXT ("Internal Parser Error")
- ACEXML_ENV_ARG_PARAMETER);
+ this->fatal_error(ACE_TEXT ("Unexpected end-of-file")
+ ACEXML_ENV_ARG_PARAMETER);
ACEXML_CHECK_RETURN (-1);
}
default:
@@ -1526,6 +1567,10 @@ ACEXML_Parser::parse_defaultdecl (ACEXML_ENV_SINGLE_ARG_DECL)
}
// @@ set up validator
break;
+ case '%':
+ this->parse_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
default:
this->fatal_error (ACE_TEXT ("Invalid DefaultDecl")
ACEXML_ENV_ARG_PARAMETER);
@@ -2073,7 +2118,7 @@ ACEXML_Parser::parse_attvalue (ACEXML_Char *&str ACEXML_ENV_ARG_DECL)
str = temp;
return 0;
}
- switch (ch)
+ switch (ch)
{
case '&':
if (this->peek () == '#')
@@ -2106,8 +2151,8 @@ ACEXML_Parser::parse_attvalue (ACEXML_Char *&str ACEXML_ENV_ARG_DECL)
break;
else
{
- this->fatal_error(ACE_TEXT ("Internal Parser Error")
- ACEXML_ENV_ARG_PARAMETER);
+ this->fatal_error(ACE_TEXT ("Unexpected end-of-file")
+ ACEXML_ENV_ARG_PARAMETER);
ACEXML_CHECK_RETURN (-1);
}
default:
@@ -2180,11 +2225,11 @@ ACEXML_Parser::parse_entity_reference (ACEXML_ENV_SINGLE_ARG_DECL)
ACEXML_ENV_ARG_PARAMETER);
ACEXML_CHECK_RETURN (-1);
}
- this->external_entity_ = 1;
+ this->external_entity_++;
}
// [WFC: No Recursion]
- int present = this->GE_reference_.insert (entity);
+ int present = this->GE_reference_.insert (replace);
if (present == 1 || present == -1)
{
ACEXML_String ref_name;
@@ -2288,7 +2333,7 @@ ACEXML_Parser::parse_PE_reference (ACEXML_ENV_SINGLE_ARG_DECL)
ACEXML_ENV_ARG_PARAMETER);
ACEXML_CHECK_RETURN (-1);
}
- this->external_entity_ = 1;
+ this->external_entity_++;
}
// [WFC: No Recursion]
@@ -2447,13 +2492,13 @@ ACEXML_Parser::parse_entity_value (ACEXML_Char *&str
if (nrelems >= 1)
{
if (this->external_entity_)
- this->external_entity_ = 0;
+ this->external_entity_--;
break;
}
else
{
- this->fatal_error(ACE_TEXT ("Internal Parser Error")
- ACEXML_ENV_ARG_PARAMETER);
+ this->fatal_error(ACE_TEXT ("Unexpected end-of-file")
+ ACEXML_ENV_ARG_PARAMETER);
ACEXML_CHECK_RETURN (-1);
}
default:
@@ -2687,28 +2732,27 @@ ACEXML_Parser::switch_input (ACEXML_InputSource* input,
const ACEXML_Char* publicId)
{
ACEXML_LocatorImpl* locator = 0;
- if (!systemId && this->current_.getLocator())
+ if (!systemId && this->current_ && this->current_->getLocator())
locator = ACE_const_cast (ACEXML_LocatorImpl*,
- this->current_.getLocator());
+ this->current_->getLocator());
if (!locator)
ACE_NEW_RETURN (locator, ACEXML_LocatorImpl (systemId, publicId), -1);
ACEXML_Parser_Context* new_context = 0;
ACE_NEW_RETURN (new_context, ACEXML_Parser_Context(input, locator), -1);
- if (this->push_context (*new_context) != 0)
+ if (this->push_context (new_context) != 0)
{
ACE_ERROR ((LM_ERROR, "Unable to switch input streams"));
return -1;
}
- this->current_.reset();
- this->current_ = *new_context;
+ this->current_ = new_context;
// Set up Locator.
if (this->content_handler_)
- this->content_handler_->setDocumentLocator (this->current_.getLocator());
+ this->content_handler_->setDocumentLocator (this->current_->getLocator());
return 0;
}
int
-ACEXML_Parser::push_context (const ACEXML_Parser_Context& context)
+ACEXML_Parser::push_context (ACEXML_Parser_Context* context)
{
if (this->ctx_stack_.push (context) < 0)
{
@@ -2721,16 +2765,16 @@ ACEXML_Parser::push_context (const ACEXML_Parser_Context& context)
int
ACEXML_Parser::pop_context (void)
{
- this->current_.reset();
- int retval = this->ctx_stack_.pop (this->current_);
+ ACEXML_Parser_Context* temp = 0;
+ int retval = this->ctx_stack_.pop (temp);
if (retval != 0)
return -1;
- this->current_.reset();
+ delete temp;
if (this->ctx_stack_.top (this->current_) != 0)
return -1;
// Set up Locator.
if (this->content_handler_)
- this->content_handler_->setDocumentLocator (this->current_.getLocator());
+ this->content_handler_->setDocumentLocator (this->current_->getLocator());
return this->ctx_stack_.size();
}
@@ -2870,7 +2914,7 @@ ACEXML_Parser::parse_encoding_decl (ACEXML_ENV_SINGLE_ARG_DECL)
ACEXML_ENV_ARG_PARAMETER);
ACEXML_CHECK;
}
- const ACEXML_Char* encoding = this->current_.getInputSource()->getEncoding();
+ const ACEXML_Char* encoding = this->current_->getInputSource()->getEncoding();
if (ACE_OS::strcmp (astring, encoding) != 0)
{
ACE_ERROR ((LM_ERROR, ACE_TEXT ("Detected Encoding is %s "
@@ -3057,10 +3101,9 @@ ACEXML_Parser::parse_processing_instruction (ACEXML_ENV_SINGLE_ARG_DECL)
void
ACEXML_Parser::reset (void)
{
- this->current_.reset();
if (this->ctx_stack_.pop (this->current_) != -1)
ACE_ERROR ((LM_ERROR, ACE_TEXT ("Mismatched push/pop of Context stack")));
- this->current_.reset();
+ delete this->current_;
ACEXML_String temp;
while (this->GE_reference_.pop (temp) != -1)
;
diff --git a/ACEXML/parser/parser/Parser.h b/ACEXML/parser/parser/Parser.h
index 28eb2359ea3..78668332caa 100644
--- a/ACEXML/parser/parser/Parser.h
+++ b/ACEXML/parser/parser/Parser.h
@@ -687,7 +687,7 @@ private:
* Push the current context on to the stack.
*
*/
- int push_context (const ACEXML_Parser_Context& context);
+ int push_context (ACEXML_Parser_Context* context);
/**
* Pop the top element in the stack and replace current context with that.
@@ -771,10 +771,10 @@ private:
ACEXML_Char *doctype_;
/// Current parser context
- ACEXML_Parser_Context current_;
+ ACEXML_Parser_Context* current_;
/// Stack used to hold the Parser_Context
- ACE_Unbounded_Stack<ACEXML_Parser_Context> ctx_stack_;
+ ACE_Unbounded_Stack<ACEXML_Parser_Context*> ctx_stack_;
/*
* The following two are essentially chains of references and is used by
diff --git a/ACEXML/parser/parser/Parser.i b/ACEXML/parser/parser/Parser.i
index e03f09c2116..dd6231c8a90 100644
--- a/ACEXML/parser/parser/Parser.i
+++ b/ACEXML/parser/parser/Parser.i
@@ -206,12 +206,12 @@ ACEXML_INLINE ACEXML_Char
ACEXML_Parser::get (void)
{
ACEXML_Char ch = 0;
- const ACEXML_InputSource* ip = this->current_.getInputSource();
+ const ACEXML_InputSource* ip = this->current_->getInputSource();
ACEXML_CharStream* instream = ip->getCharStream();
if (instream->get (ch) != -1)
{
- this->current_.getLocator()->incrColumnNumber();
+ this->current_->getLocator()->incrColumnNumber();
// Normalize white-space
if (ch == '\x0D')
{
@@ -222,8 +222,8 @@ ACEXML_Parser::get (void)
if (ch == '\x0A')
{
// Reset column number and increment Line Number.
- this->current_.getLocator()->incrLineNumber();
- this->current_.getLocator()->setColumnNumber (0);
+ this->current_->getLocator()->incrLineNumber();
+ this->current_->getLocator()->setColumnNumber (0);
}
return ch;
}
@@ -236,7 +236,7 @@ ACEXML_Parser::peek (void)
// Using an extra level of indirection so we can
// manage document location in the future.
ACEXML_Char ch = 0;
- const ACEXML_InputSource* ip = this->current_.getInputSource();
+ const ACEXML_InputSource* ip = this->current_->getInputSource();
ACEXML_CharStream* instream = ip->getCharStream();
ch = instream->peek ();
return (ch == -1 ? 0 : ch);
diff --git a/ACEXML/parser/parser/ParserErrors.h b/ACEXML/parser/parser/ParserErrors.h
deleted file mode 100644
index 6bb3435139a..00000000000
--- a/ACEXML/parser/parser/ParserErrors.h
+++ /dev/null
@@ -1,93 +0,0 @@
-// -*- C++ -*-
-
-//=============================================================================
-/**
- * @file ParserErrors.h
- *
- * $Id$
- *
- * @author Krishnakumar B <kitty@cs.wustl.edu>
- */
-//=============================================================================
-
-#ifndef _ACEXML_PARSER_ERRORS_H_
-#define _ACEXML_PARSER_ERRORS_H_
-
-#include "ace/pre.h"
-#include "ACEXML/parser/parser/Parser_export.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-#pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-enum ACEXML_Error {
- ACEXML_INVIP,
- ACEXML_LESS,
- ACEXML_GREAT,
- ACEXML_INVCO,
- ACEXML_DUPDOC,
- ACEXML_EOF,
- ACEXML_INVXMLDECL,
- ACEXML_INVVERSION,
- ACEXML_ENOTSUP,
- ACEXML_ENCMISMATCH,
- ACEXML_EINT,
- ACEXML_INVPI,
- ACEXML_INVDOCKEYWORD,
- ACEXML_INVDOCNAME,
- ACEXML_MISSINGROOT,
- ACEXML_RDATTR,
- ACEXML_DUPPREFIX,
- ACEXML_DUPATTR,
- ACEXML_NSERR,
- ACEXML_ECHAR,
- ACEXML_ETAG,
- ACEXML_ECDATASEC,
- ACEXML_MKDECLKEYWORD,
- ACEXML_MKINVCH,
- ACEXML_MKDECL,
- ACEXML_EELEMENT,
- ACEXML_ERDELENAME,
- ACEXML_EEMPTY,
- ACEXML_EANY,
- ACEXML_ERDELE,
- ACEXML_EENTITY,
- ACEXML_INVREF,
- ACEXML_ENTNAME,
- ACEXML_ENTVALUE,
- ACEXML_DUPENT,
- ACEXML_INVEXTID,
- ACEXML_UNDATA,
- ACEXML_ENDATA,
- ACEXML_EATTLIST,
- ACEXML_EATTNAME,
- ACEXML_ECDATA,
- ACEXML_EID,
- ACEXML_EENTITIES,
- ACEXML_ENMTOKEN,
- ACEXML_ENMTOKENS,
- ACEXML_ENOTATION,
- ACEXML_LPAREN,
- ACEXML_ENOTNAME,
- ACEXML_ENMNAME,
- ACEXML_INVATTRTYPE,
- ACEXML_EREQUIRED,
- ACEXML_EIMPLIED,
- ACEXML_EFIXED,
- ACEXML_EINVFIXED,
- ACEXML_INVNOTNAME,
- ACEXML_ESYSTEM,
- ACEXML_EPUBLIC,
- ACEXML_ELITERAL,
- ACEXML_ESYSPUB,
- ACEXML_EPCDATA,
- ACEXML_EMIXED,
- ACEXML_ERPAREN,
- ACEXML_ESUBELE,
- ACEXML_ECHOICE,
- ACEXML_INVCHAR
-};
-
-#include "ace/post.h"
-
-#endif /* _ACEXML_PARSER_ERRORS_H_ */