File: xml_l.ll

package info (click to toggle)
xtide 2.9.5-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,996 kB
  • ctags: 2,141
  • sloc: cpp: 20,379; sh: 1,044; makefile: 224; yacc: 114; lex: 58
file content (95 lines) | stat: -rw-r--r-- 2,412 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*  $Id: xml_l.ll 2832 2007-12-01 01:05:01Z flaterco $

    xml_l.ll  Flex file for limited XML parser (just tags, no text).

    This is *NOT* a general-purpose XML parser.

    All things beginning with <! are treated as comments which are
    terminated by the next > character.  This means that you can't do
    the following (shown in the XML FAQ):

      <!DOCTYPE foo [
        <!ENTITY alephhb cdata "&#224;">
      ]>

    However, it should be possible to add a simple DOCTYPE declaration
    at such a time that I have a DTD:

      <!DOCTYPE xtide SYSTEM "xtide.dtd">

    Copyright (C) 1997  David Flater.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

/* Cleanup2006 Legacy Cruft CloseEnough */

%{

#include "common.hh"
#include "xmlparser.hh"
#include "xml_y.h"

/* Communicate autoconf result (HAVE_UNISTD_H) to flex/bison
   (YY_NO_UNISTD_H). */
#ifndef HAVE_UNISTD_H
#define YY_NO_UNISTD_H
#endif

unsigned lineno = 1;

%}

%%

\n	++lineno;

[ \t\r]+	;

"<?"[^\n]*"?>"	{ return XMLSTART; }

"<!"[^>]*">"	{ // Count lines consumed
                  for (unsigned a=0; a<strlen(yytext); ++a)
                    if (yytext[a] == '\n')
                      ++lineno; }

\"[^"\n]*\"	{ // Remove delimiting quotes
                  yylval.value = new Dstr (yytext+1);
                  (*yylval.value) -= (*yylval.value).length() - 1;
                  return ATTVALUE; }

"="	{ return '='; }

"/"	{ return '/'; }

">"	{ return '>'; }

"<"	{ return '<'; }

[a-zA-Z0-9:_]*	{ yylval.value = new Dstr (yytext);
                  return NAME; }

%%

int yywrap() {
  return 1;
}

void yyerror (constString s unusedParameter) {
  Dstr details ("Syntax error in XML file ");
  details += xmlfilename;
  details += " at line ";
  details += lineno;
  Global::barf (Error::XMLPARSE, details);
}