SF.net SVN: fricas:[2648] trunk

1 view
Skip to first unread message

wheb...@users.sourceforge.net

unread,
Mar 11, 2020, 11:55:37 AM3/11/20
to fricas...@googlegroups.com
Revision: 2648
http://sourceforge.net/p/fricas/code/2648
Author: whebisch
Date: 2020-03-11 15:55:30 +0000 (Wed, 11 Mar 2020)
Log Message:
-----------
Do not use 'stringify'

Modified Paths:
--------------
trunk/ChangeLog
trunk/src/algebra/mathml.spad
trunk/src/algebra/tex.spad
trunk/src/algebra/texmacs.spad

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2020-03-10 18:52:20 UTC (rev 2647)
+++ trunk/ChangeLog 2020-03-11 15:55:30 UTC (rev 2648)
@@ -1,3 +1,8 @@
+2020-03-11 Waldek Hebisch <heb...@math.uni.wroc.pl>
+
+ * src/algebra/mathml.spad, src/algebra/tex.spad,
+ src/algebra/texmacs.spad: Do not use 'stringify'
+
2020-03-10 Waldek Hebisch <heb...@math.uni.wroc.pl>

* src/interp/int-top.boot, src/interp/nruncomp.boot,

Modified: trunk/src/algebra/mathml.spad
===================================================================
--- trunk/src/algebra/mathml.spad 2020-03-10 18:52:20 UTC (rev 2647)
+++ trunk/src/algebra/mathml.spad 2020-03-11 15:55:30 UTC (rev 2648)
@@ -292,7 +292,7 @@
++ Date: January 2007
++ This package is based on the TeXFormat domain by Robert S. Sutor
++ without which I wouldn't have known where to start.
-++ Basic Operations: coerce, coerceS, coerceL, exprex, display
+++ Basic Operations: coerce, coerceS, coerceL, display
++ Description:
++ \spadtype{MathMLFormat} provides a coercion from \spadtype{OutputForm}
++ to MathML format.
@@ -315,16 +315,6 @@
coerceL : E -> S
++ coerceL(o) changes o in the standard output format to MathML
++ format and displays result as one long string.
- exprex : E -> S
- ++ exprex(o) converts \spadtype{OutputForm} to \spadtype{String}
- ++ with the structure preserved with braces. Actually this is
- ++ not quite accurate. The function \spadfun{precondition} is first
- ++ applied to the
- ++ \spadtype{OutputForm} expression before \spadfun{exprex}.
- ++ The raw \spadtype{OutputForm} and
- ++ the nature of the \spadfun{precondition} function is
- ++ still obscure to me
- ++ at the time of this writing (2007-02-14).
display : S -> Void
++ prints the string returned by coerce, adding <math ...> tags.

@@ -429,7 +419,6 @@
-- the whole expression needs to be enclosed in a mrow element.
-- It also checks for +- and removes the +.

- stringify : E -> S
tagEnd : (S, I, S) -> I
++ finds closing ">" of start or end tag for mathML element
ungroup : S -> S
@@ -465,29 +454,6 @@



- exprex(expr : E) : S ==
- -- This breaks down an expression into atoms and returns it as
- -- a string. It's for developmental purposes to help understand
- -- the expressions.
- a : E
- expr := precondition expr
--- sayMsg "0: "stringify expr
- atom?(expr) or (stringify expr = "NOTHING") =>
- concat ["{",stringify expr,"}"]
- op := operator(expr)
- sop : S := exprex op
- args : L E := arguments(expr)
- nargs : I := #args
--- sayMsg concat ["1: ",stringify first le," : ",string(nargs)$S]
- s : S := concat ["{",sop]
- if nargs > 0 then
- for a in args repeat
--- sayMsg concat ["2: ",stringify a]
- s1 : S := exprex a
- s := concat [s, s1]
- s := concat [s,"}"]
-
-
displayElt(mathML : S) : Void ==
-- Takes a string of syntactically complete mathML
-- and formats it for display.
@@ -604,8 +570,6 @@



- stringify expr == (mathObject2String$Lisp expr)@S
-
optionalWrap(expr : E) : S ==
tmp : S := formatExpr(expr, minPrec)
tmp = "" or tmp = " " => "<none/>"
@@ -871,11 +835,10 @@
i, len : Integer
intSplitLen : Integer := 20
atom?(expr) =>
- str := stringify expr
- len := #str
- -- this bit seems to deal with integers
+ -- this bit deals with integers
integer?(expr) =>
i := integer(expr)
+ str := string(i)
if (i < 0) or (i > 9)
then
group
@@ -891,12 +854,17 @@
concat [nstr, " ", str]
concat ["<mn>", elt(nstr, segment(2)$US), "</mn>"]
else concat ["<mn>", str, "</mn>"]
- str = "%pi" => "<mi>&#x003C0;</mi>"
- -- pi
- str = "%e" => "<mi>&#x02147;</mi>"
- -- ExponentialE
- str = "%i" => "<mi>&#x02148;</mi>"
- -- ImaginaryI
+ if symbol?(expr) then
+ es := symbol(expr)
+ es = "%pi"::Sy => return "<mi>&#x003C0;</mi>"
+ es = "%e"::Sy => return "<mi>&#x02147;</mi>"
+ es = "%i"::Sy => return "<mi>&#x02148;</mi>"
+ str := string(es)
+ else if string?(expr) then
+ str := string(expr)
+ else
+ error "Unrecognized atom in OutputForm"
+ len := #str
len > 0 and str.1 = char "%" => concat ["<mi>", str, "</mi>"]
-- should handle floats
len > 1 and digit? str.1 => concat ["<mn>", str, "</mn>"]

Modified: trunk/src/algebra/tex.spad
===================================================================
--- trunk/src/algebra/tex.spad 2020-03-10 18:52:20 UTC (rev 2647)
+++ trunk/src/algebra/tex.spad 2020-03-11 15:55:30 UTC (rev 2648)
@@ -149,7 +149,6 @@
postcondition : S -> S
splitLong : (S, I) -> L S
splitLong1 : (S, I) -> L S
- stringify : E -> S
ungroup : S -> S

-- public function definitions
@@ -232,8 +231,6 @@
then setelt!(str, i, char " ")$S
str

- stringify expr == (mathObject2String$Lisp expr) pretend S
-
lineConcat( line : S, lines : L S ) : L S ==
length := #line

@@ -554,10 +551,9 @@
intSplitLen : Integer := 20
str, s : S
atom?(expr) =>
- str := stringify expr
- len := #str
integer?(expr) =>
i := integer(expr)
+ str := string(i)
if (i < 0) or (i > 9)
then
group
@@ -573,9 +569,17 @@
concat [nstr, " ", str]
elt(nstr, segment(2)$US)
else str
- str = "%pi" => "\pi"
- str = "%e" => "e"
- str = "%i" => "i"
+ if symbol?(expr) then
+ es := symbol(expr)
+ es = "%pi"::Sy => return "\pi"
+ es = "%e"::Sy => return "e"
+ es = "%i"::Sy => return "i"
+ str := string(es)
+ else if string?(expr) then
+ str := string(expr)
+ else
+ error "Unrecognized atom in OutputForm"
+ len := #str
len > 1 and str.1 = char "%" and str.2 = char "%" =>
u : US := segment(3, len)$US
concat(" \%\%", str.u)

Modified: trunk/src/algebra/texmacs.spad
===================================================================
--- trunk/src/algebra/texmacs.spad 2020-03-10 18:52:20 UTC (rev 2647)
+++ trunk/src/algebra/texmacs.spad 2020-03-11 15:55:30 UTC (rev 2648)
@@ -921,7 +921,6 @@
newWithNum : I -> %
parenthesize : S -> S
postcondition : S -> S
- stringify : E -> S
ungroup : S -> S

-- public function definitions
@@ -965,8 +964,6 @@



- stringify expr == (mathObject2String$Lisp expr)@S
-
optionalWrap(s : S, expr : E, prec : I) : S ==
tmp : S := formatExpr(expr, prec)
tmp = "" or tmp = " " => ""
@@ -1179,8 +1176,9 @@
bodyL := arguments(body)
if #bodyL = 2 and has_op?(bvar := bodyL(2), 'CONCAT) then
bvarL := arguments(bvar)
- if #bvarL = 2 and is_symbol?(bvarL(1), 'd) then
- bvarS : S := stringify (bvarL(2))
+ if #bvarL = 2 and is_symbol?(bvarL(1), 'd)
+ and symbol?(bvarL(2)) then
+ bvarS : S := string(symbol(bvarL(2)))
return concat ["(concat ", formatExpr(bodyL(1), opPrec),
" _"*<mathd>", bvarS, "_")"]
formatExpr(body, opPrec)
@@ -1296,9 +1294,8 @@
-- expressions
is_symbol?(first args, "..."::Symbol) => "<ldots>"
not(has_op?(first args, 'ZAG)) =>
- op : S := stringify first args
- error "formatZag: Last argument in ZAG construct "
- "has unknown operator: " op
+ error "formatZag: Last argument in ZAG construct "
+ "has unknown operator"
tmpZag : L E := arguments(first args)
#args > 1 => "(frac " formatExpr(first tmpZag, minPrec) "(concat "
formatExpr(first rest tmpZag, minPrec) " _"+_" "
@@ -1310,11 +1307,10 @@
i, len : Integer
intSplitLen : Integer := 20
atom?(expr) =>
- str := stringify expr
- len := #str
- -- this bit seems to deal with integers
+ -- this bit deals with integers
integer?(expr) =>
i := integer(expr)
+ str := string(expr)
if (i < 0) or (i > 9)
then
group
@@ -1330,13 +1326,20 @@
concat [nstr, " ", str]
concat [elt(nstr, segment(2)$US)]
else concat [" _"", str, "_" "]
- str = "%pi" => "<mathpi>"
- -- pi
- str = "%e" => "<mathe>"
- -- ExponentialE
- str = "%i" => "<mathi>"
- -- ImaginaryI
- str = "infinity" => "<infty>"
+
+ if symbol?(expr) then
+ es := symbol(expr)
+ es = "%pi"::Sy => return "<mathpi>"
+ es = "%e"::Sy => return "<mathe>"
+ es = "%i"::Sy => return "<mathi>"
+ es = 'infinity => return "<infty>"
+ str := string(es)
+ else if string?(expr) then
+ str := string(expr)
+ else
+ error "Unrecognized atom in OutputForm"
+ len := #str
+
len > 0 and str.1 = char "%" => concat [" _"", str, "_" "]
-- presumably this is a literal string
-- WSP: preserve "..." and encode <less> symbols

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Reply all
Reply to author
Forward
0 new messages