first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / core / library / textual / xml_parser.cpp
1 /*****************************************************************************\
2 *                                                                             *
3 *  Name   : xml_parser                                                        *
4 *  Author : Chris Koeritz                                                     *
5 *                                                                             *
6 *******************************************************************************
7 * Copyright (c) 2007-$now By Author.  This program is free software; you can  *
8 * redistribute it and/or modify it under the terms of the GNU General Public  *
9 * License as published by the Free Software Foundation; either version 2 of   *
10 * the License or (at your option) any later version.  This is online at:      *
11 *     http://www.fsf.org/copyleft/gpl.html                                    *
12 * Please send any updates to: fred@gruntose.com                               *
13 \*****************************************************************************/
14
15 #include "xml_parser.h"
16
17 #include <basis/astring.h>
18 #include <structures/string_table.h>
19
20 using namespace basis;
21 using namespace structures;
22
23 namespace textual {
24
25 xml_parser::xml_parser(const astring &to_parse)
26 {
27   if (!to_parse) {}
28 }
29
30 xml_parser::~xml_parser()
31 {
32 }
33
34 const char *xml_parser::outcome_name(const outcome &to_name)
35 {
36   return common::outcome_name(to_name);
37 }
38
39 void xml_parser::reset(const astring &to_parse)
40 {
41   if (!to_parse) {}
42 }
43
44 outcome xml_parser::header_callback(astring &header_name,
45     string_table &attributes)
46 {
47   if (!header_name || !attributes.symbols()) {}
48   return common::OKAY; 
49 }
50
51
52 outcome xml_parser::tag_open_callback(astring &tag_name,
53     string_table &attributes)
54 {
55   if (!tag_name || !attributes.symbols()) {}
56   return OKAY;
57 }
58
59 outcome xml_parser::tag_close_callback(astring &tag_name)
60 {
61   if (!tag_name) {}
62   return OKAY;
63 }
64
65 outcome xml_parser::content_callback(astring &content)
66 {
67   if (!content) {}
68   return OKAY;
69 }
70
71 outcome xml_parser::parse()
72 {
73
74 //phases: we are initially always seeking a bracket bounded tag of some sort.
75
76 // the first few constructs must be headers, especially the xml header.
77
78 // is it true that headers are the only valid thing to see before real tags
79 //   start, or can there be raw content embedded in there?
80 // yes, it seems to be true in mozilla.  you can't have bare content in
81 // between the headers and the real tags.
82
83 // actually, if we allow the file to not start with the xml header and
84 //   version, then that's a bug.
85
86 // need function to accumulate the tag based on structure.  do headers
87 //   have to have a ? as part of the inner and outer structure?
88
89 // test against mozilla to ensure we are seeing the same things; get
90 //   together some tasty sample files.
91
92 // count lines and chars so we can report where it tanked.
93
94 // back to phases, (not a precise grammar below)
95 //   white_space ::= [ ' ' '\n' '\r' '\t' ] *
96 //   ws ::= white_space
97 //   text_phrase ::= not_white_space_nor_reserved not_reserved*
98 //   name ::= text_phrase
99 //   value ::= not_reserved *
100 //   lt_char ::= '<'
101 //   quote ::= '"'
102
103 //   xml_file ::= header+ ws tagged_unit+ ws
104 //   header ::= '<' '?' name ws attrib_list ws '?' '>' ws
105 //   tagged_unit ::= open_tag content* close_tag ws
106 //   content ::= [ tagged_unit | text_phrase ] + ws
107 //   open_tag ::= '<' name ws attrib_list ws '>' ws
108 //   attrib_list ::= ( attribute ws ) * ws
109 //   attribute ::= name ws '=' ws quoted_string ws
110 //   quoted_string ::= '"' not_lt_char_nor_quote '"' ws
111 //   close_tag :: '<' '/' name ws '>' ws 
112
113 //write a recursive descent parser on this grammar and spit out the 
114 //   productions as callbacks, at least for the major ones already listed.
115
116 return common::NOT_IMPLEMENTED;
117 }
118
119 /* callbacks to invoke.
120 outcome header_callback(astring &header_name, string_table &attributes)
121 outcome tag_open_callback(astring &tag_name, string_table &attributes)
122 outcome tag_close_callback(astring &tag_name)
123 outcome content_callback(astring &content)
124 */
125
126 } //namespace.
127