#!/bin/perl # # The contents of this file are subject to the Mozilla Public # License Version 1.1 (the "License"); you may not use this file # except in compliance with the License. You may obtain a copy of # the License at http://www.mozilla.org/MPL/ # # Software distributed under the License is distributed on an "AS # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or # implied. See the License for the specific language governing # rights and limitations under the License. # # The Original Code is Mozilla MathML Project. # # The Initial Developer of the Original Code is The University Of # Queensland. Portions created by The University Of Queensland are # Copyright (C) 1999 The University Of Queensland. All # Rights Reserved. # # Contributor(s): # Roger B. Sidje # # Purpose: # This script produces data for the operator dictionary # RBS - Aug 28, 1999 - updated: 22 March, 2000. # Output: the file $operator_file contains the dictionary in suitable # format for inclusion with C++ macros. #$operator_file = '..\content\src\nsMathMLOperatorList.h'; $operator_file = 'operator.list'; $unicode_file = "byalpha.txt"; &getUnicode($unicode_file); # $unicode_file = "byalpha.txt" or "bycodes.txt" # byalpha.txt, bycodes.txt are simply the Save as text of # http://www.w3.org/TR/REC-MathML/chap6/byalpha.html # http://www.w3.org/TR/REC-MathML/chap6/bycodes.html &getMathMLOperators(); # Get the MathML Operators - exact *copy-paste* from # http://www.w3.org/TR/REC-MathML/appendixC.html print "\n***** Saving into the file ***** $operator_file *****\n"; open(OUTPUT_FILE, ">$operator_file") || die("can't open $operator_file"); print OUTPUT_FILE < */ /* MathML Operator Dictionary - Auto-generated by operator.pl. Do not edit! */ /* FORMAT MATHML_OPERATOR(_rank, _operator,= string value of the operator _flags, = bitwise: movablelimits|separator|largeop|accent|fence|stretchy|form _lspace, = leftspace in em _rspace) = rightspace in em */ HEADER_DATA # $MATHML_OPERATOR_LIST is global variable that contains all the # operators in the dictionary with their attributes print OUTPUT_FILE <) { #pattern byalpha: entity isolat2 377 unicode =capital Z, acute accent if ($byalpha) { # byalpha -- ALIASES ARE INCLUDED if ( /^([a-z\.]\S+)\s+\S+\s+\d+\s+(\S+)\s+.*/i ) { ($entity,$unicode) = ($1,$2); if ($UNICODE{$entity}) { #conflicting mapping ? next if $UNICODE{$entity} eq $unicode; print "\nWARNING! Found: $entity -> $unicode <> $UNICODE{$entity}"; } $UNICODE{$entity} = $unicode; $ENTITY_LAST_ALIAS{$unicode} = $entity; ++$count; } } else { # bycodes -- ALIASES ARE NOT INCLUDED #pattern bycode: unicode 9 entity mmlextra tabulator stop; horizontal tabulation if ( /^(\S+)\s+\d+\s+([a-z\.]+)\s+\S+\s+.*/i ) { ($unicode,$entity) = ($1,$2); # print "\n$entity $unicode"; $UNICODE{$entity} = $unicode; $ENTITY_LAST_ALIAS{$unicode} = $entity; ++$count; } } } @ENTITY = (keys %UNICODE); print "\nFound: $count unicode points, " . ($#ENTITY+1) . " entities\n"; } #Make the MathML Operator dictionary # INPUT: # OUTPUT: # $MATHML_OPERATOR_LIST - all operators in the dictionary sub getMathMLOperators { #Operator attributes: # values <-- default --> # form prefix |infix | postfix determined by position in mrow # fence true | false set by dictionary # accent true | false set by dictionary # lspace number h-unit set by dictionary # rspace number h-unit set by dictionary # largeop true | false set by dictionary # stretchy true | false set by dictionary # separator true | false set by dictionary # movablelimits true | false set by dictionary # symmetric true | false true # minzize number [h-unit | v-unit] 0 # maxsize number [h-unit | v-unit] | infinity infinity $DATA = <