39fbc92000-02-13Martin Stjernholm //! Variant of PXml that parses only entities.
5e5d862000-01-28Martin Stjernholm //! //! This parser is the default for arguments. //! //! Created 2000-01-28 by Martin Stjernholm. //!
2531fa2001-03-23Martin Stjernholm //! $Id: PEnt.pike,v 1.19 2001/03/23 22:49:42 mast Exp $
5e5d862000-01-28Martin Stjernholm 
d8769c2000-02-08Martin Stjernholm //#pragma strict_types // Disabled for now since it doesn't work well enough.
5e5d862000-01-28Martin Stjernholm 
cd7d5f2000-02-16Martin Stjernholm #include <config.h>
9f74bb2000-02-15Martin Stjernholm 
39fbc92000-02-13Martin Stjernholm inherit RXML.PXml;
5e5d862000-01-28Martin Stjernholm  // Block these to avoid confusion. constant add_tag = 0; constant add_tags = 0; constant add_container = 0; constant add_containers = 0;
9f74bb2000-02-15Martin Stjernholm static void init_entities() {
ca680b2001-03-01Martin Stjernholm  if (!type->entity_syntax) { // Don't decode normal entities if we're outputting xml-like stuff.
9f74bb2000-02-15Martin Stjernholm #ifdef OLD_RXML_COMPAT
cede492000-02-15Martin Stjernholm  clear_entities();
9f74bb2000-02-15Martin Stjernholm  if (not_compat) { #endif
2e0a6d2000-07-06Martin Stjernholm  add_entities (tag_set->get_string_entities());
9f74bb2000-02-15Martin Stjernholm #ifdef OLD_RXML_COMPAT } #endif } #ifdef OLD_RXML_COMPAT if (not_compat) #endif _set_entity_callback (.utils.p_xml_entity_cb); #ifdef OLD_RXML_COMPAT else _set_entity_callback (.utils.p_xml_compat_entity_cb); #endif } void reset (RXML.Context ctx, RXML.Type _type, RXML.TagSet _tag_set) { #ifdef DEBUG if (type != _type) error ("Internal error: Type change in reset().\n"); if (tag_set != _tag_set) error ("Internal error: Tag set change in reset().\n"); #endif
2531fa2001-03-23Martin Stjernholm  initialize (ctx, _type, _tag_set);
9f74bb2000-02-15Martin Stjernholm  #ifdef OLD_RXML_COMPAT
b6c3192000-03-04Martin Stjernholm  int new_not_compat = !(ctx && ctx->id && ctx->id->conf->old_rxml_compat);
9f74bb2000-02-15Martin Stjernholm  if (new_not_compat == not_compat) return; not_compat = new_not_compat; init_entities(); #endif }
5e5d862000-01-28Martin Stjernholm this_program clone (RXML.Context ctx, RXML.Type type, RXML.TagSet tag_set) {
9f74bb2000-02-15Martin Stjernholm #ifdef OLD_RXML_COMPAT
848c5b2000-03-16Martin Stjernholm  int new_not_compat = !(ctx && ctx->id && ctx->id->conf->old_rxml_compat); if (new_not_compat != not_compat) return this_program (ctx, type, tag_set);
9f74bb2000-02-15Martin Stjernholm #endif
848c5b2000-03-16Martin Stjernholm  return [object(this_program)] _low_clone (ctx, type, tag_set, 1);
5e5d862000-01-28Martin Stjernholm } static void create (
848c5b2000-03-16Martin Stjernholm  RXML.Context ctx, RXML.Type type, RXML.TagSet tag_set, void|int cloned)
5e5d862000-01-28Martin Stjernholm {
9f74bb2000-02-15Martin Stjernholm #ifdef OLD_RXML_COMPAT
b6c3192000-03-04Martin Stjernholm  not_compat = !(ctx && ctx->id && ctx->id->conf->old_rxml_compat);
9f74bb2000-02-15Martin Stjernholm #endif
2531fa2001-03-23Martin Stjernholm  initialize (ctx, type, tag_set);
5e5d862000-01-28Martin Stjernholm 
848c5b2000-03-16Martin Stjernholm  if (cloned) return;
0923e92000-02-08Martin Stjernholm 
9f74bb2000-02-15Martin Stjernholm  if (!type->free_text) { mixed_mode (1); _set_data_callback (.utils.return_empty_array); }
4703fd2000-02-11Martin Stjernholm  ignore_tags (1);
5e5d862000-01-28Martin Stjernholm  lazy_entity_end (1); match_tag (0);
9f74bb2000-02-15Martin Stjernholm  init_entities();
5e5d862000-01-28Martin Stjernholm } // These have no effect since we don't parse tags.
9f74bb2000-02-15Martin Stjernholm constant add_runtime_tag = 0; constant remove_runtime_tag = 0;
5e5d862000-01-28Martin Stjernholm  #ifdef OBJ_COUNT_DEBUG
da0c882000-03-18Martin Stjernholm string _sprintf() {
f232d02000-09-08Martin Stjernholm  return sprintf ("RXML.PEnt(%O,%O)%s", type, tag_set,
da0c882000-03-18Martin Stjernholm  __object_marker ? "[" + __object_marker->count + "]" : ""); }
5e5d862000-01-28Martin Stjernholm #else
da0c882000-03-18Martin Stjernholm string _sprintf() {
f232d02000-09-08Martin Stjernholm  return sprintf ("RXML.PEnt(%O,%O)", type, tag_set);
da0c882000-03-18Martin Stjernholm }
5e5d862000-01-28Martin Stjernholm #endif