Update of /cvsroot/flexml/flexml
In directory sc8-pr-cvs17:/tmp/cvs-serv730
Modified Files:
flexml.pl
Log Message:
Let's be a bit more serious about detecting misplaced begining tags. Previous commit was a disaster, this one is tested (sorry)
Index: flexml.pl
===================================================================
RCS file: /cvsroot/flexml/flexml/flexml.pl,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- flexml.pl 11 Oct 2007 10:00:14 -0000 1.62
+++ flexml.pl 11 Oct 2007 14:46:08 -0000 1.63
@@ -95,6 +95,7 @@
my %roottags = (); # Tags that may be the root tag.
my %ctag = (); # C variable name of each tag.
+my %allstates = (); # all existing states are key of this hash
my %states = (); # $states{tag} is list of states used by tag element.
my %emptytrans = (); # $emptytrans{state} contains empty transitions in automaton.
@@ -425,8 +426,10 @@
# true if it may be empty. Uses global $statecounter.
my ($tag,$re,$in,$out) = @_;
+ $allstates{$in} = 1;
+ $allstates{$out} = 1;
- #print "analysechildren [ $tag, $re, $in, $out ] \n";
+ print "analysechildren [ $tag, $re, $in, $out ] \n" if $debug;
local $_ = $re;
@@ -1056,6 +1059,13 @@
$$h{$k} =~ s/>S_/>S_${tagprefix}/g;
}
}
+ my %tmp = ();
+ foreach $k (keys %allstates) {
+ $k =~ s/^E_/E_${tagprefix}/;
+ $k =~ s/^S_/S_${tagprefix}/;
+ $tmp{$k} = 1;
+ }
+ %allstates = %tmp;
}
# Debugging: show DTD representation.
@@ -1369,6 +1379,24 @@
$exitswitch .= " }\n";
}
+ # Misplaced start or empty tag
+ unless ($nofail) {
+ print "\n";
+ my %ins = ();
+ foreach (keys %allstates) {
+ $ins{$_} = 'false';
+ }
+ if (exists $instates{$tag}) {
+ for (split /,/,$instates{$tag}) { $ins{$_} = 'true'; }
+ }
+ $ins{"ROOT_${tagprefix}$myctag"} = $roottags{$tag} ? 'true' : 'false';
+ my $str = '<' . join(',', grep {$ins{$_} eq 'false'} keys %ins);
+ if ($str ne '<') {
+ print "$str>\"<$tag\"{s} FAIL(\"Starting tag <$tag> is not allowed here.\");\n";
+ }
+ }
+
+
# Start or empty tag: initialise attribute list.
print "\n";
if ($roottags{$tag}) {
@@ -1512,8 +1540,6 @@
# Errors when expecting end tag.
print " \"</\"{Name}{s}\">\" FAIL(\"Unexpected end-tag `%s': `</$tag>' expected.\",yytext);\n"
unless $nofail;
- print " \"<\"{Name}{s}\"\" FAIL(\"Unexpected start-tag `%s>': `</$tag>' expected.\",yytext);\n"
- unless $nofail;
print " . FAIL(\"Unexpected character `%c': `</$tag>' expected.\",yytext[0]);\n"
unless $mixed{$tag} or $nofail;
print " <<EOF>> FAIL(\"Premature EOF: `</$tag>' expected.\");\n" unless $nofail;
|