1*7e90fac2SAndrew Rist#************************************************************** 2*7e90fac2SAndrew Rist# 3*7e90fac2SAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 4*7e90fac2SAndrew Rist# or more contributor license agreements. See the NOTICE file 5*7e90fac2SAndrew Rist# distributed with this work for additional information 6*7e90fac2SAndrew Rist# regarding copyright ownership. The ASF licenses this file 7*7e90fac2SAndrew Rist# to you under the Apache License, Version 2.0 (the 8*7e90fac2SAndrew Rist# "License"); you may not use this file except in compliance 9*7e90fac2SAndrew Rist# with the License. You may obtain a copy of the License at 10*7e90fac2SAndrew Rist# 11*7e90fac2SAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 12*7e90fac2SAndrew Rist# 13*7e90fac2SAndrew Rist# Unless required by applicable law or agreed to in writing, 14*7e90fac2SAndrew Rist# software distributed under the License is distributed on an 15*7e90fac2SAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*7e90fac2SAndrew Rist# KIND, either express or implied. See the License for the 17*7e90fac2SAndrew Rist# specific language governing permissions and limitations 18*7e90fac2SAndrew Rist# under the License. 19*7e90fac2SAndrew Rist# 20*7e90fac2SAndrew Rist#************************************************************** 21*7e90fac2SAndrew Rist 22*7e90fac2SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir$ARGV = shift @ARGV; 25cdf0e10cSrcweirmy %tokens; 26cdf0e10cSrcweir 27cdf0e10cSrcweirmy @files = glob("$ARGV/*.rnc"); 28cdf0e10cSrcweir 29cdf0e10cSrcweiropen( TOKEN, ">tokens.txt" ) || die "can't write token file"; 30cdf0e10cSrcweir 31cdf0e10cSrcweirforeach( @files ) 32cdf0e10cSrcweir{ 33cdf0e10cSrcweir print( "parsing $_\n" ); 34cdf0e10cSrcweir open ( XSD, $_ ) || die "can't open token file: $!"; 35cdf0e10cSrcweir while( <XSD> ) 36cdf0e10cSrcweir { 37cdf0e10cSrcweir chomp($_); 38cdf0e10cSrcweir if( /element (\S*:)?(\S*)/ ) 39cdf0e10cSrcweir { 40cdf0e10cSrcweir $tokens{$2} = 1; 41cdf0e10cSrcweir print("."); 42cdf0e10cSrcweir } 43cdf0e10cSrcweir elsif( /attribute (\S*:)?(\S*)/ ) 44cdf0e10cSrcweir { 45cdf0e10cSrcweir $tokens{$2} = 1; 46cdf0e10cSrcweir print("."); 47cdf0e10cSrcweir } 48cdf0e10cSrcweir elsif( /list\s*\{/ ) 49cdf0e10cSrcweir { 50cdf0e10cSrcweir while( <XSD> ) 51cdf0e10cSrcweir { 52cdf0e10cSrcweir chomp($_); 53cdf0e10cSrcweir last if( /^\s*\}/ ); 54cdf0e10cSrcweir if( /"(\S*?)\"/ ) 55cdf0e10cSrcweir { 56cdf0e10cSrcweir $tokens{$1} = 1; 57cdf0e10cSrcweir print("."); 58cdf0e10cSrcweir } 59cdf0e10cSrcweir } 60cdf0e10cSrcweir } 61cdf0e10cSrcweir } 62cdf0e10cSrcweir close ( XSD ); 63cdf0e10cSrcweir 64cdf0e10cSrcweir print("\n" ); 65cdf0e10cSrcweir} 66cdf0e10cSrcweir 67cdf0e10cSrcweirforeach( sort(keys(%tokens)) ) 68cdf0e10cSrcweir{ 69cdf0e10cSrcweir print TOKEN "$_\n"; 70cdf0e10cSrcweir} 71cdf0e10cSrcweirclose( TOKEN ); 72