[hmath-commits] org.hartmath.tex2mml/src/org/hartmath/tex2mml Scanner.java,1.4,1.5 TeX2MathMLFactory
Status: Pre-Alpha
Brought to you by:
jsurfer
|
From: Klaus H. <js...@us...> - 2004-04-02 21:19:12
|
Update of /cvsroot/hmath/org.hartmath.tex2mml/src/org/hartmath/tex2mml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14950/src/org/hartmath/tex2mml Modified Files: Scanner.java TeX2MathMLFactory.java TeXParser.java Log Message: misc changes Index: Scanner.java =================================================================== RCS file: /cvsroot/hmath/org.hartmath.tex2mml/src/org/hartmath/tex2mml/Scanner.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Scanner.java 28 Mar 2004 19:14:54 -0000 1.4 --- Scanner.java 2 Apr 2004 21:07:01 -0000 1.5 *************** *** 55,60 **** final static public int TT_DOUBLE_BACKSLASH = 56; final static public int TT_AMPERSAND = 57; ! ! final static public int TT_BEGIN = 60; final static public int TT_END = 61; --- 55,59 ---- final static public int TT_DOUBLE_BACKSLASH = 56; final static public int TT_AMPERSAND = 57; ! final static public int TT_BEGIN = 60; final static public int TT_END = 61; *************** *** 226,236 **** return; } ! if (fChar == '\\') { ! fCurrentPosition++; ! token = TT_DOUBLE_BACKSLASH; ! return; } } ! break; case '^' : token = TT_OPERATOR; --- 225,254 ---- return; } ! switch (fChar) { ! case '\\' : ! fCurrentPosition++; ! token = TT_DOUBLE_BACKSLASH; ! return; ! case '!' : ! fCurrentPosition++; ! token = TT_BACKSLASH_SYMBOL; ! fBackslashSymbol = "!"; ! return; ! case ',' : ! fCurrentPosition++; ! token = TT_BACKSLASH_SYMBOL; ! fBackslashSymbol = ","; ! return; ! case ';' : ! fCurrentPosition++; ! token = TT_BACKSLASH_SYMBOL; ! fBackslashSymbol = ";"; ! return; } } ! fCurrentPosition++; ! token = TT_BACKSLASH_SYMBOL; ! fBackslashSymbol = " "; ! return; case '^' : token = TT_OPERATOR; *************** *** 343,349 **** // special identifiers beginning with "$$" are JSP/servlet specific variables !!! // see org.hmath.servlet.HMTag ! // if (fChar == '$') { ! // getChar(); ! // } while ((fChar >= 'a' && fChar <= 'z') || (fChar >= 'A' && fChar <= 'Z') || (fChar >= '0' && fChar <= '9')) { getChar(); --- 361,367 ---- // special identifiers beginning with "$$" are JSP/servlet specific variables !!! // see org.hmath.servlet.HMTag ! // if (fChar == '$') { ! // getChar(); ! // } while ((fChar >= 'a' && fChar <= 'z') || (fChar >= 'A' && fChar <= 'Z') || (fChar >= '0' && fChar <= '9')) { getChar(); *************** *** 352,402 **** int endPosition = fCurrentPosition--; int length = (--endPosition) - startPosition; ! // if (length == 1) { ! // return optimizedCurrentTokenSource1(startPosition, endPosition); ! // } // set default token: token = TT_BACKSLASH_SYMBOL; fBackslashSymbol = fSourceString.substring(startPosition, endPosition); ! if (fBackslashSymbol.length()>=3 && fBackslashSymbol.length()<=5) { ! int index = startPosition; ! switch(fBackslashSymbol.length()){ ! case 3: // \end ! if (fSourceString.charAt(index)=='e' && ! fSourceString.charAt(++index)=='n' && ! fSourceString.charAt(++index)=='d') { ! token = TT_END; ! return fBackslashSymbol; ! } ! break; ! case 4: // \left ! if (fSourceString.charAt(index)=='l' && ! fSourceString.charAt(++index)=='e' && ! fSourceString.charAt(++index)=='f' && ! fSourceString.charAt(++index)=='t') { ! token = TT_LEFT; ! return fBackslashSymbol; ! } ! break; ! case 5: // \begin \right ! if (fSourceString.charAt(index)=='b' && ! fSourceString.charAt(++index)=='e' && ! fSourceString.charAt(++index)=='g' && ! fSourceString.charAt(++index)=='i' && ! fSourceString.charAt(++index)=='n') { ! token = TT_BEGIN; ! return fBackslashSymbol; ! } ! index = startPosition; ! if (fSourceString.charAt(index)=='r' && ! fSourceString.charAt(++index)=='i' && ! fSourceString.charAt(++index)=='g' && ! fSourceString.charAt(++index)=='h' && ! fSourceString.charAt(++index)=='t') { ! token = TT_RIGHT; ! return fBackslashSymbol; ! } ! break; ! } ! } return fBackslashSymbol; } --- 370,418 ---- int endPosition = fCurrentPosition--; int length = (--endPosition) - startPosition; ! // if (length == 1) { ! // return optimizedCurrentTokenSource1(startPosition, endPosition); ! // } // set default token: token = TT_BACKSLASH_SYMBOL; fBackslashSymbol = fSourceString.substring(startPosition, endPosition); ! if (fBackslashSymbol.length() >= 3 && fBackslashSymbol.length() <= 5) { ! int index = startPosition; ! switch (fBackslashSymbol.length()) { ! case 3 : // \end ! if (fSourceString.charAt(index) == 'e' && fSourceString.charAt(++index) == 'n' && fSourceString.charAt(++index) == 'd') { ! token = TT_END; ! return fBackslashSymbol; ! } ! break; ! case 4 : // \left ! if (fSourceString.charAt(index) == 'l' ! && fSourceString.charAt(++index) == 'e' ! && fSourceString.charAt(++index) == 'f' ! && fSourceString.charAt(++index) == 't') { ! token = TT_LEFT; ! return fBackslashSymbol; ! } ! break; ! case 5 : // \begin \right ! if (fSourceString.charAt(index) == 'b' ! && fSourceString.charAt(++index) == 'e' ! && fSourceString.charAt(++index) == 'g' ! && fSourceString.charAt(++index) == 'i' ! && fSourceString.charAt(++index) == 'n') { ! token = TT_BEGIN; ! return fBackslashSymbol; ! } ! index = startPosition; ! if (fSourceString.charAt(index) == 'r' ! && fSourceString.charAt(++index) == 'i' ! && fSourceString.charAt(++index) == 'g' ! && fSourceString.charAt(++index) == 'h' ! && fSourceString.charAt(++index) == 't') { ! token = TT_RIGHT; ! return fBackslashSymbol; ! } ! break; ! } ! } return fBackslashSymbol; } Index: TeX2MathMLFactory.java =================================================================== RCS file: /cvsroot/hmath/org.hartmath.tex2mml/src/org/hartmath/tex2mml/TeX2MathMLFactory.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TeX2MathMLFactory.java 28 Mar 2004 19:15:09 -0000 1.7 --- TeX2MathMLFactory.java 2 Apr 2004 21:07:01 -0000 1.8 *************** *** 210,213 **** --- 210,217 ---- CONSTANT_SYMBOLS.put("ldots", new Operator(toEntity('\u222B'), CONSTANT)); String quad = toEntity('\u00A0') + toEntity('\u00A0'); + // TODO find a beter way to distinguish the different spacings: + CONSTANT_SYMBOLS.put("!", new Operator(toEntity(' '), CONSTANT)); + CONSTANT_SYMBOLS.put(",", new Operator(toEntity('\u00A0'), CONSTANT)); + CONSTANT_SYMBOLS.put(";", new Operator(toEntity('\u00A0'), CONSTANT)); CONSTANT_SYMBOLS.put("quad", new Operator(quad, CONSTANT)); CONSTANT_SYMBOLS.put("qquad", new Operator(quad + quad, CONSTANT)); Index: TeXParser.java =================================================================== RCS file: /cvsroot/hmath/org.hartmath.tex2mml/src/org/hartmath/tex2mml/TeXParser.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TeXParser.java 28 Mar 2004 19:15:50 -0000 1.6 --- TeXParser.java 2 Apr 2004 21:07:01 -0000 1.7 *************** *** 230,233 **** --- 230,236 ---- getNextToken(); return new Operator("["); + } else if (token == TT_OPERATOR && fOperatorString=="|") { + getNextToken(); + return new Operator(TeX2MathMLFactory.toEntity('\u2223')); // '|' or \mid } case TT_RIGHT : *************** *** 242,250 **** getNextToken(); return new Operator("]"); } } return null; } ! /** * --- 245,256 ---- getNextToken(); return new Operator("]"); + } else if (token == TT_OPERATOR && fOperatorString=="|") { + getNextToken(); + return new Operator(TeX2MathMLFactory.toEntity('\u2223')); // '|' or \mid } } return null; } ! /** * |