home *** CD-ROM | disk | FTP | other *** search
- package webeq3.parser.mathml;
-
- import java.util.Enumeration;
- import webeq3.app.Equation;
- import webeq3.constants.TNormalizationException;
- import webeq3.schema.Box;
- import webeq3.schema.ContentBox;
- import webeq3.schema.MO;
- import webeq3.schema.Normalizer;
-
- public class P2CConverter implements P2CRuleConstants {
- P2CRuleSet pre_rules = null;
- P2CRuleSet rules = new PrimaryRuleSet(this);
- P2CRuleSet aux_rules = new PreRuleSet(this);
-
- public void validateSyntax(Equation var1) throws TNormalizationException, P2CConverterException {
- var1.root.layout();
- Normalizer.normalize(var1.root);
- this.convert(var1.root, var1.markupRoot);
- }
-
- public void convert(Box var1, ContentBox var2) throws P2CConverterException {
- while(var2.children.size() > 0) {
- ((Box)var2).removeChild();
- }
-
- this.processExpression(var1, var2);
- }
-
- public void processExpression(Box var1, ContentBox var2) throws P2CConverterException {
- int var3 = -1;
- if (var1.children != null && var1.children.size() > 0) {
- Box var4 = (Box)var1.children.elementAt(0);
- if (var4 instanceof MO && var4.semanticType() == 2) {
- boolean var5 = PreRuleSet.isMatrix(var1);
- boolean var6 = PreRuleSet.isVector(var1);
- }
- }
-
- if (this.pre_rules != null) {
- var3 = this.pre_rules.getRuleMatch(var1);
- if (var3 != -1) {
- this.pre_rules.applyRule(var3, var1, var2);
- }
- }
-
- if (var3 == -1 && this.rules != null) {
- var3 = this.rules.getRuleMatch(var1);
- if (var3 != -1) {
- this.rules.applyRule(var3, var1, var2);
- }
- }
-
- if (var3 == -1 && this.aux_rules != null) {
- var3 = this.aux_rules.getRuleMatch(var1);
- if (var3 != -1) {
- this.aux_rules.applyRule(var3, var1, var2);
- }
- }
-
- if (var3 == -1) {
- if (!var1.getClass().getName().equals("webeq3.schema.Box") && !var1.getClass().getName().equals("webeq3.schema.MRow") && !var1.getClass().getName().equals("webeq3.schema.MTable") && !var1.getClass().getName().equals("webeq3.schema.MTr") && !var1.getClass().getName().equals("webeq3.schema.MTd")) {
- throw new P2CConverterException("Malformed expression", var1);
- }
-
- Enumeration var7 = var1.children.elements();
-
- while(var7.hasMoreElements()) {
- Box var8 = (Box)var7.nextElement();
- if (!var8.isSpaceLike() && !var8.isLFence() && !var8.isRFence() && !var8.isAFence() && !var8.adata.equals(",")) {
- this.processExpression(var8, var2);
- }
- }
- }
-
- }
-
- public void setAuxilliaryRules(P2CRuleSet var1) {
- this.aux_rules = var1;
- }
-
- public void setPreliminaryRules(P2CRuleSet var1) {
- this.pre_rules = var1;
- }
-
- public void setPrimaryRules(P2CRuleSet var1) {
- this.rules = var1;
- }
- }
-