forked from JUrban/mizarmode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Consider.pl
executable file
·32 lines (24 loc) · 1.01 KB
/
Consider.pl
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
#!/usr/bin/perl
# SYNOPSIS:
# mizf text/card_1.miz
# Consider.pl text/card_1.xml | grep line
# This script prints the last propositions in "consider" items,
# which are immediately referenced.
use XML::LibXML;
use strict;
my $parser = XML::LibXML->new();
my $doc = $parser->parse_file($ARGV[0]);
# For understanding the XPath expressions, see the up-to-date
# Mizar RELAX NG doc in the Mizar distro, or at
# http://lipa.ms.mff.cuni.cz/~urban/Mizar.html (a bit outdated).
my @result = $doc->findnodes('//Consider/Proposition[(position()=last())
and (position() > 1)
and (../following-sibling::*[1][(name()="Proposition")])
and (@nr = ../following-sibling::*[2][(name()="By")
]/Ref[not(@articlenr)]/@nr)]');
push @result, $doc->findnodes('//Consider/Proposition[(position()=last())
and (position() > 1)
and (@nr = ../following-sibling::*[1][(name()="Conclusion")
or (name()="Reconsider") or (name()="Consider"
)]/By/Ref[not(@articlenr)]/@nr)]');
foreach my $res (@result) { print $res->toString, "\n"; }